本文整理汇总了Java中com.android.monkeyrunner.MonkeyDevice类的典型用法代码示例。如果您正苦于以下问题:Java MonkeyDevice类的具体用法?Java MonkeyDevice怎么用?Java MonkeyDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MonkeyDevice类属于com.android.monkeyrunner包,在下文中一共展示了MonkeyDevice类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: touch
import com.android.monkeyrunner.MonkeyDevice; //导入依赖的package包/类
private void touch(MouseEvent event) {
// TODO
int x = event.getX();
int y = event.getY();
// Since we scaled the image down, our x/y are scaled as well.
double scalex = ((double) currentImage.getWidth()) / ((double) scaledImage.getWidth());
double scaley = ((double) currentImage.getHeight()) / ((double) scaledImage.getHeight());
x = (int) (x * scalex);
y = (int) (y * scaley);
switch (event.getID()) {
case MouseEvent.MOUSE_CLICKED:
addAction(new TouchAction(x, y, MonkeyDevice.DOWN_AND_UP));
break;
case MouseEvent.MOUSE_PRESSED:
addAction(new TouchAction(x, y, MonkeyDevice.DOWN));
break;
case MouseEvent.MOUSE_RELEASED:
addAction(new TouchAction(x, y, MonkeyDevice.UP));
break;
}
}
示例2: press
import com.android.monkeyrunner.MonkeyDevice; //导入依赖的package包/类
private void press(String keycodeName, float durationSec) {
sleep(1);
if (durationSec == 0) {
_device.press(new PyObject[] { new PyString(keycodeName), new PyString(MonkeyDevice.DOWN_AND_UP) }, null);
} else {
_device.press(new PyObject[] { new PyString(keycodeName), new PyString(MonkeyDevice.DOWN) }, null);
sleep(durationSec);
_device.press(new PyObject[] { new PyString(keycodeName), new PyString(MonkeyDevice.UP) }, null);
}
}
示例3: AndroidScreen
import com.android.monkeyrunner.MonkeyDevice; //导入依赖的package包/类
public AndroidScreen(String serialNumber) throws AWTException {
MonkeyDevice device = MonkeyRunner.waitForConnection(new PyObject[] { new PyFloat(15), new PyString(serialNumber) }, null);
try { // waitForConnection() never returns null, even the connection cannot be created.
String model = device.getProperty(new PyObject[] {new PyString("build.model")}, null);
Debug.history("Successfully connect to a device. MODEL: " + model);
} catch (Throwable e) {
throw new RuntimeException("Failed to connect to a device (within timeout).", e);
}
_robot = new AndroidRobot(device);
// Region's default constructor doesn't use this screen as the default one.
Rectangle bounds = getBounds();
super.init(bounds.x, bounds.y, bounds.width, bounds.height, this);
}
示例4: QueryableDevice
import com.android.monkeyrunner.MonkeyDevice; //导入依赖的package包/类
@MonkeyRunnerExported(doc = "根据一个 MonkeyDevice实例创建QueryableDevice.", args = { "device" }, argDocs = { "要扩展的MonkeyDevice实例." })
public QueryableDevice(MonkeyDevice device) {
// 在获取HierarchyViewer引用的时候,会启动手机上的ViewServer。
// 因为HierarchyViewer这个类型提供的函数实在是太少,基本上就抛弃这个类了
// 我们自己去通过过socket跟view server通信,因此这里简单丢弃hierarchyviewer的实例。
device.getImpl().getHierarchyViewer();
_device = device;
}
示例5: AndroidRobot
import com.android.monkeyrunner.MonkeyDevice; //导入依赖的package包/类
public AndroidRobot(MonkeyDevice dev) {
_device = dev;
}
示例6: AdvancePressAction
import com.android.monkeyrunner.MonkeyDevice; //导入依赖的package包/类
public AdvancePressAction(String key) {
this(key, MonkeyDevice.DOWN_AND_UP);
}
示例7: start
import com.android.monkeyrunner.MonkeyDevice; //导入依赖的package包/类
public static void start(final MonkeyDevice device, final String defaultExportPath) {
start(device.getImpl(), defaultExportPath);
}