scroll_perf_test.dart 1.6 KB
Newer Older
1 2 3 4 5
// 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';
6

7
import 'package:flutter_driver/flutter_driver.dart';
8
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
9 10 11 12 13 14 15

void main() {
  group('scrolling performance test', () {
    FlutterDriver driver;

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

17
      await driver.waitUntilFirstFrameRasterized();
18 19 20 21 22 23 24 25
    });

    tearDownAll(() async {
      if (driver != null)
        driver.close();
    });

    test('measure', () async {
26
      final Timeline timeline = await driver.traceAction(() async {
27
        await driver.tap(find.text('Material'));
28

29
        final SerializableFinder demoList = find.byValueKey('GalleryDemoList');
30

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

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

46
      TimelineSummary.summarize(timeline)
Eric Seidel's avatar
Eric Seidel committed
47 48
        ..writeSummaryToFile('home_scroll_perf', pretty: true)
        ..writeTimelineToFile('home_scroll_perf', pretty: true);
49 50 51
    });
  });
}