use of com.facebook.buck.step.TargetDeviceOptions in project buck by facebook.
the class AdbHelperTest method testNonQuietShowsOutput.
@Test
public void testNonQuietShowsOutput() throws InterruptedException {
final File apk = new File("/some/file.apk");
final AtomicReference<String> apkPath = new AtomicReference<>();
TestDevice device = new TestDevice() {
@Override
public void installPackage(String s, boolean b, String... strings) throws InstallException {
apkPath.set(s);
}
};
device.setSerialNumber("serial#1");
device.setName("testDevice");
final List<IDevice> deviceList = Lists.newArrayList((IDevice) device);
TestConsole console = new TestConsole();
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
AdbHelper adbHelper = new AdbHelper(new AdbOptions(), new TargetDeviceOptions(), TestExecutionContext.newInstance(), console, eventBus, true) {
@Override
protected boolean isDeviceTempWritable(IDevice device, String name) {
return true;
}
@Override
public List<IDevice> getDevices(boolean quiet) {
return deviceList;
}
};
boolean success = adbHelper.adbCall(new AdbHelper.AdbCallable() {
@Override
public boolean call(IDevice device) throws Exception {
return basicAdbHelper.installApkOnDevice(device, apk, false, false);
}
@Override
public String toString() {
return "install apk";
}
}, false);
assertTrue(success);
assertEquals(apk.getAbsolutePath(), apkPath.get());
assertEquals("", console.getTextWrittenToStdOut());
assertEquals("Successfully ran install apk on 1 device(s)\n", console.getTextWrittenToStdErr());
}
use of com.facebook.buck.step.TargetDeviceOptions in project buck by facebook.
the class InstallCommandOptionsTest method testInstallCommandOptionsSerial.
@Test
public void testInstallCommandOptionsSerial() throws CmdLineException {
String serial = "some-random-serial-number";
// Short form.
TargetDeviceOptions options = getTargetDeviceOptions(TargetDeviceCommandLineOptions.SERIAL_NUMBER_SHORT_ARG, serial);
assertTrue(options.getSerialNumber().isPresent());
assertEquals(serial, options.getSerialNumber().get());
// Long form.
options = getTargetDeviceOptions(TargetDeviceCommandLineOptions.SERIAL_NUMBER_LONG_ARG, serial);
assertTrue(options.getSerialNumber().isPresent());
assertEquals(serial, options.getSerialNumber().get());
// Is off by default.
options = getTargetDeviceOptions();
assertFalse(options.getSerialNumber().isPresent());
}
use of com.facebook.buck.step.TargetDeviceOptions in project buck by facebook.
the class InstallCommandOptionsTest method testInstallCommandOptionsDeviceMode.
@Test
public void testInstallCommandOptionsDeviceMode() throws CmdLineException {
// Short form.
TargetDeviceOptions options = getTargetDeviceOptions(TargetDeviceCommandLineOptions.DEVICE_MODE_SHORT_ARG);
assertTrue(options.isRealDevicesOnlyModeEnabled());
// Long form.
options = getTargetDeviceOptions(TargetDeviceCommandLineOptions.DEVICE_MODE_LONG_ARG);
assertTrue(options.isRealDevicesOnlyModeEnabled());
// Is off by default.
options = getTargetDeviceOptions();
assertFalse(options.isRealDevicesOnlyModeEnabled());
}
use of com.facebook.buck.step.TargetDeviceOptions in project buck by facebook.
the class InstallCommandOptionsTest method testInstallCommandOptionsEmulatorMode.
@Test
public void testInstallCommandOptionsEmulatorMode() throws CmdLineException {
// Short form.
TargetDeviceOptions options = getTargetDeviceOptions(TargetDeviceCommandLineOptions.EMULATOR_MODE_SHORT_ARG);
assertTrue(options.isEmulatorsOnlyModeEnabled());
// Long form.
options = getTargetDeviceOptions(TargetDeviceCommandLineOptions.EMULATOR_MODE_LONG_ARG);
assertTrue(options.isEmulatorsOnlyModeEnabled());
// Is off by default.
options = getTargetDeviceOptions();
assertFalse(options.isEmulatorsOnlyModeEnabled());
}
Aggregations