flutter/packages/flutter/test/widgets/binding_first_frame_rasterized_test.dart
Greg Spencer bbc0161669
Remove references to Window, and switch usages to PlatformDispatcher or SingletonFlutterWindow (#69617)
* Remove references to dart:ui.Window, and point usages to PlatformDispatcher or SingletonFlutterWindow, as appropriate

* remove new test platform dispatchers

* Amend documentation
2020-11-09 15:26:29 -08:00

34 lines
1.1 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fake_async/fake_async.dart';
void main() {
test('Deferred frames will trigger the first frame callback', () {
FakeAsync().run((FakeAsync fakeAsync) {
final WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized();
binding.deferFirstFrame();
runApp(const Placeholder());
fakeAsync.flushTimers();
// Simulates the engine completing a frame render to trigger the
// appropriate callback setting [WidgetBinding.firstFrameRasterized].
binding.platformDispatcher.onReportTimings!(<FrameTiming>[]);
expect(binding.firstFrameRasterized, isFalse);
binding.allowFirstFrame();
fakeAsync.flushTimers();
// Simulates the engine again.
binding.platformDispatcher.onReportTimings!(<FrameTiming>[]);
expect(binding.firstFrameRasterized, isTrue);
});
});
}