Improves output file path logic in Android analyze (#136981)
This commit is contained in:
@@ -94,6 +94,7 @@ void main() {
|
||||
const String buildVariant = 'release';
|
||||
await runner.run(<String>['analyze', '--android', '--output-app-link-settings', '--build-variant=$buildVariant', tempDir.path]);
|
||||
expect(builder.outputVariant, buildVariant);
|
||||
expect(logger.statusText, contains(builder.outputPath));
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidBuilder: () => builder,
|
||||
});
|
||||
@@ -116,6 +117,7 @@ void main() {
|
||||
class FakeAndroidBuilder extends Fake implements AndroidBuilder {
|
||||
List<String> variants = const <String>[];
|
||||
String? outputVariant;
|
||||
final String outputPath = '/';
|
||||
|
||||
@override
|
||||
Future<List<String>> getBuildVariants({required FlutterProject project}) async {
|
||||
@@ -123,7 +125,8 @@ class FakeAndroidBuilder extends Fake implements AndroidBuilder {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> outputsAppLinkSettings(String buildVariant, {required FlutterProject project}) async {
|
||||
Future<String> outputsAppLinkSettings(String buildVariant, {required FlutterProject project}) async {
|
||||
outputVariant = buildVariant;
|
||||
return outputPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -914,7 +914,9 @@ Gradle Crashed
|
||||
AndroidStudio: () => FakeAndroidStudio(),
|
||||
});
|
||||
|
||||
testUsingContext('can call custom gradle task getApplicationIdForVariant and parse the result', () async {
|
||||
testUsingContext('can call custom gradle task outputFreeDebugAppLinkSettings and parse the result', () async {
|
||||
final String expectedOutputPath;
|
||||
expectedOutputPath = fileSystem.path.join('/build/deeplink_data', 'app-link-settings-freeDebug.json');
|
||||
final AndroidGradleBuilder builder = AndroidGradleBuilder(
|
||||
java: FakeJava(),
|
||||
logger: logger,
|
||||
@@ -927,10 +929,11 @@ Gradle Crashed
|
||||
platform: FakePlatform(),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
);
|
||||
processManager.addCommand(const FakeCommand(
|
||||
processManager.addCommand(FakeCommand(
|
||||
command: <String>[
|
||||
'gradlew',
|
||||
'-q',
|
||||
'-PoutputPath=$expectedOutputPath',
|
||||
'outputFreeDebugAppLinkSettings',
|
||||
],
|
||||
));
|
||||
@@ -940,6 +943,8 @@ Gradle Crashed
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidStudio: () => FakeAndroidStudio(),
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext("doesn't indicate how to consume an AAR when printHowToConsumeAar is false", () async {
|
||||
|
||||
@@ -175,16 +175,16 @@ void main() {
|
||||
expect(result, const ProcessResultMatcher());
|
||||
|
||||
final Directory androidApp = tempDir.childDirectory('android');
|
||||
final io.File fileDump = tempDir.childDirectory('build').childDirectory('app').childFile('app-link-settings-debug.json');
|
||||
result = await processManager.run(<String>[
|
||||
'.${platform.pathSeparator}${getGradlewFileName(platform)}',
|
||||
...getLocalEngineArguments(),
|
||||
'-q', // quiet output.
|
||||
'-PoutputPath=${fileDump.path}',
|
||||
'outputDebugAppLinkSettings',
|
||||
], workingDirectory: androidApp.path);
|
||||
|
||||
expect(result, const ProcessResultMatcher());
|
||||
|
||||
final io.File fileDump = tempDir.childDirectory('build').childDirectory('app').childFile('app-link-settings-debug.json');
|
||||
expect(fileDump.existsSync(), true);
|
||||
final Map<String, dynamic> json = jsonDecode(fileDump.readAsStringSync()) as Map<String, dynamic>;
|
||||
expect(json['applicationId'], 'com.example.testapp');
|
||||
@@ -220,16 +220,16 @@ void main() {
|
||||
expect(result, const ProcessResultMatcher());
|
||||
|
||||
final Directory androidApp = tempDir.childDirectory('android');
|
||||
final io.File fileDump = tempDir.childDirectory('build').childDirectory('app').childFile('app-link-settings-debug.json');
|
||||
result = await processManager.run(<String>[
|
||||
'.${platform.pathSeparator}${getGradlewFileName(platform)}',
|
||||
...getLocalEngineArguments(),
|
||||
'-q', // quiet output.
|
||||
'-PoutputPath=${fileDump.path}',
|
||||
'outputDebugAppLinkSettings',
|
||||
], workingDirectory: androidApp.path);
|
||||
|
||||
expect(result, const ProcessResultMatcher());
|
||||
|
||||
final io.File fileDump = tempDir.childDirectory('build').childDirectory('app').childFile('app-link-settings-debug.json');
|
||||
expect(fileDump.existsSync(), true);
|
||||
final Map<String, dynamic> json = jsonDecode(fileDump.readAsStringSync()) as Map<String, dynamic>;
|
||||
expect(json['applicationId'], 'com.example.testapp');
|
||||
|
||||
@@ -41,11 +41,10 @@ class FakeAndroidBuilder implements AndroidBuilder {
|
||||
Future<List<String>> getBuildVariants({required FlutterProject project}) async => const <String>[];
|
||||
|
||||
@override
|
||||
Future<void> outputsAppLinkSettings(
|
||||
Future<String> outputsAppLinkSettings(
|
||||
String buildVariant, {
|
||||
required FlutterProject project,
|
||||
}) async {}
|
||||
|
||||
}) async => '/';
|
||||
}
|
||||
|
||||
/// Creates a [FlutterProject] in a directory named [flutter_project]
|
||||
|
||||
Reference in New Issue
Block a user