scroll_perf_test.dart 1.53 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 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

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

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

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

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

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

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

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

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