Search in sources :

Example 1 with FlagParser

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

the class BuildApksDeviceSpecTest method deviceSpecFlags_inJavaViaProtos_equivalent.

@Test
public void deviceSpecFlags_inJavaViaProtos_equivalent() throws Exception {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    DeviceSpec deviceSpec = deviceWithSdk(28);
    Path deviceSpecPath = createDeviceSpecFile(deviceSpec, tmpDir.resolve("device.json"));
    BuildApksCommand commandViaFlags = BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--device-spec=" + deviceSpecPath), new PrintStream(output), systemEnvironmentProvider, fakeAdbServer);
    BuildApksCommand.Builder commandViaBuilder = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpec).setExecutorServiceInternal(commandViaFlags.getExecutorService()).setExecutorServiceCreatedByBundleTool(true).setOutputPrintStream(commandViaFlags.getOutputPrintStream().get());
    DebugKeystoreUtils.getDebugSigningConfiguration(systemEnvironmentProvider).ifPresent(commandViaBuilder::setSigningConfiguration);
    assertThat(commandViaBuilder.build()).isEqualTo(commandViaFlags);
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) Path(java.nio.file.Path) PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 2 with FlagParser

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

the class BuildApksDeviceSpecTest method deviceSpecFlags_inJavaViaFiles_equivalent.

@Test
public void deviceSpecFlags_inJavaViaFiles_equivalent() throws Exception {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    DeviceSpec deviceSpec = deviceWithSdk(28);
    Path deviceSpecPath = createDeviceSpecFile(deviceSpec, tmpDir.resolve("device.json"));
    BuildApksCommand commandViaFlags = BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--device-spec=" + deviceSpecPath), new PrintStream(output), systemEnvironmentProvider, fakeAdbServer);
    BuildApksCommand.Builder commandViaBuilder = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpecPath).setExecutorServiceInternal(commandViaFlags.getExecutorService()).setExecutorServiceCreatedByBundleTool(true).setOutputPrintStream(commandViaFlags.getOutputPrintStream().get());
    DebugKeystoreUtils.getDebugSigningConfiguration(systemEnvironmentProvider).ifPresent(commandViaBuilder::setSigningConfiguration);
    assertThat(commandViaBuilder.build()).isEqualTo(commandViaFlags);
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) Path(java.nio.file.Path) PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 3 with FlagParser

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

the class AddTransparencyCommandTest method buildingCommandViaFlags_injectSignatureMode_missingRequiredFlag.

@Test
public void buildingCommandViaFlags_injectSignatureMode_missingRequiredFlag() {
    Throwable e = assertThrows(RequiredFlagNotSetException.class, () -> AddTransparencyCommand.fromFlags(new FlagParser().parse("--mode=inject_signature", "--bundle=" + bundlePath, "--output=" + outputBundlePath, "--transparency-key-certificate=" + transparencyKeyCertificatePath)));
    assertThat(e).hasMessageThat().contains("Missing the required --transparency-signature flag");
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 4 with FlagParser

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

the class AddTransparencyCommandTest method buildingCommandViaFlags_defaultMode_outputPathNotSet.

@Test
public void buildingCommandViaFlags_defaultMode_outputPathNotSet() {
    Throwable e = assertThrows(RequiredFlagNotSetException.class, () -> AddTransparencyCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--ks=" + keystorePath, "--ks-key-alias=" + KEY_ALIAS, "--ks-pass=pass:" + KEYSTORE_PASSWORD, "--key-pass=pass:" + KEY_PASSWORD)));
    assertThat(e).hasMessageThat().contains("Missing the required --output flag");
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 5 with FlagParser

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

the class AddTransparencyCommandTest method buildingCommandViaFlags_generateCodeTransparencyFileMode_missingRequiredFlag.

@Test
public void buildingCommandViaFlags_generateCodeTransparencyFileMode_missingRequiredFlag() {
    Throwable e = assertThrows(RequiredFlagNotSetException.class, () -> AddTransparencyCommand.fromFlags(new FlagParser().parse("--mode=generate_code_transparency_file", "--bundle=" + bundlePath, "--output=" + outputUnsignedTransparencyFilePath)));
    assertThat(e).hasMessageThat().contains("Missing the required --transparency-key-certificate flag");
}
Also used : 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