use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class BuildApksConnectedDeviceTest method setUp.
@Before
public void setUp() throws Exception {
tmpDir = tmp.getRoot().toPath();
bundlePath = tmpDir.resolve("bundle");
outputDir = tmp.newFolder("output").toPath();
outputFilePath = outputDir.resolve("app.apks");
sdkDirPath = Files.createDirectory(tmpDir.resolve("android-sdk"));
setUpAdb(sdkDirPath);
this.androidHomeProvider = new FakeSystemEnvironmentProvider(ImmutableMap.of(ANDROID_HOME, sdkDirPath.toString()));
}
use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class InstallApksCommandTest method setUp.
@Before
public void setUp() throws Exception {
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);
simpleApksPath = createApksArchiveFile(createSimpleTableOfContent(ZipPath.create("base-master.apk")), tmpDir.resolve("simple-bundle.apks"));
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 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.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class DebugKeystoreUtilsTest method debugKeystore_userHome_secondPreference.
@Test
public void debugKeystore_userHome_secondPreference() throws Exception {
Path androidSdkHome = tmpDir.resolve("androidSdkHome");
Files.createDirectories(androidSdkHome);
Path homeDir = tmpDir.resolve("home");
Path homeDebugKey = homeDir.resolve(".android").resolve("debug.keystore");
FileUtils.createParentDirectories(homeDebugKey);
Files.write(homeDebugKey, new byte[0]);
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(homeDebugKey);
}
use of com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider in project bundletool by google.
the class DebugKeystoreUtilsTest method debugKeystore_notFound.
@Test
public void debugKeystore_notFound() throws Exception {
Path androidSdkHome = tmpDir.resolve("androidSdkHome").resolve(".android");
Files.createDirectories(androidSdkHome);
Path homeDir = tmpDir.resolve("home");
Files.createDirectories(homeDir);
FakeSystemEnvironmentProvider fakeEnvironmentVariableProvider = new FakeSystemEnvironmentProvider(/* variables= */
ImmutableMap.of("ANDROID_SDK_HOME", tmpDir.resolve("androidSdkHome").toString(), "HOME", homeDir.toString()), /* properties= */
ImmutableMap.of(USER_HOME.key(), homeDir.toString()));
assertThat(DebugKeystoreUtils.DEBUG_KEYSTORE_CACHE.get(fakeEnvironmentVariableProvider)).isEmpty();
}
Aggregations