use of com.facebook.buck.step.TargetDeviceOptions in project buck by facebook.
the class AdbHelperTest method testDeviceFilterEmulator.
/**
* Verify that when emulator-only mode is enabled only emulators appear in result.
*/
@Test
public void testDeviceFilterEmulator() throws CmdLineException {
AdbHelper myAdbHelper = createAdbHelper(new AdbOptions(), new TargetDeviceOptions(true, false, Optional.empty()));
IDevice[] devices = new IDevice[] { createEmulator("1", IDevice.DeviceState.ONLINE), createRealDevice("2", IDevice.DeviceState.ONLINE) };
List<IDevice> filteredDevices = myAdbHelper.filterDevices(devices);
assertNotNull(filteredDevices);
assertEquals(1, filteredDevices.size());
assertSame(devices[0], filteredDevices.get(0));
}
use of com.facebook.buck.step.TargetDeviceOptions in project buck by facebook.
the class AdbHelperTest method whenSerialNumberSetInEnvironmentThenCorrectDeviceFound.
/**
* Verify that filtering by environment variable works.
*/
@Test
public void whenSerialNumberSetInEnvironmentThenCorrectDeviceFound() throws CmdLineException {
IDevice[] devices = new IDevice[] { createRealDevice("1", IDevice.DeviceState.ONLINE), createEmulator("2", IDevice.DeviceState.ONLINE), createRealDevice("3", IDevice.DeviceState.ONLINE), createEmulator("4", IDevice.DeviceState.ONLINE) };
for (int i = 0; i < devices.length; i++) {
AdbHelper myAdbHelper = createAdbHelper(TestExecutionContext.newBuilder().setEnvironment(ImmutableMap.of(AdbHelper.SERIAL_NUMBER_ENV, devices[i].getSerialNumber())).build(), new AdbOptions(), new TargetDeviceOptions());
List<IDevice> filteredDevices = myAdbHelper.filterDevices(devices);
assertNotNull(filteredDevices);
assertEquals(1, filteredDevices.size());
assertSame(devices[i], filteredDevices.get(0));
}
}
use of com.facebook.buck.step.TargetDeviceOptions in project buck by facebook.
the class AdbHelperTest method testDeviceFilterBySerial.
/**
* Verify that filtering by serial number works.
*/
@Test
public void testDeviceFilterBySerial() throws CmdLineException {
IDevice[] devices = new IDevice[] { createRealDevice("1", IDevice.DeviceState.ONLINE), createEmulator("2", IDevice.DeviceState.ONLINE), createRealDevice("3", IDevice.DeviceState.ONLINE), createEmulator("4", IDevice.DeviceState.ONLINE) };
for (int i = 0; i < devices.length; i++) {
AdbHelper myAdbHelper = createAdbHelper(new AdbOptions(), new TargetDeviceOptions(false, false, Optional.of(devices[i].getSerialNumber())));
List<IDevice> filteredDevices = myAdbHelper.filterDevices(devices);
assertNotNull(filteredDevices);
assertEquals(1, filteredDevices.size());
assertSame(devices[i], filteredDevices.get(0));
}
}
use of com.facebook.buck.step.TargetDeviceOptions in project buck by facebook.
the class AdbHelperTest method testGenymotionIsntARealDevice.
@Test
public void testGenymotionIsntARealDevice() throws Throwable {
AdbHelper adbHelper = createAdbHelper(new AdbOptions(), new TargetDeviceOptions(false, true, Optional.empty()));
IDevice[] devices = new IDevice[] { TestDevice.createRealDevice("foobar"), TestDevice.createRealDevice("192.168.57.101:5555") };
List<IDevice> filtered = adbHelper.filterDevices(devices);
assertNotNull(filtered);
assertEquals(1, filtered.size());
assertEquals("foobar", filtered.get(0).getSerialNumber());
}
use of com.facebook.buck.step.TargetDeviceOptions in project buck by facebook.
the class AdbHelperTest method testDeviceFilterNoMatchingDevices.
/**
* Verify that if no devices match filters null is returned.
*/
@Test
public void testDeviceFilterNoMatchingDevices() throws CmdLineException {
IDevice[] devices = new IDevice[] { createRealDevice("1", IDevice.DeviceState.ONLINE), createEmulator("2", IDevice.DeviceState.ONLINE), createRealDevice("3", IDevice.DeviceState.ONLINE), createEmulator("4", IDevice.DeviceState.ONLINE) };
AdbHelper myAdbHelper = createAdbHelper(new AdbOptions(), new TargetDeviceOptions(false, false, Optional.of("invalid-serial")));
List<IDevice> filteredDevices = myAdbHelper.filterDevices(devices);
assertNull(filteredDevices);
}
Aggregations