scroll_perf_test.dart 1.56 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_driver/flutter_driver.dart';
6
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
7 8 9

void main() {
  group('scrolling performance test', () {
10
    late FlutterDriver driver;
11 12 13

    setUpAll(() async {
      driver = await FlutterDriver.connect();
14

15
      await driver.waitUntilFirstFrameRasterized();
16 17 18 19 20 21 22
    });

    tearDownAll(() async {
        driver.close();
    });

    test('measure', () async {
23
      final Timeline timeline = await driver.traceAction(() async {
24
        await driver.tap(find.text('Material'));
25

26
        final SerializableFinder demoList = find.byValueKey('GalleryDemoList');
27

Josh Soref's avatar
Josh Soref committed
28
        // TODO(eseidel): These are very artificial scrolls, we should use better
Eric Seidel's avatar
Eric Seidel committed
29
        // https://github.com/flutter/flutter/issues/3316
30 31
        // Scroll down
        for (int i = 0; i < 5; i++) {
32
          await driver.scroll(demoList, 0.0, -300.0, const Duration(milliseconds: 300));
33
          await Future<void>.delayed(const Duration(milliseconds: 500));
34 35 36 37
        }

        // Scroll up
        for (int i = 0; i < 5; i++) {
38
          await driver.scroll(demoList, 0.0, 300.0, const Duration(milliseconds: 300));
39
          await Future<void>.delayed(const Duration(milliseconds: 500));
40 41 42
        }
      });

43 44
      final TimelineSummary summary = TimelineSummary.summarize(timeline);
      await summary.writeTimelineToFile('home_scroll_perf', pretty: true);
45
    }, timeout: Timeout.none);
46 47
  });
}