Search in sources :

Example 26 with FlagParser

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

the class InstallApksCommandTest method missingApksFlag_fails.

@Test
public void missingApksFlag_fails() {
    expectMissingRequiredBuilderPropertyException("apksArchivePath", () -> InstallApksCommand.builder().setAdbPath(adbPath).setAdbServer(fakeServerOneDevice(lDeviceWithLocales("en-US"))).build());
    expectMissingRequiredFlagException("apks", () -> InstallApksCommand.fromFlags(new FlagParser().parse("--adb=" + adbPath), systemEnvironmentProvider, fakeServerOneDevice(lDeviceWithLocales("en-US"))));
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 27 with FlagParser

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

the class InstallMultiApksCommandTest method fromFlags_matchBuilder_apksZip.

@Test
public void fromFlags_matchBuilder_apksZip() {
    Path zipFile = tmpDir.resolve("container.zip");
    InstallMultiApksCommand fromFlags = InstallMultiApksCommand.fromFlags(new FlagParser().parse("--apks-zip=" + zipFile), systemEnvironmentProvider, fakeServerOneDevice(qDeviceWithLocales("en-US")));
    InstallMultiApksCommand fromBuilder = InstallMultiApksCommand.builder().setAdbPath(adbPath).setAdbServer(fromFlags.getAdbServer()).setApksArchiveZipPath(zipFile).setDeviceId(DEVICE_ID).build();
    assertThat(fromBuilder).isEqualTo(fromFlags);
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 28 with FlagParser

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

the class InstallMultiApksCommandTest method fromFlags_missingApksOption.

@Test
public void fromFlags_missingApksOption() {
    InvalidCommandException e = assertThrows(InvalidCommandException.class, () -> InstallMultiApksCommand.fromFlags(new FlagParser().parse(), systemEnvironmentProvider, fakeServerOneDevice(qDeviceWithLocales("en-US"))));
    assertThat(e).hasMessageThat().contains("Exactly one of");
}
Also used : InvalidCommandException(com.android.tools.build.bundletool.model.exceptions.InvalidCommandException) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 29 with FlagParser

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

the class InstallMultiApksCommandTest method fromFlags_staged.

@Test
public void fromFlags_staged() {
    Path zipFile = tmpDir.resolve("container.zip");
    InstallMultiApksCommand fromFlags = InstallMultiApksCommand.fromFlags(new FlagParser().parse("--staged", "--apks-zip=" + zipFile), systemEnvironmentProvider, fakeServerOneDevice(qDeviceWithLocales("en-US")));
    assertThat(fromFlags.getStaged()).isTrue();
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 30 with FlagParser

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

the class InstallMultiApksCommandTest method execute_badAdbPath.

@Test
public void execute_badAdbPath() {
    Path zipFile = tmpDir.resolve("container.zip");
    InstallMultiApksCommand fromFlags = InstallMultiApksCommand.fromFlags(new FlagParser().parse("--adb=foo", "--apks-zip=" + zipFile), systemEnvironmentProvider, fakeServerOneDevice(qDeviceWithLocales("en-US")));
    IllegalArgumentException e = assertThrows(IllegalArgumentException.class, fromFlags::execute);
    assertThat(e).hasMessageThat().contains("was not found");
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) 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