Unverified Commit 1f72406b authored by xster's avatar xster Committed by GitHub

Platform agnostic gallery smoke test (#23423)

parent e70f1952
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/services.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.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_test/flutter_test.dart';
import 'package:flutter_gallery/gallery/demos.dart'; import 'package:flutter_gallery/gallery/demos.dart';
...@@ -33,12 +34,19 @@ const List<String> _kUnsynchronizedDemoTitles = <String>[ ...@@ -33,12 +34,19 @@ const List<String> _kUnsynchronizedDemoTitles = <String>[
// These demos can't be backed out of by tapping a button whose // These demos can't be backed out of by tapping a button whose
// tooltip is 'Back'. // tooltip is 'Back'.
const List<String> _kSkippedDemoTitles = <String>[ const List<String> _kSkippedDemoTitles = <String>[
'Pull to refresh',
'Progress indicators', 'Progress indicators',
'Activity Indicator', 'Activity Indicator',
'Video', '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<void> main() async { Future<void> main() async {
try { try {
// Verify that _kUnsynchronizedDemos and _kSkippedDemos identify // Verify that _kUnsynchronizedDemos and _kSkippedDemos identify
...@@ -66,7 +74,7 @@ Future<void> main() async { ...@@ -66,7 +74,7 @@ Future<void> main() async {
await controller.tap(demoItem); // Launch the demo await controller.tap(demoItem); // Launch the demo
controller.frameSync = !_kUnsynchronizedDemoTitles.contains(demo.title); controller.frameSync = !_kUnsynchronizedDemoTitles.contains(demo.title);
print('Going back to demo list...'); print('Going back to demo list...');
await controller.tap(find.byTooltip('Back')); await controller.tap(backFinder);
controller.frameSync = true; controller.frameSync = true;
} }
} }
...@@ -81,6 +89,18 @@ Future<void> main() async { ...@@ -81,6 +89,18 @@ Future<void> 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 { class _LiveWidgetController extends LiveWidgetController {
_LiveWidgetController(WidgetsBinding binding) : super(binding); _LiveWidgetController(WidgetsBinding binding) : super(binding);
......
...@@ -18,6 +18,14 @@ const String kGalleryTitle = 'Flutter gallery'; ...@@ -18,6 +18,14 @@ const String kGalleryTitle = 'Flutter gallery';
// values approved by verityToStringOutput(). // values approved by verityToStringOutput().
int toStringErrors = 0; 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<String> lines, String message) { void reportToStringError(String name, String route, int lineNumber, List<String> lines, String message) {
// If you're on line 12, then it has index 11. // 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. // If you want 1 line before and 1 line after, then you want lines with index 10, 11, and 12.
......
...@@ -35,6 +35,14 @@ const List<String> kProfiledDemos = <String>[ ...@@ -35,6 +35,14 @@ const List<String> kProfiledDemos = <String>[
'Pickers@Material', '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(); // Demos that will be backed out of within FlutterDriver.runUnsynchronized();
// //
// These names must match GalleryItem titles from kAllGalleryDemos // These names must match GalleryItem titles from kAllGalleryDemos
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment