Search in sources :

Example 31 with FakeAdbServer

use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.

the class DeviceAnalyzerTest method extractsGlExtensions.

@Test
public void extractsGlExtensions() {
    FakeDevice fakeDevice = FakeDevice.fromDeviceSpec("id1", DeviceState.ONLINE, mergeSpecs(density(240), locales("en-US"), abis("x86"), sdkVersion(21), glExtensions("GL_EXT_extension1", "GL_EXT_extension2")));
    FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
    true, /* devices= */
    ImmutableList.of(fakeDevice));
    fakeAdbServer.init(Paths.get("path/to/adb"));
    DeviceAnalyzer analyzer = new DeviceAnalyzer(fakeAdbServer);
    DeviceSpec deviceSpec = analyzer.getDeviceSpec(Optional.empty());
    assertThat(deviceSpec.getGlExtensionsList()).containsExactly("GL_EXT_extension1", "GL_EXT_extension2");
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) FakeDevice(com.android.tools.build.bundletool.testing.FakeDevice) FakeAdbServer(com.android.tools.build.bundletool.testing.FakeAdbServer) Test(org.junit.Test)

Example 32 with FakeAdbServer

use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.

the class DeviceAnalyzerTest method deviceId_noConnectedDevices_throws.

@Test
public void deviceId_noConnectedDevices_throws() {
    FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
    true, /* devices= */
    ImmutableList.of());
    fakeAdbServer.init(Paths.get("path/to/adb"));
    DeviceAnalyzer analyzer = new DeviceAnalyzer(fakeAdbServer);
    Throwable exception = assertThrows(CommandExecutionException.class, () -> analyzer.getDeviceSpec(Optional.of("a")));
    assertThat(exception).hasMessageThat().contains("No connected devices found");
}
Also used : FakeAdbServer(com.android.tools.build.bundletool.testing.FakeAdbServer) Test(org.junit.Test)

Example 33 with FakeAdbServer

use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.

the class DeviceAnalyzerTest method noDeviceId_oneConnectedDevice_sdk21_fine.

@Test
public void noDeviceId_oneConnectedDevice_sdk21_fine() {
    FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
    true, /* devices= */
    ImmutableList.of(createUsbEnabledDevice("a", /* sdkVersion= */
    21, "fr-CA")));
    fakeAdbServer.init(Paths.get("path/to/adb"));
    DeviceSpec spec = new DeviceAnalyzer(fakeAdbServer).getDeviceSpec(Optional.empty());
    assertThat(spec.getScreenDensity()).isEqualTo(480);
    assertThat(spec.getSupportedAbisList()).containsExactly("armeabi");
    assertThat(spec.getSdkVersion()).isEqualTo(21);
    assertThat(spec.getSupportedLocalesList()).containsExactly("fr-CA");
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) FakeAdbServer(com.android.tools.build.bundletool.testing.FakeAdbServer) Test(org.junit.Test)

Example 34 with FakeAdbServer

use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.

the class DeviceAnalyzerTest method noDeviceId_oneConnectedDevice_sdk19_fallBack.

@Test
public void noDeviceId_oneConnectedDevice_sdk19_fallBack() {
    FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
    true, /* devices= */
    ImmutableList.of(createDeviceWithNoProperties("a", /* sdkVersion= */
    19, /* locale= */
    "de-DE")));
    fakeAdbServer.init(Paths.get("path/to/adb"));
    DeviceSpec spec = new DeviceAnalyzer(fakeAdbServer).getDeviceSpec(Optional.empty());
    assertThat(spec.getScreenDensity()).isEqualTo(480);
    assertThat(spec.getSupportedAbisList()).containsExactly("armeabi");
    assertThat(spec.getSdkVersion()).isEqualTo(19);
    // We couldn't detect locale so we expect to fallback to en-US.
    assertThat(spec.getSupportedLocalesList()).containsExactly("en-US");
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) FakeAdbServer(com.android.tools.build.bundletool.testing.FakeAdbServer) Test(org.junit.Test)

Example 35 with FakeAdbServer

use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.

the class DeviceAnalyzerTest method noDeviceId_noConnectedDevices_throws.

@Test
public void noDeviceId_noConnectedDevices_throws() {
    FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
    true, /* devices= */
    ImmutableList.of());
    fakeAdbServer.init(Paths.get("path/to/adb"));
    DeviceAnalyzer analyzer = new DeviceAnalyzer(fakeAdbServer);
    Throwable exception = assertThrows(CommandExecutionException.class, () -> analyzer.getDeviceSpec(Optional.empty()));
    assertThat(exception).hasMessageThat().contains("No connected devices found");
}
Also used : FakeAdbServer(com.android.tools.build.bundletool.testing.FakeAdbServer) Test(org.junit.Test)

Aggregations

FakeAdbServer (com.android.tools.build.bundletool.testing.FakeAdbServer)57 Test (org.junit.Test)57 FakeDevice (com.android.tools.build.bundletool.testing.FakeDevice)30 Path (java.nio.file.Path)27 AdbServer (com.android.tools.build.bundletool.device.AdbServer)23 BuildApksResult (com.android.bundle.Commands.BuildApksResult)19 ZipPath (com.android.tools.build.bundletool.model.ZipPath)16 DeviceSpec (com.android.bundle.Devices.DeviceSpec)14 ArrayList (java.util.ArrayList)10 Theory (org.junit.experimental.theories.Theory)9 ApkSet (com.android.bundle.Commands.ApkSet)7 Variant (com.android.bundle.Commands.Variant)7 DeviceState (com.android.ddmlib.IDevice.DeviceState)7 CommandExecutionException (com.android.tools.build.bundletool.model.exceptions.CommandExecutionException)7 ImmutableList (com.google.common.collect.ImmutableList)7 Truth.assertThat (com.google.common.truth.Truth.assertThat)7 Files (java.nio.file.Files)7 ZipFile (java.util.zip.ZipFile)7 Before (org.junit.Before)7 Rule (org.junit.Rule)7