Add2app devicelab test (#18795)
This commit is contained in:
committed by
GitHub
parent
75b737ff69
commit
d4db748047
89
dev/devicelab/bin/tasks/module_test.dart
Normal file
89
dev/devicelab/bin/tasks/module_test.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
// Copyright (c) 2018 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 'dart:io';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
/// Tests that the Flutter module project template works and supports
|
||||
/// adding Flutter to an existing Android app.
|
||||
Future<Null> main() async {
|
||||
await task(() async {
|
||||
|
||||
section('Create Flutter module project');
|
||||
|
||||
final Directory directory = await Directory.systemTemp.createTemp('module');
|
||||
try {
|
||||
await inDirectory(directory, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--org', 'io.flutter.devicelab', '-t', 'module', 'hello'],
|
||||
);
|
||||
});
|
||||
|
||||
section('Build Android .aar');
|
||||
|
||||
await inDirectory(new Directory(path.join(directory.path, 'hello', '.android')), () async {
|
||||
await exec('./gradlew', <String>['flutter:assembleDebug']);
|
||||
});
|
||||
|
||||
final bool aarBuilt = exists(new File(path.join(
|
||||
directory.path,
|
||||
'hello',
|
||||
'build',
|
||||
'android_gen',
|
||||
'outputs',
|
||||
'aar',
|
||||
'flutter-debug.aar',
|
||||
)));
|
||||
|
||||
if (!aarBuilt) {
|
||||
return new TaskResult.failure('Failed to build .aar');
|
||||
}
|
||||
|
||||
section('Add to Android app');
|
||||
|
||||
final Directory hostApp = new Directory(path.join(directory.path, 'hello_host_app'));
|
||||
mkdir(hostApp);
|
||||
recursiveCopy(
|
||||
new Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests', 'android_host_app')),
|
||||
hostApp,
|
||||
);
|
||||
copy(
|
||||
new File(path.join(directory.path, 'hello', '.android', 'gradlew')),
|
||||
hostApp,
|
||||
);
|
||||
copy(
|
||||
new File(path.join(directory.path, 'hello', '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')),
|
||||
new Directory(path.join(hostApp.path, 'gradle', 'wrapper')),
|
||||
);
|
||||
|
||||
await inDirectory(hostApp, () async {
|
||||
await exec('chmod', <String>['+x', 'gradlew']);
|
||||
await exec('./gradlew', <String>['app:assembleDebug']);
|
||||
});
|
||||
|
||||
final bool appBuilt = exists(new File(path.join(
|
||||
hostApp.path,
|
||||
'app',
|
||||
'build',
|
||||
'outputs',
|
||||
'apk',
|
||||
'debug',
|
||||
'app-debug.apk',
|
||||
)));
|
||||
|
||||
if (!appBuilt) {
|
||||
return new TaskResult.failure('Failed to build .apk');
|
||||
}
|
||||
return new TaskResult.success(null);
|
||||
} catch (e) {
|
||||
return new TaskResult.failure(e.toString());
|
||||
} finally {
|
||||
rmTree(directory);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -261,6 +261,13 @@ tasks:
|
||||
stage: devicelab
|
||||
required_agent_capabilities: ["linux/android"]
|
||||
|
||||
module_test:
|
||||
description: >
|
||||
Checks that the module project template works and supports add2app on Android.
|
||||
stage: devicelab
|
||||
required_agent_capabilities: ["linux/android"]
|
||||
flaky: true
|
||||
|
||||
flutter_gallery_instrumentation_test:
|
||||
description: >
|
||||
Same as flutter_gallery__transition_perf but uses Android instrumentation
|
||||
|
||||
Reference in New Issue
Block a user