New Gallery UI reprise (#17031)

This commit is contained in:
Hans Muller
2018-04-27 08:11:20 -07:00
committed by GitHub
parent 4033937c89
commit bf3bd7667f
38 changed files with 2094 additions and 1253 deletions

View File

@@ -14,14 +14,17 @@ void main() {
});
test('navigation', () async {
final SerializableFinder menuItem = find.text('Text fields');
await driver.scrollUntilVisible(find.byType('CustomScrollView'), menuItem,
await driver.tap(find.text('Material'));
final SerializableFinder demoList = find.byValueKey('GalleryDemoList');
final SerializableFinder demoItem = find.text('Text fields');
await driver.scrollUntilVisible(demoList, demoItem,
dyScroll: -300.0,
alignment: 0.5,
timeout: const Duration(minutes: 1),
);
for (int i = 0; i < 15; i++) {
await driver.tap(menuItem);
await driver.tap(demoItem);
await driver.tap(find.byTooltip('Back'));
}
});

View File

@@ -22,24 +22,21 @@ void main() {
test('measure', () async {
final Timeline timeline = await driver.traceAction(() async {
final SerializableFinder home = find.byValueKey('Gallery List');
expect(home, isNotNull);
await driver.tap(find.text('Material'));
await driver.tap(find.text('Vignettes'));
await driver.tap(find.text('Components'));
await driver.tap(find.text('Style'));
final SerializableFinder demoList = find.byValueKey('GalleryDemoList');
// TODO(eseidel): These are very artificial scrolls, we should use better
// https://github.com/flutter/flutter/issues/3316
// Scroll down
for (int i = 0; i < 5; i++) {
await driver.scroll(home, 0.0, -300.0, const Duration(milliseconds: 300));
await driver.scroll(demoList, 0.0, -300.0, const Duration(milliseconds: 300));
await new Future<Null>.delayed(const Duration(milliseconds: 500));
}
// Scroll up
for (int i = 0; i < 5; i++) {
await driver.scroll(home, 0.0, 300.0, const Duration(milliseconds: 300));
await driver.scroll(demoList, 0.0, 300.0, const Duration(milliseconds: 300));
await new Future<Null>.delayed(const Duration(milliseconds: 500));
}
});

View File

@@ -6,13 +6,13 @@ import 'dart:async';
import 'dart:convert' show JsonEncoder;
import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_gallery/gallery/item.dart';
import 'package:flutter_gallery/gallery/demos.dart';
import 'package:flutter_gallery/main.dart' as app;
Future<String> _handleMessages(String message) async {
assert(message == 'demoNames');
return const JsonEncoder.withIndent(' ').convert(
kAllGalleryItems.map((GalleryItem item) => item.title).toList(),
kAllGalleryDemos.map((GalleryDemo demo) => '${demo.title}@${demo.category.name}').toList(),
);
}

View File

@@ -45,8 +45,7 @@ const List<String> kUnsynchronizedDemos = const <String>[
'Video',
];
// All of the gallery demo titles in the order they appear on the
// gallery home page.
// All of the gallery demos, identified as "title@category".
//
// These names are reported by the test app, see _handleMessages()
// in transitions_perf.dart.
@@ -121,20 +120,26 @@ Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
/// Scrolls each demo menu item into view, launches it, then returns to the
/// home screen twice.
Future<Null> runDemos(List<String> demos, FlutterDriver driver) async {
final SerializableFinder demoList = find.byValueKey('GalleryDemoList');
String currentDemoCategory;
for (String demo in demos) {
print('Testing "$demo" demo');
final SerializableFinder menuItem = find.text(demo);
await driver.scrollUntilVisible(find.byType('CustomScrollView'), menuItem,
dyScroll: -48.0,
alignment: 0.5,
);
final String demoAtCategory = _allDemos.firstWhere((String s) => s.startsWith(demo));
final String demoCategory = demoAtCategory.substring(demoAtCategory.indexOf('@') + 1);
if (currentDemoCategory == null) {
await driver.tap(find.text(demoCategory));
} else if (currentDemoCategory != demoCategory) {
await driver.tap(find.byTooltip('Back'));
await driver.tap(find.text(demoCategory));
}
currentDemoCategory = demoCategory;
final SerializableFinder demoItem = find.text(demo);
await driver.scrollUntilVisible(demoList, demoItem, dyScroll: -48.0, alignment: 0.5);
for (int i = 0; i < 2; i += 1) {
await driver.tap(menuItem); // Launch the demo
// This demo's back button isn't initially visible.
if (demo == 'Backdrop')
await driver.tap(find.byTooltip('Tap to dismiss'));
await driver.tap(demoItem); // Launch the demo
if (kUnsynchronizedDemos.contains(demo)) {
await driver.runUnsynchronized<Future<Null>>(() async {
@@ -144,8 +149,12 @@ Future<Null> runDemos(List<String> demos, FlutterDriver driver) async {
await driver.tap(find.byTooltip('Back'));
}
}
print('Success');
}
// Return to the home screen
await driver.tap(find.byTooltip('Back'));
}
void main([List<String> args = const <String>[]]) {
@@ -171,6 +180,7 @@ void main([List<String> args = const <String>[]]) {
});
test('all demos', () async {
// Collect timeline data for just a limited set of demos to avoid OOMs.
final Timeline timeline = await driver.traceAction(
() async {
@@ -190,14 +200,9 @@ void main([List<String> args = const <String>[]]) {
final String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json');
await saveDurationsHistogram(timeline.json['traceEvents'], histogramPath);
// Scroll back to the top
await driver.scrollUntilVisible(find.byType('CustomScrollView'), find.text(_allDemos[0]),
dyScroll: 200.0,
alignment: 0.0
);
// Execute the remaining tests.
final Set<String> unprofiledDemos = new Set<String>.from(_allDemos)..removeAll(kProfiledDemos);
final List<String> allDemoNames = _allDemos.map((String s) => s.substring(0, s.indexOf('@')));
final Set<String> unprofiledDemos = new Set<String>.from(allDemoNames)..removeAll(kProfiledDemos);
await runDemos(unprofiledDemos.toList(), driver);
}, timeout: const Timeout(const Duration(minutes: 5)));