Unverified Commit bbaced6d authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] cache adb path (#76650)

parent ed70d190
......@@ -167,7 +167,8 @@ class AndroidSdk {
AndroidSdkVersion get latestVersion => _latestVersion;
String get adbPath => getPlatformToolsPath(globals.platform.isWindows ? 'adb.exe' : 'adb');
String get adbPath => _adbPath ??= getPlatformToolsPath(globals.platform.isWindows ? 'adb.exe' : 'adb');
String _adbPath;
String get emulatorPath => getEmulatorPath();
......
......@@ -83,6 +83,27 @@ void main() {
Config: () => config,
});
testUsingContext('Caches adb location after first access', () {
sdkDir = MockAndroidSdk.createSdkDirectory();
config.setValue('android-sdk', sdkDir.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
final File adbFile = fileSystem.file(
fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'adb.exe')
)..createSync(recursive: true);
expect(sdk.adbPath, fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'adb.exe'));
adbFile.deleteSync(recursive: true);
expect(sdk.adbPath, fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'adb.exe'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
Platform: () => FakePlatform(operatingSystem: 'windows'),
Config: () => config,
});
testUsingContext('returns sdkmanager.bat path under cmdline tools for windows', () {
sdkDir = MockAndroidSdk.createSdkDirectory();
config.setValue('android-sdk', sdkDir.path);
......
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