flutter/dev/devicelab/lib/tasks/size_tests.dart
Yegor 6cdab85d28 Sync test code with Cocoon (#6129)
* fix flutter watch benchmark

Syncs d2d7950ecd

* Split Android/iOS impl behind a unified interface

Syncs db87e10fa5

* Switch from pub get to flutter packages get

Syncs b378005cbb

* "silent" option in test runner; fix analysis errors;
2016-09-29 10:19:15 -07:00

39 lines
1.3 KiB
Dart

// 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:io';
import '../framework/framework.dart';
import '../framework/utils.dart';
TaskFunction createBasicMaterialAppSizeTest() {
return () async {
const String sampleAppName = 'sample_flutter_app';
Directory sampleDir = dir('${Directory.systemTemp.path}/$sampleAppName');
if (await sampleDir.exists())
rmTree(sampleDir);
int apkSizeInBytes;
await inDirectory(Directory.systemTemp, () async {
await flutter('create', options: <String>[sampleAppName]);
if (!(await sampleDir.exists()))
throw 'Failed to create sample Flutter app in ${sampleDir.path}';
await inDirectory(sampleDir, () async {
await flutter('packages', options: <String>['get']);
await flutter('build', options: <String>['clean']);
await flutter('build', options: <String>['apk', '--release']);
apkSizeInBytes = await file('${sampleDir.path}/build/app.apk').length();
});
});
return new TaskResult.success(
<String, dynamic>{'release_size_in_bytes': apkSizeInBytes},
benchmarkScoreKeys: <String>['release_size_in_bytes']);
};
}