use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class CheckTransparencyCommandTest method buildingCommandViaFlags_bundleMode_withApkSigningKeyCertificateFlag.
@Test
public void buildingCommandViaFlags_bundleMode_withApkSigningKeyCertificateFlag() {
Throwable e = assertThrows(UnknownFlagsException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse("--mode=BUNDLE", "--bundle=" + bundlePath, "--apk-signing-key-certificate=" + apkSigningKeyCertificatePath), systemEnvironmentProvider, fakeAdbServer));
assertThat(e).hasMessageThat().contains("Unrecognized flags: --apk-signing-key-certificate");
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildBundleCommandTest method buildingViaFlagsAndBuilderHasSameResult_optionalOverwrite.
@Test
public void buildingViaFlagsAndBuilderHasSameResult_optionalOverwrite() throws Exception {
Path baseModulePath = buildSimpleModule("base");
BuildBundleCommand commandViaBuilder = BuildBundleCommand.builder().setOutputPath(bundlePath).setModulesPaths(ImmutableList.of(baseModulePath)).setOverwriteOutput(true).build();
BuildBundleCommand commandViaFlags = BuildBundleCommand.fromFlags(new FlagParser().parse("--output=" + bundlePath, "--modules=" + baseModulePath, "--overwrite"));
assertThat(commandViaBuilder).isEqualTo(commandViaFlags);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class GetDeviceSpecCommandTest method fromFlagsEquivalentToBuilder_allFlagsUsed.
@Test
public void fromFlagsEquivalentToBuilder_allFlagsUsed() {
Path outputPath = tmpDir.resolve("device.json");
GetDeviceSpecCommand commandViaFlags = GetDeviceSpecCommand.fromFlags(new FlagParser().parse("--adb=" + adbPath, "--device-id=" + DEVICE_ID, "--output=" + outputPath, "--device-tier=" + DEVICE_TIER, "--device-groups=" + Joiner.on(",").join(DEVICE_GROUPS)), systemEnvironmentProvider, fakeServerOneDevice(lDeviceWithLocales("en-US")));
GetDeviceSpecCommand commandViaBuilder = GetDeviceSpecCommand.builder().setAdbPath(adbPath).setDeviceId(DEVICE_ID).setOutputPath(outputPath).setAdbServer(commandViaFlags.getAdbServer()).setDeviceTier(DEVICE_TIER).setDeviceGroups(DEVICE_GROUPS).build();
assertThat(commandViaFlags).isEqualTo(commandViaBuilder);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class GetSizeCommandTest method wrongSubCommand_throws.
@Test
public void wrongSubCommand_throws() throws Exception {
BuildApksResult tableOfContentsProto = BuildApksResult.getDefaultInstance();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
ParsedFlags flags = new FlagParser().parse("get-size", "full", "--apks=" + apksArchiveFile);
Throwable exception = assertThrows(InvalidCommandException.class, () -> GetSizeCommand.fromFlags(flags));
assertThat(exception).hasMessageThat().contains("Unrecognized get-size command target:");
assertThat(exception).hasMessageThat().contains("full");
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class GetSizeCommandTest method builderAndFlagsConstruction_optionalHumanReadableSizes.
@Test
public void builderAndFlagsConstruction_optionalHumanReadableSizes() throws Exception {
BuildApksResult tableOfContentsProto = BuildApksResult.getDefaultInstance();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
GetSizeCommand fromFlags = GetSizeCommand.fromFlags(new FlagParser().parse("get-size", "total", "--apks=" + apksArchiveFile, // Optional values.
"--human-readable-sizes"));
GetSizeCommand fromBuilderApi = GetSizeCommand.builder().setApksArchivePath(apksArchiveFile).setHumanReadableSizes(true).setGetSizeSubCommand(GetSizeSubcommand.TOTAL).build();
assertThat(fromFlags).isEqualTo(fromBuilderApi);
}
Aggregations