[tools] Fix Android Studio duplicate detection (#88384)
This commit is contained in:
@@ -157,6 +157,7 @@ void main() {
|
||||
Platform: () => platform,
|
||||
PlistParser: () => plistUtils,
|
||||
});
|
||||
|
||||
testUsingContext('Can discover Android Studio >=2020.3 location on Mac', () {
|
||||
final String studioInApplicationPlistFolder = globals.fs.path.join(
|
||||
'/',
|
||||
@@ -222,6 +223,43 @@ void main() {
|
||||
PlistParser: () => plistUtils,
|
||||
});
|
||||
|
||||
testUsingContext('Does not discover Android Studio with JetBrainsToolboxApp wrapper', () {
|
||||
final String applicationPlistFolder = globals.fs.path.join(
|
||||
'/',
|
||||
'Applications',
|
||||
'Android Studio.app',
|
||||
'Contents',
|
||||
);
|
||||
globals.fs.directory(applicationPlistFolder).createSync(recursive: true);
|
||||
|
||||
final String applicationsPlistFilePath = globals.fs.path.join(applicationPlistFolder, 'Info.plist');
|
||||
const Map<String, dynamic> jetbrainsInfoPlist = <String, dynamic>{
|
||||
'JetBrainsToolboxApp': 'ignored',
|
||||
};
|
||||
plistUtils.fileContents[applicationsPlistFilePath] = jetbrainsInfoPlist;
|
||||
|
||||
final String homeDirectoryPlistFolder = globals.fs.path.join(
|
||||
globals.fsUtils.homeDirPath,
|
||||
'Applications',
|
||||
'Android Studio.app',
|
||||
'Contents',
|
||||
);
|
||||
globals.fs.directory(homeDirectoryPlistFolder).createSync(recursive: true);
|
||||
|
||||
final String homeDirectoryPlistFilePath = globals.fs.path.join(homeDirectoryPlistFolder, 'Info.plist');
|
||||
plistUtils.fileContents[homeDirectoryPlistFilePath] = macStudioInfoPlist2020_3;
|
||||
|
||||
expect(AndroidStudio.allInstalled().length, 1);
|
||||
}, 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 installation from Spotlight query', () {
|
||||
// One in expected location.
|
||||
final String studioInApplication = fileSystem.path.join(
|
||||
@@ -370,64 +408,6 @@ void main() {
|
||||
Platform: () => platform,
|
||||
PlistParser: () => plistUtils,
|
||||
});
|
||||
|
||||
testUsingContext('extracts custom paths for Android Studio downloaded by JetBrainsToolbox on Mac', () {
|
||||
final String jetbrainsStudioInApplicationPlistFolder = globals.fs.path.join(
|
||||
homeMac,
|
||||
'Application',
|
||||
'JetBrains Toolbox',
|
||||
'Android Studio.app',
|
||||
'Contents',
|
||||
);
|
||||
globals.fs.directory(jetbrainsStudioInApplicationPlistFolder).createSync(recursive: true);
|
||||
const Map<String, dynamic> jetbrainsInfoPlist = <String, dynamic>{
|
||||
'CFBundleLongVersionString': '3.3',
|
||||
'CFBundleShortVersionString': '3.3',
|
||||
'CFBundleVersion': '3.3',
|
||||
'JetBrainsToolboxApp': '$homeMac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/183.5256920/Android Studio 3.3.app',
|
||||
};
|
||||
final String jetbrainsPlistFilePath = globals.fs.path.join(
|
||||
jetbrainsStudioInApplicationPlistFolder,
|
||||
'Info.plist',
|
||||
);
|
||||
plistUtils.fileContents[jetbrainsPlistFilePath] = jetbrainsInfoPlist;
|
||||
|
||||
final String studioInApplicationPlistFolder = globals.fs.path.join(
|
||||
globals.fs.path.join(homeMac,'Library','Application Support'),
|
||||
'JetBrains',
|
||||
'Toolbox',
|
||||
'apps',
|
||||
'AndroidStudio',
|
||||
'ch-0',
|
||||
'183.5256920',
|
||||
globals.fs.path.join('Android Studio 3.3.app', 'Contents'),
|
||||
);
|
||||
globals.fs.directory(studioInApplicationPlistFolder).createSync(recursive: true);
|
||||
final String studioPlistFilePath = globals.fs.path.join(
|
||||
studioInApplicationPlistFolder,
|
||||
'Info.plist',
|
||||
);
|
||||
plistUtils.fileContents[studioPlistFilePath] = macStudioInfoPlist;
|
||||
|
||||
final AndroidStudio studio = AndroidStudio.fromMacOSBundle(
|
||||
globals.fs.directory(jetbrainsStudioInApplicationPlistFolder)?.parent?.path,
|
||||
);
|
||||
expect(studio, isNotNull);
|
||||
expect(studio.pluginsPath, equals(globals.fs.path.join(
|
||||
homeMac,
|
||||
'Library',
|
||||
'Application Support',
|
||||
'AndroidStudio3.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,
|
||||
});
|
||||
});
|
||||
|
||||
FileSystem windowsFileSystem;
|
||||
|
||||
Reference in New Issue
Block a user