use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class ExtractApksCommandTest method builderAndFlagsConstruction_optionalOutputDirectory_equivalent.
@Test
public void builderAndFlagsConstruction_optionalOutputDirectory_equivalent() throws Exception {
DeviceSpec deviceSpec = deviceWithSdk(21);
Path deviceSpecFile = createDeviceSpecFile(deviceSpec, tmpDir.resolve("device.json"));
BuildApksResult tableOfContentsProto = minimalApkSet();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
ExtractApksCommand fromFlags = ExtractApksCommand.fromFlags(new FlagParser().parse("--device-spec=" + deviceSpecFile, "--apks=" + apksArchiveFile, // Optional values.
"--output-dir=" + tmp.getRoot()));
ExtractApksCommand fromBuilderApi = ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).setOutputDirectory(tmpDir).build();
assertThat(fromFlags).isEqualTo(fromBuilderApi);
}
use of com.android.tools.build.bundletool.flags.FlagParser 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.flags.FlagParser in project bundletool by google.
the class GetDeviceSpecCommandTest method fromFlagsEquivalentToBuilder_onlyOutputPath.
@Test
public void fromFlagsEquivalentToBuilder_onlyOutputPath() {
Path outputPath = tmpDir.resolve("device.json");
GetDeviceSpecCommand commandViaFlags = GetDeviceSpecCommand.fromFlags(new FlagParser().parse("--output=" + outputPath), systemEnvironmentProvider, fakeServerOneDevice(lDeviceWithLocales("en-US")));
// The command via flags uses $ANDROID_HOME as a base for ADB location if the --adb flag is
// missing. The builder doesn't support that so we pass what should be the resolved ADB location
// for verification.
GetDeviceSpecCommand commandViaBuilder = GetDeviceSpecCommand.builder().setOutputPath(outputPath).setAdbPath(sdkDirPath.resolve("platform-tools").resolve("adb")).setAdbServer(commandViaFlags.getAdbServer()).setDeviceId(DEVICE_ID).build();
assertThat(commandViaFlags).isEqualTo(commandViaBuilder);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class GetDeviceSpecCommandTest method fromFlagsEquivalentToBuilder_allFlagsUsed_overwrite.
@Test
public void fromFlagsEquivalentToBuilder_allFlagsUsed_overwrite() {
Path outputPath = tmpDir.resolve("device.json");
GetDeviceSpecCommand commandViaFlags = GetDeviceSpecCommand.fromFlags(new FlagParser().parse("--adb=" + adbPath, "--device-id=" + DEVICE_ID, "--output=" + outputPath, "--overwrite"), systemEnvironmentProvider, fakeServerOneDevice(lDeviceWithLocales("en-US")));
GetDeviceSpecCommand commandViaBuilder = GetDeviceSpecCommand.builder().setAdbPath(adbPath).setDeviceId(DEVICE_ID).setOutputPath(outputPath).setAdbServer(commandViaFlags.getAdbServer()).setOverwriteOutput(true).build();
assertThat(commandViaFlags).isEqualTo(commandViaBuilder);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class GetDeviceSpecCommandTest method missingOuputFlag_fails.
@Test
public void missingOuputFlag_fails() {
expectMissingRequiredBuilderPropertyException("output", () -> GetDeviceSpecCommand.builder().setAdbPath(adbPath).build());
expectMissingRequiredFlagException("output", () -> GetDeviceSpecCommand.fromFlags(new FlagParser().parse("--adb=" + adbPath), systemEnvironmentProvider, fakeServerOneDevice(lDeviceWithLocales("en-US"))));
}
Aggregations