Add frameSync mechanism to flutter_driver. (#7471)
With frameSync enabled, flutter_driver actions will only be performed when there are no pending frames in the app under test. This helps with reducing flakiness.
This commit is contained in:
committed by
GitHub
parent
f5bd8976de
commit
fea7496546
@@ -3,6 +3,8 @@ import 'dart:async';
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
const Duration kWaitBetweenActions = const Duration(milliseconds: 250);
|
||||
|
||||
void main() {
|
||||
group('flutter gallery transitions', () {
|
||||
FlutterDriver driver;
|
||||
@@ -18,13 +20,13 @@ void main() {
|
||||
test('navigation', () async {
|
||||
SerializableFinder menuItem = find.text('Text fields');
|
||||
await driver.scrollIntoView(menuItem);
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 500));
|
||||
await new Future<Null>.delayed(kWaitBetweenActions);
|
||||
|
||||
for (int i = 0; i < 15; i++) {
|
||||
await driver.tap(menuItem);
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 1000));
|
||||
await new Future<Null>.delayed(kWaitBetweenActions);
|
||||
await driver.tap(find.byTooltip('Back'));
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 1000));
|
||||
await new Future<Null>.delayed(kWaitBetweenActions);
|
||||
}
|
||||
}, timeout: new Timeout(new Duration(minutes: 1)));
|
||||
});
|
||||
|
||||
@@ -59,8 +59,15 @@ final List<String> demoTitles = <String>[
|
||||
'Typography'
|
||||
];
|
||||
|
||||
// Subset of [demoTitles] that needs frameSync turned off.
|
||||
final List<String> unsynchedDemoTitles = <String>[
|
||||
'Progress indicators',
|
||||
];
|
||||
|
||||
final FileSystem _fs = new LocalFileSystem();
|
||||
|
||||
const Duration kWaitBetweenActions = const Duration(milliseconds: 250);
|
||||
|
||||
/// Extracts event data from [events] recorded by timeline, validates it, turns
|
||||
/// it into a histogram, and saves to a JSON file.
|
||||
Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events, String outputPath) async {
|
||||
@@ -144,7 +151,7 @@ void main() {
|
||||
// Expand the demo category submenus.
|
||||
for (String category in demoCategories.reversed) {
|
||||
await driver.tap(find.text(category));
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 500));
|
||||
await new Future<Null>.delayed(kWaitBetweenActions);
|
||||
}
|
||||
// Scroll each demo menu item into view, launch the demo and
|
||||
// return to the demo menu 2x.
|
||||
@@ -152,13 +159,20 @@ void main() {
|
||||
print('Testing "$demoTitle" demo');
|
||||
SerializableFinder menuItem = find.text(demoTitle);
|
||||
await driver.scrollIntoView(menuItem);
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 500));
|
||||
await new Future<Null>.delayed(kWaitBetweenActions);
|
||||
|
||||
for(int i = 0; i < 2; i += 1) {
|
||||
await driver.tap(menuItem); // Launch the demo
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 500));
|
||||
await driver.tap(find.byTooltip('Back'));
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 1000));
|
||||
await new Future<Null>.delayed(kWaitBetweenActions);
|
||||
if (!unsynchedDemoTitles.contains(demoTitle)) {
|
||||
await driver.tap(find.byTooltip('Back'));
|
||||
} else {
|
||||
await driver.runUnsynchronized(() async {
|
||||
await new Future<Null>.delayed(kWaitBetweenActions);
|
||||
await driver.tap(find.byTooltip('Back'));
|
||||
});
|
||||
}
|
||||
await new Future<Null>.delayed(kWaitBetweenActions);
|
||||
}
|
||||
print('Success');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user