Support materializing Flutter module host app on iOS (#21276)
* Prototype * Fix paths to Flutter library resources * Invoke pod install as necessary for materialized modules * Add devicelab test for module use on iOS * Remove debug output * Rebase, reame materialize editable * Add devicelab test editable iOS host app * Removed add2app test section
This commit is contained in:
committed by
Dan Field
parent
5c07e6dff7
commit
a600fe7f13
@@ -24,6 +24,7 @@ Future<Null> main() async {
|
||||
section('Create Flutter module project');
|
||||
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_module_test.');
|
||||
final Directory projectDir = Directory(path.join(tempDir.path, 'hello'));
|
||||
try {
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
@@ -34,14 +35,14 @@ Future<Null> main() async {
|
||||
|
||||
section('Add plugins');
|
||||
|
||||
final File pubspec = File(path.join(tempDir.path, 'hello', 'pubspec.yaml'));
|
||||
final File pubspec = File(path.join(projectDir.path, 'pubspec.yaml'));
|
||||
String content = await pubspec.readAsString();
|
||||
content = content.replaceFirst(
|
||||
'\ndependencies:\n',
|
||||
'\ndependencies:\n battery:\n package_info:\n',
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
@@ -50,7 +51,7 @@ Future<Null> main() async {
|
||||
|
||||
section('Build Flutter module library archive');
|
||||
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello', '.android')), () async {
|
||||
await inDirectory(Directory(path.join(projectDir.path, '.android')), () async {
|
||||
await exec(
|
||||
'./gradlew',
|
||||
<String>['flutter:assembleDebug'],
|
||||
@@ -59,8 +60,7 @@ Future<Null> main() async {
|
||||
});
|
||||
|
||||
final bool aarBuilt = exists(File(path.join(
|
||||
tempDir.path,
|
||||
'hello',
|
||||
projectDir.path,
|
||||
'.android',
|
||||
'Flutter',
|
||||
'build',
|
||||
@@ -75,7 +75,7 @@ Future<Null> main() async {
|
||||
|
||||
section('Build ephemeral host app');
|
||||
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
@@ -83,8 +83,7 @@ Future<Null> main() async {
|
||||
});
|
||||
|
||||
final bool ephemeralHostApkBuilt = exists(File(path.join(
|
||||
tempDir.path,
|
||||
'hello',
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
@@ -99,31 +98,30 @@ Future<Null> main() async {
|
||||
|
||||
section('Clean build');
|
||||
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter('clean');
|
||||
});
|
||||
|
||||
section('Running `flutter make-host-app-editable` to Materialize host app');
|
||||
section('Make Android host app editable');
|
||||
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'make-host-app-editable',
|
||||
options: <String>['android'],
|
||||
);
|
||||
});
|
||||
|
||||
section('Build materialized host app');
|
||||
section('Build editable host app');
|
||||
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
);
|
||||
});
|
||||
|
||||
final bool materializedHostApkBuilt = exists(File(path.join(
|
||||
tempDir.path,
|
||||
'hello',
|
||||
final bool editableHostApkBuilt = exists(File(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'host',
|
||||
'outputs',
|
||||
@@ -132,11 +130,11 @@ Future<Null> main() async {
|
||||
'app-release.apk',
|
||||
)));
|
||||
|
||||
if (!materializedHostApkBuilt) {
|
||||
return TaskResult.failure('Failed to build materialized host .apk');
|
||||
if (!editableHostApkBuilt) {
|
||||
return TaskResult.failure('Failed to build editable host .apk');
|
||||
}
|
||||
|
||||
section('Add to Android app');
|
||||
section('Add to existing Android app');
|
||||
|
||||
final Directory hostApp = Directory(path.join(tempDir.path, 'hello_host_app'));
|
||||
mkdir(hostApp);
|
||||
@@ -145,11 +143,11 @@ Future<Null> main() async {
|
||||
hostApp,
|
||||
);
|
||||
copy(
|
||||
File(path.join(tempDir.path, 'hello', '.android', 'gradlew')),
|
||||
File(path.join(projectDir.path, '.android', 'gradlew')),
|
||||
hostApp,
|
||||
);
|
||||
copy(
|
||||
File(path.join(tempDir.path, 'hello', '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')),
|
||||
File(path.join(projectDir.path, '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')),
|
||||
Directory(path.join(hostApp.path, 'gradle', 'wrapper')),
|
||||
);
|
||||
|
||||
|
||||
137
dev/devicelab/bin/tasks/module_test_ios.dart
Normal file
137
dev/devicelab/bin/tasks/module_test_ios.dart
Normal file
@@ -0,0 +1,137 @@
|
||||
// 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/ios.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 iOS app.
|
||||
Future<Null> main() async {
|
||||
await task(() async {
|
||||
|
||||
section('Create Flutter module project');
|
||||
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_module_test.');
|
||||
final Directory projectDir = Directory(path.join(tempDir.path, 'hello'));
|
||||
try {
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--org', 'io.flutter.devicelab', '-t', 'module', 'hello'],
|
||||
);
|
||||
});
|
||||
await prepareProvisioningCertificates(projectDir.path);
|
||||
|
||||
section('Build ephemeral host app without CocoaPods');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['ios'],
|
||||
);
|
||||
});
|
||||
|
||||
final bool ephemeralHostAppBuilt = exists(Directory(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'ios',
|
||||
'iphoneos',
|
||||
'Runner.app',
|
||||
)));
|
||||
|
||||
if (!ephemeralHostAppBuilt) {
|
||||
return TaskResult.failure('Failed to build ephemeral host .app');
|
||||
}
|
||||
|
||||
section('Clean build');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter('clean');
|
||||
});
|
||||
|
||||
section('Add plugins');
|
||||
|
||||
final File pubspec = File(path.join(projectDir.path, 'pubspec.yaml'));
|
||||
String content = await pubspec.readAsString();
|
||||
content = content.replaceFirst(
|
||||
'\ndependencies:\n',
|
||||
'\ndependencies:\n battery:\n package_info:\n',
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
);
|
||||
});
|
||||
|
||||
section('Build ephemeral host app with CocoaPods');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['ios'],
|
||||
);
|
||||
});
|
||||
|
||||
final bool ephemeralHostAppWithCocoaPodsBuilt = exists(Directory(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'ios',
|
||||
'iphoneos',
|
||||
'Runner.app',
|
||||
)));
|
||||
|
||||
if (!ephemeralHostAppWithCocoaPodsBuilt) {
|
||||
return TaskResult.failure('Failed to build ephemeral host .app with CocoaPods');
|
||||
}
|
||||
|
||||
section('Clean build');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter('clean');
|
||||
});
|
||||
|
||||
section('Make iOS host app editable');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'make-host-app-editable',
|
||||
options: <String>['ios'],
|
||||
);
|
||||
});
|
||||
|
||||
section('Build editable host app');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['ios'],
|
||||
);
|
||||
});
|
||||
|
||||
final bool editableHostAppBuilt = exists(Directory(path.join(
|
||||
projectDir.path,
|
||||
'build',
|
||||
'ios',
|
||||
'iphoneos',
|
||||
'Runner.app',
|
||||
)));
|
||||
|
||||
if (!editableHostAppBuilt) {
|
||||
return TaskResult.failure('Failed to build editable host .app');
|
||||
}
|
||||
return TaskResult.success(null);
|
||||
} catch (e) {
|
||||
return TaskResult.failure(e.toString());
|
||||
} finally {
|
||||
//rmTree(tempDir);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -297,6 +297,13 @@ tasks:
|
||||
stage: devicelab_ios
|
||||
required_agent_capabilities: ["mac/ios"]
|
||||
|
||||
module_test_ios:
|
||||
description: >
|
||||
Checks that the module project template works and supports add2app on iOS.
|
||||
stage: devicelab
|
||||
required_agent_capabilities: ["mac/ios"]
|
||||
flaky: true
|
||||
|
||||
external_ui_integration_test_ios:
|
||||
description: >
|
||||
Checks that external UIs work on iOS.
|
||||
|
||||
Reference in New Issue
Block a user