use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class ExtractApksCommandTest method emptyModules_throws.
@Test
public void emptyModules_throws() throws Exception {
Path apksArchiveFile = createApksArchiveFile(minimalApkSet(), tmpDir.resolve("bundle.apks"));
Path deviceSpecFile = createDeviceSpecFile(deviceWithSdk(21), tmpDir.resolve("device.json"));
ExtractApksCommand command = ExtractApksCommand.fromFlags(new FlagParser().parse("--device-spec=" + deviceSpecFile, "--apks=" + apksArchiveFile, "--modules="));
Throwable exception = assertThrows(InvalidCommandException.class, command::execute);
assertThat(exception).hasMessageThat().contains("The set of modules cannot be empty.");
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class ExtractApksCommandTest method nonExistentModule_throws.
@Test
public void nonExistentModule_throws() throws Exception {
ZipPath apkLBase = ZipPath.create("apkL-base.apk");
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(createVariant(VariantTargeting.getDefaultInstance(), createSplitApkSet("base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), apkLBase)))).build();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
Path deviceSpecFile = createDeviceSpecFile(deviceWithSdk(21), tmpDir.resolve("device.json"));
ExtractApksCommand command = ExtractApksCommand.fromFlags(new FlagParser().parse("--device-spec=" + deviceSpecFile, "--apks=" + apksArchiveFile, "--modules=unknown_module"));
Throwable exception = assertThrows(InvalidCommandException.class, command::execute);
assertThat(exception).hasMessageThat().contains("The APK Set archive does not contain the following modules: [unknown_module]");
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class VersionCommandTest method executePrintsVersion.
@Test
public void executePrintsVersion() {
ByteArrayOutputStream out = new ByteArrayOutputStream();
VersionCommand.fromFlags(new FlagParser().parse(), new PrintStream(out)).execute();
assertThat(asLines(out.toString())).containsExactly(BundleToolVersion.getCurrentVersion().toString(), "").inOrder();
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class CheckTransparencyCommandTest method buildingCommandViaFlags_apkMode_apkZipPathNotSet.
@Test
public void buildingCommandViaFlags_apkMode_apkZipPathNotSet() {
Throwable e = assertThrows(RequiredFlagNotSetException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse("--mode=APK"), systemEnvironmentProvider, fakeAdbServer));
assertThat(e).hasMessageThat().contains("Missing the required --apk-zip flag");
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class CheckTransparencyCommandTest method buildingCommandViaFlags_bundleMode_withTransparencyCertificateFlag_invalidFormat.
@Test
public void buildingCommandViaFlags_bundleMode_withTransparencyCertificateFlag_invalidFormat() {
Throwable e = assertThrows(InvalidCommandException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse("--mode=BUNDLE", "--bundle=" + bundlePath, "--transparency-key-certificate=" + apkZipPath), systemEnvironmentProvider, fakeAdbServer));
assertThat(e).hasMessageThat().contains("Unable to read public key certificate from the provided path.");
}
Aggregations