use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class DebugKeystoreUtilsTest method debugKeystore_homeEnvironmentVariable_thirdPreference.
@Test
public void debugKeystore_homeEnvironmentVariable_thirdPreference() throws Exception {
Path androidSdkHome = tmpDir.resolve("androidSdkHome");
Files.createDirectories(androidSdkHome);
Path homeDir = tmpDir.resolve("home");
Files.createDirectories(homeDir);
Path homeEnvDir = tmpDir.resolve("homeEnv");
Path homeEnvDebugKey = homeEnvDir.resolve(".android").resolve("debug.keystore");
FileUtils.createParentDirectories(homeEnvDebugKey);
Files.write(homeEnvDebugKey, new byte[0]);
FakeSystemEnvironmentProvider fakeEnvironmentVariableProvider = new FakeSystemEnvironmentProvider(/* variables= */
ImmutableMap.of("ANDROID_SDK_HOME", androidSdkHome.toString(), "HOME", homeEnvDir.toString()), /* properties= */
ImmutableMap.of(USER_HOME.key(), homeDir.toString()));
assertThat(DebugKeystoreUtils.DEBUG_KEYSTORE_CACHE.get(fakeEnvironmentVariableProvider)).hasValue(homeEnvDebugKey);
}
use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class GetDeviceSpecCommandTest method setUp.
@Before
public void setUp() throws IOException {
tmpDir = tmp.getRoot().toPath();
sdkDirPath = tmpDir.resolve("android-sdk");
adbPath = sdkDirPath.resolve("platform-tools").resolve("adb");
Files.createDirectories(adbPath.getParent());
Files.createFile(adbPath);
adbPath.toFile().setExecutable(true);
this.systemEnvironmentProvider = new FakeSystemEnvironmentProvider(ImmutableMap.of(ANDROID_HOME, sdkDirPath.toString(), ANDROID_SERIAL, DEVICE_ID));
}
use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class GetDeviceSpecCommandTest method fromFlagsEquivalentToBuilder_noDeviceId.
@Test
public void fromFlagsEquivalentToBuilder_noDeviceId() {
SystemEnvironmentProvider androidHomeProvider = new FakeSystemEnvironmentProvider(ImmutableMap.of(ANDROID_HOME, sdkDirPath.toString()));
Path outputPath = tmpDir.resolve("device.json");
GetDeviceSpecCommand commandViaFlags = GetDeviceSpecCommand.fromFlags(new FlagParser().parse("--adb=" + adbPath, "--output=" + outputPath), androidHomeProvider, fakeServerOneDevice(lDeviceWithLocales("en-US")));
GetDeviceSpecCommand commandViaBuilder = GetDeviceSpecCommand.builder().setAdbPath(adbPath).setOutputPath(outputPath).setAdbServer(commandViaFlags.getAdbServer()).build();
assertThat(commandViaFlags).isEqualTo(commandViaBuilder);
}
use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class DebugKeystoreUtilsTest method debugKeyStore_prefersAndroidSdkHome.
@Test
public void debugKeyStore_prefersAndroidSdkHome() throws Exception {
Path androidSdkHome = tmpDir.resolve("androidSdkHome");
Path androidSdkHomeKey = androidSdkHome.resolve(".android").resolve("debug.keystore");
FileUtils.createParentDirectories(androidSdkHomeKey);
Files.write(androidSdkHomeKey, new byte[0]);
Path homeDir = tmpDir.resolve("home");
Path homeDebugKey = homeDir.resolve(".android").resolve("debug.keystore");
FileUtils.createParentDirectories(homeDebugKey);
Files.write(homeDebugKey, new byte[0]);
FakeSystemEnvironmentProvider fakeEnvironmentVariableProvider = new FakeSystemEnvironmentProvider(/* variables= */
ImmutableMap.of("ANDROID_SDK_HOME", androidSdkHome.toString(), "HOME", homeDir.toString()), /* properties= */
ImmutableMap.of(USER_HOME.key(), homeDir.toString()));
assertThat(DebugKeystoreUtils.DEBUG_KEYSTORE_CACHE.get(fakeEnvironmentVariableProvider)).hasValue(androidSdkHomeKey);
}
use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class InstallMultiApksCommandTest method fromFlags_deviceId.
@Test
public void fromFlags_deviceId() {
Path zipFile = tmpDir.resolve("container.zip");
InstallMultiApksCommand fromFlags = InstallMultiApksCommand.fromFlags(new FlagParser().parse("--device-id=" + DEVICE_ID, "--apks-zip=" + zipFile), new FakeSystemEnvironmentProvider(ImmutableMap.of(ANDROID_HOME, sdkDirPath.toString(), ANDROID_SERIAL, "other-device-id")), fakeServerOneDevice(qDeviceWithLocales("en-US")));
assertThat(fromFlags.getDeviceId()).hasValue(DEVICE_ID);
}
Aggregations