use of com.facebook.buck.step.AdbOptions in project buck by facebook.
the class AdbHelperTest method testDeviceFilterRealDevices.
/**
* Verify that when real-device-only mode is enabled only real devices appear in result.
*/
@Test
public void testDeviceFilterRealDevices() throws CmdLineException {
AdbHelper myAdbHelper = createAdbHelper(new AdbOptions(), new TargetDeviceOptions(false, true, Optional.empty()));
IDevice[] devices = new IDevice[] { createRealDevice("1", IDevice.DeviceState.ONLINE), createEmulator("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.AdbOptions 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.AdbOptions in project buck by facebook.
the class InstallCommandOptionsTest method testInstallCommandOptionsMultiInstallMode.
@Test
public void testInstallCommandOptionsMultiInstallMode() throws CmdLineException, IOException {
// Short form.
AdbOptions options = getAdbOptions(false, AdbCommandLineOptions.MULTI_INSTALL_MODE_SHORT_ARG);
assertTrue(options.isMultiInstallModeEnabled());
// Long form.
options = getAdbOptions(false, AdbCommandLineOptions.MULTI_INSTALL_MODE_LONG_ARG);
assertTrue(options.isMultiInstallModeEnabled());
// Is off by default.
options = getAdbOptions(false);
assertFalse(options.isMultiInstallModeEnabled());
}
use of com.facebook.buck.step.AdbOptions in project buck by facebook.
the class InstallCommandOptionsTest method testInstallCommandOptionsAdbThreads.
@Test
public void testInstallCommandOptionsAdbThreads() throws CmdLineException, IOException {
// Short form.
AdbOptions options = getAdbOptions(false, AdbCommandLineOptions.ADB_THREADS_SHORT_ARG, "4");
assertEquals(4, options.getAdbThreadCount());
// Long form.
options = getAdbOptions(false, AdbCommandLineOptions.ADB_THREADS_LONG_ARG, "4");
assertEquals(4, options.getAdbThreadCount());
// Is zero by default and overridden when creating the thread pool.
options = getAdbOptions(false);
assertEquals(0, options.getAdbThreadCount());
}
Aggregations