本文整理汇总了Java中com.android.ddmlib.IShellOutputReceiver类的典型用法代码示例。如果您正苦于以下问题:Java IShellOutputReceiver类的具体用法?Java IShellOutputReceiver怎么用?Java IShellOutputReceiver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IShellOutputReceiver类属于com.android.ddmlib包,在下文中一共展示了IShellOutputReceiver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRun_ioException
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
/**
* Test run when the device throws a IOException
*/
@SuppressWarnings("unchecked")
public void testRun_ioException() throws Exception {
mMockDevice.executeShellCommand((String)EasyMock.anyObject(), (IShellOutputReceiver)
EasyMock.anyObject(), EasyMock.eq(0L), EasyMock.eq(TimeUnit.MILLISECONDS));
EasyMock.expectLastCall().andThrow(new IOException());
// verify that the listeners run started, run failure, and run ended methods are called
mMockListener.testRunStarted(TEST_PACKAGE, 0);
mMockListener.testRunFailed((String)EasyMock.anyObject());
mMockListener.testRunEnded(EasyMock.anyLong(), EasyMock.eq(Collections.EMPTY_MAP));
EasyMock.replay(mMockDevice, mMockListener);
try {
mRunner.run(mMockListener);
fail("IOException not thrown");
} catch (IOException e) {
// expected
}
EasyMock.verify(mMockDevice, mMockListener);
}
示例2: testDeviceStartActivityWaitForDebugger
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
@Test
public void testDeviceStartActivityWaitForDebugger() throws Exception {
final AtomicReference<String> runDeviceCommand = new AtomicReference<>();
TestDevice device =
new TestDevice() {
@Override
public void executeShellCommand(
String command,
IShellOutputReceiver receiver,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits) {
runDeviceCommand.set(command);
}
};
assertNull(createAndroidDevice(device).deviceStartActivity("com.foo/.Activity", true));
assertTrue(runDeviceCommand.get().contains(" -D"));
}
示例3: testDeviceStartActivityDoNotWaitForDebugger
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
@Test
public void testDeviceStartActivityDoNotWaitForDebugger() throws Exception {
final AtomicReference<String> runDeviceCommand = new AtomicReference<>();
TestDevice device =
new TestDevice() {
@Override
public void executeShellCommand(
String command,
IShellOutputReceiver receiver,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits) {
runDeviceCommand.set(command);
}
};
assertNull(createAndroidDevice(device).deviceStartActivity("com.foo/.Activity", false));
assertFalse(runDeviceCommand.get().contains(" -D"));
}
示例4: killMinicap
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
/**
* 关闭minicap
*
* @param pid
* 进程号
*/
public static void killMinicap(final String serialNumber, final int pid) {
logger.info(serialNumber + ":关闭minicap线程 " + pid);
DeviceEntity deviceEntity = DeviceContainerHandler
.getDevice(serialNumber);
if (deviceEntity != null) {
MinicapEntity minicapEntity = deviceEntity.getMinicapEntity();
IDevice idevice = deviceEntity.getIdevice();
executorService.execute(new Runnable() {
IShellOutputReceiver receiver = new NullOutputReceiver();
@Override
public void run() {
if (idevice.isOnline()) {
try {
idevice.executeShellCommand("exec kill " + pid,
receiver, 3, TimeUnit.SECONDS);
} catch (TimeoutException | AdbCommandRejectedException
| ShellCommandUnresponsiveException
| IOException e) {
logger.error("关闭minicap出错", e);
}
minicapEntity.setStatus(Status.CLOSED);
}
}
});
}
}
示例5: setDebugLayoutEnabled
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
public static void setDebugLayoutEnabled(IDevice device, boolean enabled, IShellOutputReceiver iShellOutputReceiver) {
String cmd = "setprop " + Property.DEBUG_LAYOUT_PROPERTY + " " + (enabled ? "true" : "false");
System.out.println(cmd);
executeShell(device, iShellOutputReceiver, cmd);
executeShell(device, null, "am broadcast -a red.dim.updatesystemprop -n red.dim.duang/.UpdateReceiver");
}
示例6: setShowOverdrawEnabled
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
public static void setShowOverdrawEnabled(IDevice device, boolean enabled, IShellOutputReceiver iShellOutputReceiver) {
String cmd = "setprop " + Property.getDebugOverdrawPropertyKey(getApiLevel(device)) + " "
+ (enabled ? Property.getDebugOverdrawPropertyEnabledValue(getApiLevel(device)) : "false");
System.out.println(cmd);
executeShell(device, iShellOutputReceiver, cmd);
executeShell(device, null, "am broadcast -a red.dim.updatesystemprop -n red.dim.duang/.UpdateReceiver");
}
示例7: executeShellCommand
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
@Override
public void executeShellCommand(String arg0, IShellOutputReceiver arg1)
throws TimeoutException,
AdbCommandRejectedException,
ShellCommandUnresponsiveException,
IOException {
// TODO Auto-generated method stub
}
示例8: startScreenRecorder
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
@Override
public void startScreenRecorder(String remoteFilePath,
ScreenRecorderOptions options,
IShellOutputReceiver receiver)
throws TimeoutException,
AdbCommandRejectedException,
IOException,
ShellCommandUnresponsiveException {
// TODO Auto-generated method stub
}
示例9: answer
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
String request = (String) args[0];
IShellOutputReceiver output = (IShellOutputReceiver) args[1];
switch (request) {
// device is booted check
case "getprop init.svc.bootanim":
printToOutput(output, "stopped\r\n");
break;
}
return null;
}
示例10: testRegisteringUncompatibleDevice
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
@Test
public void testRegisteringUncompatibleDevice() throws Exception {
// FIXME: This is not really an unit test
String mockDeviceSerialNumber = "UncompatibleDevice";
boolean mockDeviceEmulator = false;
String mockDeviceApiNotCompatibleApiVersion = "16";
Map<String, String> mockPropMap = new HashMap<>();
mockPropMap.put(DevicePropertyStringConstants.PROPERTY_API_LEVEL.toString(),
mockDeviceApiNotCompatibleApiVersion);
IDevice mockDevice = mock(IDevice.class);
when(mockDevice.getSerialNumber()).thenReturn(mockDeviceSerialNumber);
when(mockDevice.isEmulator()).thenReturn(mockDeviceEmulator);
when(mockDevice.arePropertiesSet()).thenReturn(true);
when(mockDevice.getProperties()).thenReturn(mockPropMap);
FakeOnDeviceComponentAnswer onDeviceAnswer = new FakeOnDeviceComponentAnswer();
FakeDeviceShellAnswer shellAnswer = new FakeDeviceShellAnswer();
Mockito.doAnswer(onDeviceAnswer).when(mockDevice).createForward(anyInt(), anyInt());
Mockito.doAnswer(shellAnswer).when(mockDevice).executeShellCommand(Matchers.anyString(),
Matchers.any(IShellOutputReceiver.class));
Mockito.doAnswer(shellAnswer).when(mockDevice).executeShellCommand(Matchers.anyString(),
Matchers.any(IShellOutputReceiver.class),
anyInt());
assertNull("Successfully registered device with API Level lower than 17.",
deviceManager.registerDevice(mockDevice));
}
示例11: testRegisteringCompatibleDevice
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
@Test
public void testRegisteringCompatibleDevice() throws Exception {
// FIXME: This is not really an unit test
String mockDeviceSerialNumber = "CompatibleDevice";
boolean mockDeviceEmulator = false;
String mockDeviceApiCompatibleApiVersion = "17";
Map<String, String> mockPropMap = new HashMap<>();
mockPropMap.put(DevicePropertyStringConstants.PROPERTY_API_LEVEL.toString(), mockDeviceApiCompatibleApiVersion);
IDevice mockDevice = mock(IDevice.class);
when(mockDevice.getSerialNumber()).thenReturn(mockDeviceSerialNumber);
when(mockDevice.getProperty(IDevice.PROP_BUILD_API_LEVEL)).thenReturn(mockDeviceApiCompatibleApiVersion);
when(mockDevice.isEmulator()).thenReturn(mockDeviceEmulator);
when(mockDevice.arePropertiesSet()).thenReturn(true);
when(mockDevice.getProperties()).thenReturn(mockPropMap);
FakeOnDeviceComponentAnswer onDeviceAnswer = new FakeOnDeviceComponentAnswer();
FakeDeviceShellAnswer shellAnswer = new FakeDeviceShellAnswer();
Mockito.doAnswer(onDeviceAnswer).when(mockDevice).createForward(anyInt(), anyInt());
Mockito.doAnswer(shellAnswer).when(mockDevice).executeShellCommand(Matchers.anyString(),
Matchers.any(IShellOutputReceiver.class));
Mockito.doAnswer(shellAnswer).when(mockDevice).executeShellCommand(Matchers.anyString(),
Matchers.any(IShellOutputReceiver.class),
anyInt());
assertEquals("The mocked device was not successfully wrapped.",
mockDevice.getSerialNumber(),
deviceManager.registerDevice(mockDevice));
assertEquals("The mocked device is not present in Agent after it was registered.",
mockDevice,
deviceManager.getDeviceBySerialNumber(mockDeviceSerialNumber));
}
示例12: executeShellCommand
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
@Override
public void executeShellCommand(String command, IShellOutputReceiver receiver,
long maxTimeToOutputResponse, TimeUnit maxTimeUnits)
throws TimeoutException, AdbCommandRejectedException,
ShellCommandUnresponsiveException, IOException {
iDevice.executeShellCommand(command, receiver, maxTimeToOutputResponse, maxTimeUnits);
}
示例13: runAndVerify
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
/**
* Calls {@link RemoteAndroidTestRunner#run(ITestRunListener...)} and verifies the given
* <var>expectedCmd</var> pattern was received by the mock device.
*/
private void runAndVerify(String expectedCmd) throws Exception {
mMockDevice.executeShellCommand(expectedCmd, (IShellOutputReceiver)
EasyMock.anyObject(), EasyMock.eq(0L), EasyMock.eq(TimeUnit.MILLISECONDS));
EasyMock.replay(mMockDevice);
mRunner.run(mMockListener);
EasyMock.verify(mMockDevice);
}
示例14: monkey
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
/**
* Executes a monkey command on the device, and sends the result to a
* <var>receiver</var>.
*
* @param command the shell command to execute
* @param receiver the {@link IShellOutputReceiver} that will receives the
* output of the shell command
*/
public boolean monkey(String command, IShellOutputReceiver receiver) {
boolean result = false;
try {
mDevice.executeShellCommand(command, receiver, 60000);
result = true;
} catch (ShellCommandUnresponsiveException mttor) {
result = true;
} catch (Exception ex) {
result = false;
}
return result;
}
示例15: logcat
import com.android.ddmlib.IShellOutputReceiver; //导入依赖的package包/类
/**
* Executes a logcat command on the device, and sends the result to a
* <var>receiver</var>.
*
* @param receiver the {@link IShellOutputReceiver} that will receives the
* output of the shell command
*/
public boolean logcat(IShellOutputReceiver receiver) {
boolean result = false;
try {
mDevice.executeShellCommand("logcat -v threadtime *:V", receiver,
60000);
result = true;
} catch (ShellCommandUnresponsiveException mttor) {
result = true;
} catch (Exception ex) {
result = false;
}
return result;
}