Search in sources :

Example 56 with FlagParser

use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.

the class GetDeviceSpecCommandTest method fromFlagsEquivalentToBuilder_withEnvironmentalVariables.

@Test
public void fromFlagsEquivalentToBuilder_withEnvironmentalVariables() {
    Path outputPath = tmpDir.resolve("device.json");
    GetDeviceSpecCommand commandViaFlags = GetDeviceSpecCommand.fromFlags(new FlagParser().parse("--adb=" + adbPath, "--output=" + outputPath), systemEnvironmentProvider, fakeServerOneDevice(lDeviceWithLocales("en-US")));
    GetDeviceSpecCommand commandViaBuilder = GetDeviceSpecCommand.builder().setAdbPath(adbPath).setDeviceId(DEVICE_ID).setOutputPath(outputPath).setAdbServer(commandViaFlags.getAdbServer()).build();
    assertThat(commandViaFlags).isEqualTo(commandViaBuilder);
}
Also used : Path(java.nio.file.Path) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 57 with FlagParser

use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.

the class ExtractApksCommandTest method builderAndFlagsConstruction_optionalInstantFalse_equivalent.

@Test
public void builderAndFlagsConstruction_optionalInstantFalse_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));
    ExtractApksCommand fromBuilderApi = ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).setInstant(false).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 58 with FlagParser

use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.

the class CheckTransparencyCommandTest method buildingCommandViaFlags_bundleMode_adbPathSet.

@Test
public void buildingCommandViaFlags_bundleMode_adbPathSet() {
    Throwable e = assertThrows(UnknownFlagsException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse("--mode=BUNDLE", "--bundle=" + bundlePath, "--adb=path/to/adb"), systemEnvironmentProvider, fakeAdbServer));
    assertThat(e).hasMessageThat().contains("Unrecognized flags");
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 59 with FlagParser

use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.

the class CheckTransparencyCommandTest method buildingCommandViaFlags_modeNotSet.

@Test
public void buildingCommandViaFlags_modeNotSet() {
    Throwable e = assertThrows(RequiredFlagNotSetException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse(), systemEnvironmentProvider, fakeAdbServer));
    assertThat(e).hasMessageThat().contains("Missing the required --mode flag");
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 60 with FlagParser

use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.

the class DumpCommandTest method dumpInvalidTarget.

@Test
public void dumpInvalidTarget() {
    InvalidCommandException exception = assertThrows(InvalidCommandException.class, () -> DumpCommand.fromFlags(new FlagParser().parse("dump", "blah", "--bundle=" + bundlePath)));
    assertThat(exception).hasMessageThat().matches("Unrecognized dump target: 'blah'. Accepted values are: .*");
}
Also used : InvalidCommandException(com.android.tools.build.bundletool.model.exceptions.InvalidCommandException) 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