use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.
the class AddTransparencyCommandTest method execute_defaultMode_dexMergingChoiceReject_fail.
@Test
public void execute_defaultMode_dexMergingChoiceReject_fail() throws Exception {
createBundle(bundlePath, /* hasSharedUserId= */
false, /* minSdkVersion= */
19);
AddTransparencyCommand addTransparencyCommand = AddTransparencyCommand.builder().setMode(Mode.DEFAULT).setDexMergingChoice(DexMergingChoice.REJECT).setBundlePath(bundlePath).setOutputPath(outputBundlePath).setSignerConfig(signerConfig).build();
InvalidCommandException exception = assertThrows(InvalidCommandException.class, addTransparencyCommand::execute);
assertThat(exception).hasMessageThat().contains("'add-transparency' command is rejected");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.
the class BuildApksCommandTest method optimizationDimensionsWithUniversal_throws.
@Test
public void optimizationDimensionsWithUniversal_throws() throws Exception {
InvalidCommandException builderException = assertThrows(InvalidCommandException.class, () -> BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setAapt2Command(aapt2Command).setApkBuildMode(UNIVERSAL).setOptimizationDimensions(ImmutableSet.of(ABI)).build());
assertThat(builderException).hasMessageThat().contains("Optimization dimension can be only set when running with 'default' mode flag.");
InvalidCommandException flagsException = assertThrows(InvalidCommandException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--optimize-for=abi", "--mode=UNIVERSAL"), fakeAdbServer));
assertThat(flagsException).hasMessageThat().contains("Optimization dimension can be only set when running with 'default' mode flag.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.
the class InstallMultiApksCommandTest method execute_timeout_androidQ_throws.
@Test
public void execute_timeout_androidQ_throws() throws Exception {
// GIVEN a fake .apks file with an .apex file.
BuildApksResult toc = fakeTableOfContents(PKG_NAME_1);
Path apksPath = createApksArchiveFile(toc, tmpDir.resolve("package1.apks"));
// GIVEN an install command with the --staged flag...
InstallMultiApksCommand command = InstallMultiApksCommand.builder().setAdbServer(fakeServerOneDevice(device)).setDeviceId(DEVICE_ID).setAdbPath(adbPath).setTimeout(Duration.ofSeconds(20)).setApksArchivePaths(ImmutableList.of(apksPath)).setAapt2Command(createFakeAapt2Command(ImmutableMap.of(PKG_NAME_1, 1L))).setAdbCommand(// EXPECT the --staged flag to be included.
createFakeAdbCommand(expectedInstallApks(PKG_NAME_1, toc), /* expectedStaged= */
false, /* expectedEnableRollback= */
false, /* expectedTimeout= */
Optional.of(Duration.ofSeconds(20)), Optional.of(DEVICE_ID))).build();
givenEmptyListPackages(device);
InvalidCommandException exception = assertThrows(InvalidCommandException.class, command::execute);
assertThat(exception).hasMessageThat().isEqualTo("'timeout-millis' flag is supported for Android 12+ devices.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.
the class DumpCommandTest method dumpResources_moduleSet_throws.
@Test
public void dumpResources_moduleSet_throws() throws Exception {
createBundle(bundlePath);
DumpCommand dumpCommand = DumpCommand.builder().setBundlePath(bundlePath).setDumpTarget(DumpTarget.RESOURCES).setModuleName("base").build();
InvalidCommandException exception = assertThrows(InvalidCommandException.class, dumpCommand::execute);
assertThat(exception).hasMessageThat().contains("The module is unnecessary");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.
the class DumpCommandTest method dumpResources_withXPath_throws.
@Test
public void dumpResources_withXPath_throws() throws Exception {
createBundle(bundlePath);
DumpCommand dumpCommand = DumpCommand.builder().setBundlePath(bundlePath).setDumpTarget(DumpTarget.RESOURCES).setXPathExpression("/manifest/@nothing-that-exists").build();
InvalidCommandException exception = assertThrows(InvalidCommandException.class, dumpCommand::execute);
assertThat(exception).hasMessageThat().contains("Cannot pass an XPath expression when dumping resources.");
}
Aggregations