當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。