本文整理匯總了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);
}