• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'dart:async';
6
7import 'package:flutter_driver/flutter_driver.dart';
8import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
9
10void main() {
11  group('scrolling performance test', () {
12    FlutterDriver driver;
13
14    setUpAll(() async {
15      driver = await FlutterDriver.connect();
16    });
17
18    tearDownAll(() async {
19      if (driver != null)
20        driver.close();
21    });
22
23    test('measure', () async {
24      final Timeline timeline = await driver.traceAction(() async {
25        // Find the scrollable stock list
26        final SerializableFinder stockList = find.byValueKey('stock-list');
27        expect(stockList, isNotNull);
28
29        // Scroll down
30        for (int i = 0; i < 5; i++) {
31          await driver.scroll(stockList, 0.0, -300.0, const Duration(milliseconds: 300));
32          await Future<void>.delayed(const Duration(milliseconds: 500));
33        }
34
35        // Scroll up
36        for (int i = 0; i < 5; i++) {
37          await driver.scroll(stockList, 0.0, 300.0, const Duration(milliseconds: 300));
38          await Future<void>.delayed(const Duration(milliseconds: 500));
39        }
40      });
41
42      final TimelineSummary summary = TimelineSummary.summarize(timeline);
43      summary.writeSummaryToFile('stocks_scroll_perf', pretty: true);
44      summary.writeTimelineToFile('stocks_scroll_perf', pretty: true);
45    });
46  });
47}
48