flutter/dev/benchmarks/complex_layout/test_driver/scroll_perf_test.dart
Ian Hickson 1993a67381
Performance test cleanup (#20652)
* Fix TODO syntax.
* Clarify messages for some timeouts, to aid debugging.
* Increase some other timeouts that were a needlessly short, to reduce sources of flakes.
* Remove some more timeouts that were mostly redundant, to remove complexity.
* Minor style cleanup.
* Remove some dangerous traps (specifically, hide the explicit start/end times in TimedEvent since they shouldn't matter).
2018-08-17 13:19:28 -07:00

63 lines
2.2 KiB
Dart

// 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' hide TypeMatcher, isInstanceOf;
void main() {
group('scrolling performance test', () {
FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
});
tearDownAll(() async {
if (driver != null)
driver.close();
});
Future<Null> testScrollPerf(String listKey, String summaryName) async {
// The slight initial delay avoids starting the timing during a
// period of increased load on the device. Without this delay, the
// benchmark has greater noise.
// See: https://github.com/flutter/flutter/issues/19434
await new Future<Null>.delayed(const Duration(milliseconds: 250));
final Timeline timeline = await driver.traceAction(() async {
// Find the scrollable stock list
final SerializableFinder list = find.byValueKey(listKey);
expect(list, isNotNull);
// Scroll down
for (int i = 0; i < 5; i += 1) {
await driver.scroll(list, 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 += 1) {
await driver.scroll(list, 0.0, 300.0, const Duration(milliseconds: 300));
await new Future<Null>.delayed(const Duration(milliseconds: 500));
}
});
final TimelineSummary summary = new TimelineSummary.summarize(timeline);
summary.writeSummaryToFile(summaryName, pretty: true);
summary.writeTimelineToFile(summaryName, pretty: true);
}
test('complex_layout_scroll_perf', () async {
await testScrollPerf('complex-scroll', 'complex_layout_scroll_perf');
});
test('tiles_scroll_perf', () async {
await driver.tap(find.byTooltip('Open navigation menu'));
await driver.tap(find.byValueKey('scroll-switcher'));
await testScrollPerf('tiles-scroll', 'tiles_scroll_perf');
});
});
}