use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class InstallMultiApksCommandTest method setUp.
@Before
public void setUp() throws IOException {
tmpDir = tmp.getRoot().toPath();
sdkDirPath = Files.createDirectory(tmpDir.resolve("android-sdk"));
adbPath = sdkDirPath.resolve("platform-tools").resolve("adb");
Files.createDirectories(adbPath.getParent());
Files.createFile(adbPath);
adbPath.toFile().setExecutable(true);
systemEnvironmentProvider = new FakeSystemEnvironmentProvider(ImmutableMap.of(ANDROID_HOME, sdkDirPath.toString(), ANDROID_SERIAL, DEVICE_ID));
device = FakeDevice.fromDeviceSpec(DEVICE_ID, DeviceState.ONLINE, qDeviceWithLocales("en-US"));
adbCommandExecuted = false;
}
use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider 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.testing.FakeSystemEnvironmentProvider 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.testing.FakeSystemEnvironmentProvider 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());
}
use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class BuildApksCommandTest method noKeystoreProvidedPrintsWarning_debugKeystore.
@Test
public void noKeystoreProvidedPrintsWarning_debugKeystore() throws Exception {
Path debugKeystorePath = tmpDir.resolve(".android").resolve("debug.keystore");
FileUtils.createParentDirectories(debugKeystorePath);
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.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH), new PrintStream(output), provider, fakeAdbServer);
assertThat(new String(output.toByteArray(), UTF_8)).contains("INFO: The APKs will be signed with the debug keystore");
}
Aggregations