Unverified Commit 90f353f9 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] dont crash when looking for AS4.1 on windows with no LOCALAPPDATA (#77261)

parent 5e62e664
...@@ -346,7 +346,7 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -346,7 +346,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
} }
// 4.1 has a different location for AndroidStudio installs on Windows. // 4.1 has a different location for AndroidStudio installs on Windows.
if (globals.platform.isWindows) { if (globals.platform.isWindows && globals.platform.environment.containsKey('LOCALAPPDATA')) {
final File homeDot = globals.fs.file(globals.fs.path.join( final File homeDot = globals.fs.file(globals.fs.path.join(
globals.platform.environment['LOCALAPPDATA'], globals.platform.environment['LOCALAPPDATA'],
'Google', 'Google',
......
...@@ -288,6 +288,24 @@ void main() { ...@@ -288,6 +288,24 @@ void main() {
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
}); });
testUsingContext('Does not discover Android Studio 4.1 location on Windows if LOCALAPPDATA is null', () {
windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio4.1\.home')
..createSync(recursive: true)
..writeAsStringSync(r'C:\Program Files\AndroidStudio');
windowsFileSystem
.directory(r'C:\Program Files\AndroidStudio')
.createSync(recursive: true);
expect(AndroidStudio.allInstalled(), isEmpty);
}, overrides: <Type, Generator>{
Platform: () => FakePlatform(
operatingSystem: 'windows',
environment: <String, String>{}, // Does not include LOCALAPPDATA
),
FileSystem: () => windowsFileSystem,
ProcessManager: () => FakeProcessManager.any(),
});
group('Installation detection on Linux', () { group('Installation detection on Linux', () {
FileSystemUtils fsUtils; FileSystemUtils fsUtils;
......
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