use of com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider in project bundletool by google.
the class BuildSdkApksCommandTest method noKeystoreProvidedPrintsInfo_debugKeystore.
@Test
public void noKeystoreProvidedPrintsInfo_debugKeystore() throws Exception {
SystemEnvironmentProvider provider = new FakeSystemEnvironmentProvider(/* variables= */
ImmutableMap.of(ANDROID_HOME, "/android/home", ANDROID_SERIAL, DEVICE_ID), /* properties= */
ImmutableMap.of(USER_HOME.key(), tmpDir.toString()));
Path debugKeystorePath = tmpDir.resolve(".android").resolve("debug.keystore");
FileUtils.createParentDirectories(debugKeystorePath);
createDebugKeystore(debugKeystorePath, DEBUG_KEYSTORE_PASSWORD, DEBUG_KEY_ALIAS, DEBUG_KEY_PASSWORD);
try (ByteArrayOutputStream outputByteArrayStream = new ByteArrayOutputStream();
PrintStream outputPrintStream = new PrintStream(outputByteArrayStream)) {
BuildSdkApksCommand.fromFlags(getDefaultFlagsWithAdditionalFlags(), outputPrintStream, provider);
assertThat(new String(outputByteArrayStream.toByteArray(), UTF_8)).contains("INFO: The APKs will be signed with the debug keystore");
}
}
use of com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider 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.model.utils.SystemEnvironmentProvider in project bundletool by google.
the class BuildApksCommandTest method noKeystoreProvidedPrintsWarning.
@Test
public void noKeystoreProvidedPrintsWarning() {
SystemEnvironmentProvider provider = new FakeSystemEnvironmentProvider(/* variables= */
ImmutableMap.of(ANDROID_HOME, "/android/home", ANDROID_SERIAL, DEVICE_ID), /* properties= */
ImmutableMap.of(USER_HOME.key(), "/"));
ByteArrayOutputStream output = new ByteArrayOutputStream();
BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH), new PrintStream(output), provider, fakeAdbServer);
assertThat(new String(output.toByteArray(), UTF_8)).contains("WARNING: The APKs won't be signed");
}
use of com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider in project bundletool by google.
the class BuildApksCommandTest method stampKeystoreFlags_noKeystore_fails.
@Test
public void stampKeystoreFlags_noKeystore_fails() throws Exception {
SystemEnvironmentProvider provider = new FakeSystemEnvironmentProvider(/* variables= */
ImmutableMap.of(ANDROID_HOME, "/android/home", ANDROID_SERIAL, DEVICE_ID), /* properties= */
ImmutableMap.of(USER_HOME.key(), "/"));
ByteArrayOutputStream output = new ByteArrayOutputStream();
InvalidCommandException e = assertThrows(InvalidCommandException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH, "--create-stamp=" + true), new PrintStream(output), provider, fakeAdbServer));
assertThat(e).hasMessageThat().isEqualTo("No key was found to sign the stamp.");
}
use of com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider in project bundletool by google.
the class BuildApksCommandTest method buildingViaFlagsAndBuilderHasSameResult_stamp_debugKey.
@Test
public void buildingViaFlagsAndBuilderHasSameResult_stamp_debugKey() throws Exception {
Path debugKeystorePath = tmpDir.resolve(".android").resolve("debug.keystore");
FileUtils.createParentDirectories(debugKeystorePath);
SigningConfiguration signingConfiguration = createDebugKeystore(debugKeystorePath, DEBUG_KEYSTORE_PASSWORD, DEBUG_KEY_ALIAS, DEBUG_KEY_PASSWORD);
SystemEnvironmentProvider provider = new FakeSystemEnvironmentProvider(/* variables= */
ImmutableMap.of(ANDROID_HOME, "/android/home", ANDROID_SERIAL, DEVICE_ID), /* properties= */
ImmutableMap.of(USER_HOME.key(), tmpDir.toString()));
ByteArrayOutputStream output = new ByteArrayOutputStream();
BuildApksCommand commandViaFlags = BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH, "--create-stamp=" + true), new PrintStream(output), provider, fakeAdbServer);
BuildApksCommand commandViaBuilder = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setSigningConfiguration(signingConfiguration).setSourceStamp(SourceStamp.builder().setSigningConfiguration(signingConfiguration).build()).setAapt2Command(commandViaFlags.getAapt2Command().get()).setExecutorServiceInternal(commandViaFlags.getExecutorService()).setExecutorServiceCreatedByBundleTool(true).setOutputPrintStream(commandViaFlags.getOutputPrintStream().get()).build();
assertThat(commandViaBuilder.getSourceStamp()).isEqualTo(commandViaFlags.getSourceStamp());
assertThat(commandViaBuilder.getSigningConfiguration()).isEqualTo(commandViaFlags.getSigningConfiguration());
}
Aggregations