forked from flutter/flutter
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow plugins to use compileSdkPreview (flutter#131901)
Fixes flutter#124748 Based (heavily) off flutter#104662
- Loading branch information
Showing
7 changed files
with
209 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/flutter_tools/test/android_preview_integration.shard/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Android preview integration tests | ||
|
||
This directory contains integration tests which would otherwise live in `integration.shard`, | ||
but require a dependency on a CIPD-hosted preview version of Android (and therefore their own | ||
test shard). For additional information see the README in the `../integration.shard` directory. |
135 changes: 135 additions & 0 deletions
135
.../flutter_tools/test/android_preview_integration.shard/flutter_build_preview_sdk_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// 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:flutter_tools/src/base/file_system.dart'; | ||
import 'package:flutter_tools/src/base/io.dart'; | ||
|
||
import '../integration.shard/test_utils.dart'; | ||
import '../src/common.dart'; | ||
|
||
void main() { | ||
late Directory tempDir; | ||
late String flutterBin; | ||
late Directory exampleAppDir; | ||
late Directory pluginDir; | ||
final RegExp compileSdkVersionMatch = RegExp(r'compileSdk [\w.]+'); | ||
final String builtApkPath = <String>['build', 'app', 'outputs', 'flutter-apk', 'app-debug.apk'] | ||
.join(platform.pathSeparator); | ||
|
||
setUp(() async { | ||
tempDir = createResolvedTempDirectorySync('flutter_plugin_test.'); | ||
flutterBin = fileSystem.path.join( | ||
getFlutterRoot(), | ||
'bin', | ||
'flutter', | ||
); | ||
pluginDir = tempDir.childDirectory('aaa'); | ||
exampleAppDir = pluginDir.childDirectory('example'); | ||
|
||
processManager.runSync(<String>[ | ||
flutterBin, | ||
...getLocalEngineArguments(), | ||
'create', | ||
'--template=plugin', | ||
'--platforms=android', | ||
'aaa', | ||
], workingDirectory: tempDir.path); | ||
}); | ||
|
||
tearDown(() async { | ||
tryToDelete(tempDir); | ||
}); | ||
|
||
test( | ||
'build succeeds targeting string compileSdkVersion', | ||
() async { | ||
final File buildGradleFile = exampleAppDir.childDirectory('android').childDirectory('app').childFile('build.gradle'); | ||
// write a build.gradle with compileSdkVersion as `android-UpsideDownCake` which is a string preview version | ||
buildGradleFile.writeAsStringSync( | ||
buildGradleFile.readAsStringSync().replaceFirst(compileSdkVersionMatch, 'compileSdkVersion "android-UpsideDownCake"'), | ||
flush: true | ||
); | ||
expect(buildGradleFile.readAsStringSync(), contains('compileSdkVersion "android-UpsideDownCake"')); | ||
|
||
final ProcessResult result = await processManager.run(<String>[ | ||
flutterBin, | ||
...getLocalEngineArguments(), | ||
'build', | ||
'apk', | ||
'--debug', | ||
], workingDirectory: exampleAppDir.path); | ||
expect(exampleAppDir.childDirectory('build') | ||
.childDirectory('app') | ||
.childDirectory('outputs') | ||
.childDirectory('apk') | ||
.childDirectory('debug') | ||
.childFile('app-debug.apk').existsSync(), true); | ||
expect(result.stdout, contains('Built $builtApkPath')); | ||
}, | ||
); | ||
|
||
test( | ||
'build succeeds targeting string compileSdkPreview', | ||
() async { | ||
final File buildGradleFile = exampleAppDir.childDirectory('android').childDirectory('app').childFile('build.gradle'); | ||
// write a build.gradle with compileSdkPreview as `UpsideDownCake` which is a string preview version | ||
buildGradleFile.writeAsStringSync( | ||
buildGradleFile.readAsStringSync().replaceFirst(compileSdkVersionMatch, 'compileSdkPreview "UpsideDownCake"'), | ||
flush: true | ||
); | ||
expect(buildGradleFile.readAsStringSync(), contains('compileSdkPreview "UpsideDownCake"')); | ||
|
||
final ProcessResult result = await processManager.run(<String>[ | ||
flutterBin, | ||
...getLocalEngineArguments(), | ||
'build', | ||
'apk', | ||
'--debug', | ||
], workingDirectory: exampleAppDir.path); | ||
expect(exampleAppDir.childDirectory('build') | ||
.childDirectory('app') | ||
.childDirectory('outputs') | ||
.childDirectory('apk') | ||
.childDirectory('debug') | ||
.childFile('app-debug.apk').existsSync(), true); | ||
expect(result.stdout, contains('Built $builtApkPath')); | ||
}, | ||
); | ||
|
||
test( | ||
'build succeeds when both example app and plugin target compileSdkPreview', | ||
() async { | ||
final File appBuildGradleFile = exampleAppDir.childDirectory('android').childDirectory('app').childFile('build.gradle'); | ||
// write a build.gradle with compileSdkPreview as `UpsideDownCake` which is a string preview version | ||
appBuildGradleFile.writeAsStringSync( | ||
appBuildGradleFile.readAsStringSync().replaceFirst(compileSdkVersionMatch, 'compileSdkPreview "UpsideDownCake"'), | ||
flush: true | ||
); | ||
expect(appBuildGradleFile.readAsStringSync(), contains('compileSdkPreview "UpsideDownCake"')); | ||
|
||
final File pluginBuildGradleFile = pluginDir.childDirectory('android').childFile('build.gradle'); | ||
// change the plugin build.gradle to use a preview compile sdk version | ||
pluginBuildGradleFile.writeAsStringSync( | ||
pluginBuildGradleFile.readAsStringSync().replaceFirst(compileSdkVersionMatch, 'compileSdkPreview "UpsideDownCake"'), | ||
flush: true | ||
); | ||
expect(pluginBuildGradleFile.readAsStringSync(), contains('compileSdkPreview "UpsideDownCake"')); | ||
|
||
final ProcessResult result = await processManager.run(<String>[ | ||
flutterBin, | ||
...getLocalEngineArguments(), | ||
'build', | ||
'apk', | ||
'--debug', | ||
], workingDirectory: exampleAppDir.path); | ||
expect(exampleAppDir.childDirectory('build') | ||
.childDirectory('app') | ||
.childDirectory('outputs') | ||
.childDirectory('apk') | ||
.childDirectory('debug') | ||
.childFile('app-debug.apk').existsSync(), true); | ||
expect(result.stdout, contains('Built $builtApkPath')); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 0 additions & 94 deletions
94
packages/flutter_tools/test/integration.shard/flutter_build_preview_sdk.dart
This file was deleted.
Oops, something went wrong.