Ian Hickson 2a54524337 Fix tests to use Ahem, and helpful changes around that (#9332)
* Fix tests to use Ahem, and helpful changes around that

- Fix fonts that had metric-specific behaviours.

- LiveTestWidgetsFlutterBinding.allowAllFrames has been renamed
  to LiveTestWidgetsFlutterBinding.framePolicy.

- LiveTestWidgetsFlutterBinding now defaults to using a frame policy
  that pumps slightly more frames, to animate the pointer crosshairs.

- Added "flutter run --use-test-fonts" to enable Ahem on devices.

- Changed how idle() works to be more effective in live mode.

- Display the test name in live mode (unless ahem fonts are enabled).

- Added a toString to TextSelectionPoint.

- Style nit fixes.

* Roll engine to get Ahem changes.

* Update tests for dartdoc changes.

* Fix flutter_tools tests
2017-04-12 13:33:02 -07:00

44 lines
1.7 KiB
Dart

// Copyright 2016 The Chromium 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 'package:flutter_test/flutter_test.dart';
import 'package:flutter_gallery/gallery/app.dart';
Future<String> mockUpdateUrlFetcher() {
// A real implementation would connect to the network to retrieve this value
return new Future<String>.value('http://www.example.com/');
}
void main() {
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
if (binding is LiveTestWidgetsFlutterBinding)
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
// Regression test for https://github.com/flutter/flutter/pull/5168
testWidgets('update dialog', (WidgetTester tester) async {
await tester.pumpWidget(new GalleryApp(updateUrlFetcher: mockUpdateUrlFetcher));
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame
expect(find.text('UPDATE'), findsOneWidget);
await tester.tap(find.text('NO THANKS'));
await tester.pump();
await tester.tap(find.text('Shrine'));
await tester.pump(); // Launch shrine
await tester.pump(const Duration(seconds: 1)); // transition is complete
final Finder backButton = find.byTooltip('Back');
expect(backButton, findsOneWidget);
await tester.tap(backButton);
await tester.pump(); // Start the pop "back" operation.
await tester.pump(); // Complete the willPop() Future.
await tester.pump(const Duration(seconds: 1)); // transition is complete
//await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1));
expect(find.text('UPDATE'), findsNothing);
});
}