drive_perf_debug_warning.dart 1.58 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
// Copyright 2019 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_devicelab/framework/adb.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';

11 12 13
Future<String> _runWithMode(String mode, String deviceId) async {
  final StringBuffer stderr = StringBuffer();
  await evalFlutter('drive', stderr: stderr, options: <String>[
14 15 16 17 18 19
    mode,
    '-t',
    'test_driver/scroll_perf.dart',
    '-d',
    deviceId,
  ]);
20
  return stderr.toString();
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
}

Future<TaskResult> run() async {
  cd('${flutterDirectory.path}/examples/flutter_gallery');
  final Device device = await devices.workingDevice;
  await device.unlock();
  final String deviceId = device.deviceId;
  await flutter('packages', options: <String>['get']);

  const String warningPiece = 'THIS BENCHMARK IS BEING RUN IN DEBUG MODE';

  final String debugOutput = await _runWithMode('--debug', deviceId);
  if (!debugOutput.contains(warningPiece)) {
    return TaskResult.failure(
        'Could not find the following warning message piece: $warningPiece'
    );
  }

  final String profileOutput = await _runWithMode('--profile', deviceId);
  if (profileOutput.contains(warningPiece)) {
    return TaskResult.failure(
      'Unexpected warning message piece in profile mode: $warningPiece'
    );
  }

  return TaskResult.success(null);
}

Future<void> main() async {
  deviceOperatingSystem = DeviceOperatingSystem.android;
  await task(run);
}