Search in sources :

Example 96 with FlagParser

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);
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) BuildApksResult(com.android.bundle.Commands.BuildApksResult) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 97 with FlagParser

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);
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) BuildApksResult(com.android.bundle.Commands.BuildApksResult) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 98 with FlagParser

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);
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) BuildApksResult(com.android.bundle.Commands.BuildApksResult) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 99 with FlagParser

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);
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) BuildApksResult(com.android.bundle.Commands.BuildApksResult) Reader(java.io.Reader) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test) Theory(org.junit.experimental.theories.Theory)

Example 100 with FlagParser

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);
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) BuildApksResult(com.android.bundle.Commands.BuildApksResult) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Aggregations

FlagParser (com.android.tools.build.bundletool.flags.FlagParser)138 Test (org.junit.Test)137 Path (java.nio.file.Path)63 ZipPath (com.android.tools.build.bundletool.model.ZipPath)55 ByteArrayOutputStream (java.io.ByteArrayOutputStream)29 PrintStream (java.io.PrintStream)29 BuildApksResult (com.android.bundle.Commands.BuildApksResult)22 InvalidCommandException (com.android.tools.build.bundletool.model.exceptions.InvalidCommandException)20 DeviceSpec (com.android.bundle.Devices.DeviceSpec)13 ParsedFlags (com.android.tools.build.bundletool.flags.ParsedFlags)12 ApksigSigningConfiguration (com.android.tools.build.bundletool.model.ApksigSigningConfiguration)10 SigningConfiguration (com.android.tools.build.bundletool.model.SigningConfiguration)10 FlagParseException (com.android.tools.build.bundletool.flags.FlagParser.FlagParseException)8 CommandExecutionException (com.android.tools.build.bundletool.model.exceptions.CommandExecutionException)8 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)8 TestUtils.expectMissingRequiredBuilderPropertyException (com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredBuilderPropertyException)8 TestUtils.expectMissingRequiredFlagException (com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredFlagException)8 IOException (java.io.IOException)8 JoseException (org.jose4j.lang.JoseException)7 FakeSystemEnvironmentProvider (com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider)6