use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class ExtractApksCommandTest method builderAndFlagsConstruction_optionalInstant_equivalent.
@Test
public void builderAndFlagsConstruction_optionalInstant_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.
"--instant"));
ExtractApksCommand fromBuilderApi = ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).setInstant(true).build();
assertThat(fromFlags).isEqualTo(fromBuilderApi);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class ExtractApksCommandTest method deviceSpecUnknownExtension_throws.
@Test
public void deviceSpecUnknownExtension_throws() throws Exception {
DeviceSpec deviceSpec = deviceWithSdk(21);
Path deviceSpecFile = createDeviceSpecFile(deviceSpec, tmpDir.resolve("bad_filename.dat"));
BuildApksResult tableOfContentsProto = minimalApkSet();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
Throwable exception = assertThrows(InvalidDeviceSpecException.class, () -> ExtractApksCommand.fromFlags(new FlagParser().parse("--device-spec=" + deviceSpecFile, "--apks=" + apksArchiveFile)));
assertThat(exception).hasMessageThat().contains("Expected .json extension for the device spec");
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class ExtractApksCommandTest method builderAndFlagsConstruction_optionalModules_equivalent.
@Test
public void builderAndFlagsConstruction_optionalModules_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.
"--modules=base"));
ExtractApksCommand fromBuilderApi = ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).setModules(ImmutableSet.of("base")).build();
assertThat(fromFlags).isEqualTo(fromBuilderApi);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class ExtractApksCommandTest method missingDeviceSpecFlag_throws.
@Test
public void missingDeviceSpecFlag_throws() throws Exception {
Path apksArchiveFile = createApksArchiveFile(minimalApkSet(), tmpDir.resolve("bundle.apks"));
expectMissingRequiredFlagException("device-spec", () -> ExtractApksCommand.fromFlags(new FlagParser().parse("--apks=" + apksArchiveFile)));
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class ExtractApksCommandTest method nonExistentApksArchiveFile_throws.
@Test
public void nonExistentApksArchiveFile_throws() throws Exception {
Path deviceSpecFile = createDeviceSpecFile(deviceWithSdk(21), tmpDir.resolve("device.json"));
Throwable exception = assertThrows(IllegalArgumentException.class, () -> ExtractApksCommand.fromFlags(new FlagParser().parse("--device-spec=" + deviceSpecFile, "--apks=nonexistent")).execute());
assertThat(exception).hasMessageThat().contains("File 'nonexistent' was not found");
}
Aggregations