use of com.android.ddmlib.InstallException 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());
}
Aggregations