当前位置: 首页>>代码示例>>Java>>正文


Java MonkeyDevice类代码示例

本文整理汇总了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;
	}
}
 
开发者ID:Gogolook-Inc,项目名称:GogoMonkeyRun,代码行数:22,代码来源:MonkeyRecorderFrameExt.java

示例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);
    }
}
 
开发者ID:imsardine,项目名称:sikuli-monkey,代码行数:11,代码来源:AndroidRobot.java

示例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);
}
 
开发者ID:imsardine,项目名称:sikuli-monkey,代码行数:16,代码来源:AndroidScreen.java

示例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;
}
 
开发者ID:shiyimin,项目名称:androidtestdebug,代码行数:10,代码来源:QueryableDevice.java

示例5: AndroidRobot

import com.android.monkeyrunner.MonkeyDevice; //导入依赖的package包/类
public AndroidRobot(MonkeyDevice dev) {
    _device = dev;
}
 
开发者ID:imsardine,项目名称:sikuli-monkey,代码行数:4,代码来源:AndroidRobot.java

示例6: AdvancePressAction

import com.android.monkeyrunner.MonkeyDevice; //导入依赖的package包/类
public AdvancePressAction(String key) {
	this(key, MonkeyDevice.DOWN_AND_UP);
}
 
开发者ID:Gogolook-Inc,项目名称:GogoMonkeyRun,代码行数:4,代码来源:AdvancePressAction.java

示例7: start

import com.android.monkeyrunner.MonkeyDevice; //导入依赖的package包/类
public static void start(final MonkeyDevice device, final String defaultExportPath) {
	start(device.getImpl(), defaultExportPath);
}
 
开发者ID:Gogolook-Inc,项目名称:GogoMonkeyRun,代码行数:4,代码来源:MonkeyRecorderExt.java


注:本文中的com.android.monkeyrunner.MonkeyDevice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。