Merge pull request #2689 from yjbanov/benchmark-harness
[driver] API for getting performance traces
This commit is contained in:
@@ -3,11 +3,9 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:flutter_driver/src/error.dart';
|
||||
import 'package:stocks/main.dart' as app;
|
||||
|
||||
void main() {
|
||||
flutterDriverLog.listen(print);
|
||||
enableFlutterDriverExtension();
|
||||
app.main();
|
||||
}
|
||||
|
||||
@@ -19,22 +19,29 @@ void main() {
|
||||
driver.close();
|
||||
});
|
||||
|
||||
test('tap on the floating action button; verify counter', () async {
|
||||
// Find the scrollable stock list
|
||||
ObjectRef stockList = await driver.findByValueKey('stock-list');
|
||||
expect(stockList, isNotNull);
|
||||
test('measure', () async {
|
||||
Map<String, dynamic> profileJson = await driver.traceAction(() async {
|
||||
// Find the scrollable stock list
|
||||
ObjectRef stockList = await driver.findByValueKey('stock-list');
|
||||
expect(stockList, isNotNull);
|
||||
|
||||
// Scroll down 5 times
|
||||
for (int i = 0; i < 5; i++) {
|
||||
await driver.scroll(stockList, 0.0, -300.0, new Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 500));
|
||||
}
|
||||
// Scroll down
|
||||
for (int i = 0; i < 5; i++) {
|
||||
await driver.scroll(stockList, 0.0, -300.0, new Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
// Scroll up 5 times
|
||||
for (int i = 0; i < 5; i++) {
|
||||
await driver.scroll(stockList, 0.0, 300.0, new Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 500));
|
||||
}
|
||||
// Scroll up
|
||||
for (int i = 0; i < 5; i++) {
|
||||
await driver.scroll(stockList, 0.0, 300.0, new Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 500));
|
||||
}
|
||||
});
|
||||
|
||||
// Usually the profile is saved to a file and then analyzed using
|
||||
// chrom://tracing or a script. Both are out of scope for this little
|
||||
// test, so all we do is check that we received something.
|
||||
expect(profileJson, isNotNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user