Move android_plugin_example_app_build_test from devicelab to tool integration tests (#74685)
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
// Copyright 2014 The Flutter 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 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('flutter_plugin_test.');
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
test('plugin example can be built using current Flutter Gradle plugin', () async {
|
||||
final String flutterBin = fileSystem.path.join(
|
||||
getFlutterRoot(),
|
||||
'bin',
|
||||
'flutter',
|
||||
);
|
||||
|
||||
processManager.runSync(<String>[
|
||||
flutterBin,
|
||||
...getLocalEngineArguments(),
|
||||
'create',
|
||||
'--template=plugin',
|
||||
'--platforms=android',
|
||||
'plugin_test',
|
||||
], workingDirectory: tempDir.path);
|
||||
|
||||
final Directory exampleAppDir = tempDir.childDirectory('plugin_test').childDirectory('example');
|
||||
|
||||
final File buildGradleFile = exampleAppDir.childDirectory('android').childFile('build.gradle');
|
||||
expect(buildGradleFile, exists);
|
||||
|
||||
final String buildGradle = buildGradleFile.readAsStringSync();
|
||||
final RegExp androidPluginRegExp =
|
||||
RegExp(r'com\.android\.tools\.build:gradle:(\d+\.\d+\.\d+)');
|
||||
|
||||
// Use AGP 4.1.0
|
||||
String newBuildGradle = buildGradle.replaceAll(
|
||||
androidPluginRegExp, 'com.android.tools.build:gradle:4.1.0');
|
||||
buildGradleFile.writeAsStringSync(newBuildGradle);
|
||||
|
||||
// Run flutter build apk using AGP 4.1.0
|
||||
processManager.runSync(<String>[
|
||||
flutterBin,
|
||||
...getLocalEngineArguments(),
|
||||
'build',
|
||||
'apk',
|
||||
'--target-platform=android-arm',
|
||||
], workingDirectory: exampleAppDir.path);
|
||||
|
||||
final File exampleApk = fileSystem.file(fileSystem.path.join(
|
||||
exampleAppDir.path,
|
||||
'build',
|
||||
'app',
|
||||
'outputs',
|
||||
'flutter-apk',
|
||||
'app-release.apk',
|
||||
));
|
||||
expect(exampleApk, exists);
|
||||
|
||||
// Clean
|
||||
processManager.runSync(<String>[
|
||||
flutterBin,
|
||||
...getLocalEngineArguments(),
|
||||
'clean',
|
||||
], workingDirectory: exampleAppDir.path);
|
||||
|
||||
// Remove Gradle wrapper
|
||||
fileSystem
|
||||
.directory(fileSystem.path
|
||||
.join(exampleAppDir.path, 'android', 'gradle', 'wrapper'))
|
||||
.deleteSync(recursive: true);
|
||||
|
||||
// Use AGP 3.3.0
|
||||
newBuildGradle = buildGradle.replaceAll(
|
||||
androidPluginRegExp, 'com.android.tools.build:gradle:3.3.0');
|
||||
buildGradleFile.writeAsStringSync(newBuildGradle);
|
||||
|
||||
// Enable R8 in gradle.properties
|
||||
final File gradleProperties =
|
||||
exampleAppDir.childDirectory('android').childFile('gradle.properties');
|
||||
expect(gradleProperties, exists);
|
||||
|
||||
gradleProperties.writeAsStringSync('''
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
android.enableR8=true''');
|
||||
|
||||
// Run flutter build apk using AGP 3.3.0
|
||||
processManager.runSync(<String>[
|
||||
flutterBin,
|
||||
...getLocalEngineArguments(),
|
||||
'build',
|
||||
'apk',
|
||||
'--target-platform=android-arm',
|
||||
], workingDirectory: exampleAppDir.path);
|
||||
expect(exampleApk, exists);
|
||||
});
|
||||
}
|
||||
@@ -17,22 +17,32 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
testWithoutContext('device.getDevices', () async {
|
||||
final Directory tempDir = createResolvedTempDirectorySync('daemon_mode_test.');
|
||||
Directory tempDir;
|
||||
Process daemonProcess;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('daemon_mode_test.');
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
tryToDelete(tempDir);
|
||||
daemonProcess?.kill();
|
||||
});
|
||||
|
||||
testWithoutContext('device.getDevices', () async {
|
||||
final BasicProject _project = BasicProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
|
||||
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||
|
||||
const ProcessManager processManager = LocalProcessManager();
|
||||
final Process process = await processManager.start(
|
||||
daemonProcess = await processManager.start(
|
||||
<String>[flutterBin, ...getLocalEngineArguments(), '--show-test-device', 'daemon'],
|
||||
workingDirectory: tempDir.path,
|
||||
);
|
||||
|
||||
final StreamController<String> stdout = StreamController<String>.broadcast();
|
||||
transformToLines(process.stdout).listen((String line) => stdout.add(line));
|
||||
transformToLines(daemonProcess.stdout).listen((String line) => stdout.add(line));
|
||||
final Stream<Map<String, dynamic>> stream = stdout
|
||||
.stream
|
||||
.map<Map<String, dynamic>>(parseFlutterResponse)
|
||||
@@ -42,7 +52,7 @@ void main() {
|
||||
expect(response['event'], 'daemon.connected');
|
||||
|
||||
// start listening for devices
|
||||
process.stdin.writeln('[${jsonEncode(<String, dynamic>{
|
||||
daemonProcess.stdin.writeln('[${jsonEncode(<String, dynamic>{
|
||||
'id': 1,
|
||||
'method': 'device.enable',
|
||||
})}]');
|
||||
@@ -56,7 +66,7 @@ void main() {
|
||||
expect(response['event'], 'device.added');
|
||||
|
||||
// get the list of all devices
|
||||
process.stdin.writeln('[${jsonEncode(<String, dynamic>{
|
||||
daemonProcess.stdin.writeln('[${jsonEncode(<String, dynamic>{
|
||||
'id': 2,
|
||||
'method': 'device.getDevices',
|
||||
})}]');
|
||||
@@ -68,8 +78,5 @@ void main() {
|
||||
final dynamic result = response['result'];
|
||||
expect(result, isList);
|
||||
expect(result, isNotEmpty);
|
||||
|
||||
tryToDelete(tempDir);
|
||||
process.kill();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,9 +12,17 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
testWithoutContext('can step over statements', () async {
|
||||
final Directory tempDir = createResolvedTempDirectorySync('debugger_stepping_test.');
|
||||
Directory tempDir;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('debugger_stepping_test.');
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
testWithoutContext('can step over statements', () async {
|
||||
final SteppingProject _project = SteppingProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
|
||||
@@ -43,6 +51,5 @@ void main() {
|
||||
}
|
||||
|
||||
await _flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user