Unverified Commit f9aa5842 authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

[tools] Fix Android Studio Arctic Fox Java path on macOS (#87267)

parent f226c1ea
......@@ -37,7 +37,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
this.studioAppName = 'AndroidStudio',
this.presetPluginsPath,
}) : version = version ?? Version.unknown {
_init();
_init(version: version);
}
factory AndroidStudio.fromMacOSBundle(String bundlePath) {
......@@ -435,7 +435,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
return keyMatcher.stringMatch(plistValue)?.split('=').last.trim().replaceAll('"', '');
}
void _init() {
void _init({Version? version}) {
_isValid = false;
_validationMessages.clear();
......@@ -449,6 +449,8 @@ class AndroidStudio implements Comparable<AndroidStudio> {
}
final String javaPath = globals.platform.isMacOS ?
version != null && version.major >= 2020 ?
globals.fs.path.join(directory, 'jre', 'Contents', 'Home') :
globals.fs.path.join(directory, 'jre', 'jdk', 'Contents', 'Home') :
globals.fs.path.join(directory, 'jre');
final String javaExecutable = globals.fs.path.join(javaPath, 'bin', 'java');
......
......@@ -45,6 +45,19 @@ const Map<String, dynamic> macStudioInfoPlist4_1 = <String, dynamic>{
},
};
const Map<String, dynamic> macStudioInfoPlist2020_3 = <String, dynamic>{
'CFBundleGetInfoString': 'Android Studio 2020.3, build AI-203.7717.56.2031.7583922. Copyright JetBrains s.r.o., (c) 2000-2021',
'CFBundleShortVersionString': '2020.3',
'CFBundleVersion': 'AI-203.7717.56.2031.7583922',
'JVMOptions': <String, dynamic>{
'Properties': <String, dynamic>{
'idea.vendor.name' : 'Google',
'idea.paths.selector': 'AndroidStudio2020.3',
'idea.platform.prefix': 'AndroidStudio',
},
},
};
final Platform linuxPlatform = FakePlatform(
operatingSystem: 'linux',
environment: <String, String>{'HOME': homeLinux},
......@@ -144,6 +157,38 @@ void main() {
Platform: () => platform,
PlistParser: () => plistUtils,
});
testUsingContext('Can discover Android Studio >=2020.3 location on Mac', () {
final String studioInApplicationPlistFolder = globals.fs.path.join(
'/',
'Application',
'Android Studio.app',
'Contents',
);
globals.fs.directory(studioInApplicationPlistFolder).createSync(recursive: true);
final String plistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist');
plistUtils.fileContents[plistFilePath] = macStudioInfoPlist2020_3;
final AndroidStudio studio = AndroidStudio.fromMacOSBundle(
globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path,
);
expect(studio, isNotNull);
expect(studio.pluginsPath, equals(globals.fs.path.join(
homeMac,
'Library',
'Application Support',
'Google',
'AndroidStudio2020.3',
)));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
FileSystemUtils: () => fsUtils,
ProcessManager: () => FakeProcessManager.any(),
// Custom home paths are not supported on macOS nor Windows yet,
// so we force the platform to fake Linux here.
Platform: () => platform,
PlistParser: () => plistUtils,
});
testUsingContext('Can discover Android Studio <4.1 location on Mac', () {
final String studioInApplicationPlistFolder = globals.fs.path.join(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment