Search in sources :

Example 6 with FakeSystemEnvironmentProvider

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);
}
Also used : Path(java.nio.file.Path) FakeSystemEnvironmentProvider(com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider) Test(org.junit.Test)

Example 7 with FakeSystemEnvironmentProvider

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));
}
Also used : FakeSystemEnvironmentProvider(com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider) Before(org.junit.Before)

Example 8 with FakeSystemEnvironmentProvider

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);
}
Also used : Path(java.nio.file.Path) FakeSystemEnvironmentProvider(com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider) FakeSystemEnvironmentProvider(com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider) SystemEnvironmentProvider(com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 9 with FakeSystemEnvironmentProvider

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);
}
Also used : Path(java.nio.file.Path) FakeSystemEnvironmentProvider(com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider) Test(org.junit.Test)

Example 10 with FakeSystemEnvironmentProvider

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);
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) FakeSystemEnvironmentProvider(com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Aggregations

FakeSystemEnvironmentProvider (com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider)15 Test (org.junit.Test)11 Path (java.nio.file.Path)9 FlagParser (com.android.tools.build.bundletool.flags.FlagParser)6 SystemEnvironmentProvider (com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 PrintStream (java.io.PrintStream)5 ZipPath (com.android.tools.build.bundletool.model.ZipPath)4 Before (org.junit.Before)4 ApksigSigningConfiguration (com.android.tools.build.bundletool.model.ApksigSigningConfiguration)1 SigningConfiguration (com.android.tools.build.bundletool.model.SigningConfiguration)1 InvalidCommandException (com.android.tools.build.bundletool.model.exceptions.InvalidCommandException)1 DefaultSystemEnvironmentProvider (com.android.tools.build.bundletool.model.utils.DefaultSystemEnvironmentProvider)1