use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class GetSizeCommandTest method deviceSpecAll_hasAllDimensions.
@Test
public void deviceSpecAll_hasAllDimensions() throws Exception {
BuildApksResult tableOfContentsProto = BuildApksResult.getDefaultInstance();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
GetSizeCommand command = GetSizeCommand.fromFlags(new FlagParser().parse("get-size", "total", "--apks=" + apksArchiveFile, "--dimensions=" + "ALL"));
assertThat(command.getDimensions()).isSameInstanceAs(SUPPORTED_DIMENSIONS);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class GetSizeCommandTest method builderAndFlagsConstruction_optionalDeviceSpec_inJavaViaApi_equivalent.
@Test
public void builderAndFlagsConstruction_optionalDeviceSpec_inJavaViaApi_equivalent() throws Exception {
DeviceSpec deviceSpec = deviceWithSdk(21);
Path deviceSpecFile = createDeviceSpecFile(deviceSpec, tmpDir.resolve("device.json"));
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.
"--device-spec=" + deviceSpecFile));
GetSizeCommand fromBuilderApi = GetSizeCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).setGetSizeSubCommand(GetSizeSubcommand.TOTAL).build();
assertThat(fromFlags).isEqualTo(fromBuilderApi);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class GetSizeCommandTest method builderAndFlagsConstruction_optionalDimensions_equivalent.
@Test
public void builderAndFlagsConstruction_optionalDimensions_equivalent() 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, "--dimensions=" + "ABI,SCREEN_DENSITY"));
GetSizeCommand fromBuilderApi = GetSizeCommand.builder().setApksArchivePath(apksArchiveFile).setDimensions(ImmutableSet.of(Dimension.ABI, Dimension.SCREEN_DENSITY)).setGetSizeSubCommand(GetSizeSubcommand.TOTAL).build();
assertThat(fromFlags).isEqualTo(fromBuilderApi);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class GetSizeCommandTest method checkFlagsConstructionWithDeviceSpec.
@Test
@Theory
public void checkFlagsConstructionWithDeviceSpec(@FromDataPoints("deviceSpecs") String deviceSpecPath) throws Exception {
DeviceSpec.Builder expectedDeviceSpecBuilder = DeviceSpec.newBuilder();
try (Reader reader = TestData.openReader(deviceSpecPath)) {
JsonFormat.parser().merge(reader, expectedDeviceSpecBuilder);
}
DeviceSpec expectedDeviceSpec = expectedDeviceSpecBuilder.build();
BuildApksResult tableOfContentsProto = BuildApksResult.getDefaultInstance();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
Path deviceSpecFile = copyToTempDir(deviceSpecPath);
GetSizeCommand command = GetSizeCommand.fromFlags(new FlagParser().parse("get-size", "total", "--device-spec=" + deviceSpecFile, "--apks=" + apksArchiveFile));
assertThat(command.getDeviceSpec()).isEqualTo(expectedDeviceSpec);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class GetSizeCommandTest method builderAndFlagsConstruction_optionalInstant_equivalent.
@Test
public void builderAndFlagsConstruction_optionalInstant_equivalent() 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.
"--instant"));
GetSizeCommand fromBuilderApi = GetSizeCommand.builder().setApksArchivePath(apksArchiveFile).setInstant(true).setGetSizeSubCommand(GetSizeSubcommand.TOTAL).build();
assertThat(fromFlags).isEqualTo(fromBuilderApi);
}
Aggregations