driver.scroll action; scroll perf test for Stocks
This commit is contained in:
@@ -18,6 +18,7 @@ class StockList extends StatelessComponent {
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return new ScrollableList(
|
||||
key: const ValueKey('stock-list'),
|
||||
itemExtent: StockRow.kHeight,
|
||||
children: stocks.map((Stock stock) {
|
||||
return new StockRow(
|
||||
|
||||
@@ -7,3 +7,5 @@ dependencies:
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
path: ../../packages/flutter_test
|
||||
flutter_driver:
|
||||
path: ../../packages/flutter_driver
|
||||
|
||||
13
examples/stocks/test_driver/scroll_perf.dart
Normal file
13
examples/stocks/test_driver/scroll_perf.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// 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();
|
||||
}
|
||||
40
examples/stocks/test_driver/scroll_perf_test.dart
Normal file
40
examples/stocks/test_driver/scroll_perf_test.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
main() {
|
||||
group('scrolling performance test', () {
|
||||
FlutterDriver driver;
|
||||
|
||||
setUpAll(() async {
|
||||
driver = await FlutterDriver.connect();
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
if (driver != null)
|
||||
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);
|
||||
|
||||
// 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.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.delayed(new Duration(milliseconds: 500));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user