diff --git a/examples/flutter_gallery/test/live_smoketest.dart b/examples/flutter_gallery/test/live_smoketest.dart index c64be0439f6..8f2977c8064 100644 --- a/examples/flutter_gallery/test/live_smoketest.dart +++ b/examples/flutter_gallery/test/live_smoketest.dart @@ -10,10 +10,11 @@ import 'dart:async'; -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_gallery/gallery/demos.dart'; @@ -33,12 +34,19 @@ const List _kUnsynchronizedDemoTitles = [ // These demos can't be backed out of by tapping a button whose // tooltip is 'Back'. const List _kSkippedDemoTitles = [ - 'Pull to refresh', 'Progress indicators', 'Activity Indicator', 'Video', ]; +// There are 3 places where the Gallery demos are traversed. +// 1- In widget tests such as examples/flutter_gallery/test/smoke_test.dart +// 2- In driver tests such as examples/flutter_gallery/test_driver/transitions_perf_test.dart +// 3- In on-device instrumentation tests such as examples/flutter_gallery/test/live_smoketest.dart +// +// If you change navigation behavior in the Gallery or in the framework, make +// sure all 3 are covered. + Future main() async { try { // Verify that _kUnsynchronizedDemos and _kSkippedDemos identify @@ -66,7 +74,7 @@ Future main() async { await controller.tap(demoItem); // Launch the demo controller.frameSync = !_kUnsynchronizedDemoTitles.contains(demo.title); print('Going back to demo list...'); - await controller.tap(find.byTooltip('Back')); + await controller.tap(backFinder); controller.frameSync = true; } } @@ -81,6 +89,18 @@ Future main() async { } } +final Finder backFinder = find.byElementPredicate( + (Element element) { + final Widget widget = element.widget; + if (widget is Tooltip) + return widget.message == 'Back'; + if (widget is CupertinoNavigationBarBackButton) + return true; + return false; + }, + description: 'Material or Cupertino back button', +); + class _LiveWidgetController extends LiveWidgetController { _LiveWidgetController(WidgetsBinding binding) : super(binding); diff --git a/examples/flutter_gallery/test/smoke_test.dart b/examples/flutter_gallery/test/smoke_test.dart index 9eb65f543a2..284ee0f2da3 100644 --- a/examples/flutter_gallery/test/smoke_test.dart +++ b/examples/flutter_gallery/test/smoke_test.dart @@ -18,6 +18,14 @@ const String kGalleryTitle = 'Flutter gallery'; // values approved by verityToStringOutput(). int toStringErrors = 0; +// There are 3 places where the Gallery demos are traversed. +// 1- In widget tests such as examples/flutter_gallery/test/smoke_test.dart +// 2- In driver tests such as examples/flutter_gallery/test_driver/transitions_perf_test.dart +// 3- In on-device instrumentation tests such as examples/flutter_gallery/test/live_smoketest.dart +// +// If you change navigation behavior in the Gallery or in the framework, make +// sure all 3 are covered. + void reportToStringError(String name, String route, int lineNumber, List lines, String message) { // If you're on line 12, then it has index 11. // If you want 1 line before and 1 line after, then you want lines with index 10, 11, and 12. diff --git a/examples/flutter_gallery/test_driver/transitions_perf_test.dart b/examples/flutter_gallery/test_driver/transitions_perf_test.dart index 440e332065b..c8fcd7e862f 100644 --- a/examples/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/examples/flutter_gallery/test_driver/transitions_perf_test.dart @@ -35,6 +35,14 @@ const List kProfiledDemos = [ 'Pickers@Material', ]; +// There are 3 places where the Gallery demos are traversed. +// 1- In widget tests such as examples/flutter_gallery/test/smoke_test.dart +// 2- In driver tests such as examples/flutter_gallery/test_driver/transitions_perf_test.dart +// 3- In on-device instrumentation tests such as examples/flutter_gallery/test/live_smoketest.dart +// +// If you change navigation behavior in the Gallery or in the framework, make +// sure all 3 are covered. + // Demos that will be backed out of within FlutterDriver.runUnsynchronized(); // // These names must match GalleryItem titles from kAllGalleryDemos