1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 02:41:11 +01:00

BaseUiAutomation: Port uiDeviceSwipe methods from WA2

This commit is contained in:
Brendan Jackman 2017-10-02 16:12:49 +01:00
parent a65cffb705
commit e5f13076ac
2 changed files with 75 additions and 0 deletions

View File

@ -43,6 +43,8 @@ public class BaseUiAutomation {
// Time in milliseconds
public long uiAutoTimeout = 4 * 1000;
public enum Direction { UP, DOWN, LEFT, RIGHT, NULL };
public static final int CLICK_REPEAT_INTERVAL_MINIMUM = 5;
public static final int CLICK_REPEAT_INTERVAL_DEFAULT = 50;
@ -149,6 +151,79 @@ public class BaseUiAutomation {
}
}
public int getDisplayHeight() {
return mDevice.getDisplayHeight();
}
public int getDisplayWidth() {
return mDevice.getDisplayWidth();
}
public int getDisplayCentreWidth() {
return getDisplayWidth() / 2;
}
public int getDisplayCentreHeight() {
return getDisplayHeight() / 2;
}
public void uiDeviceSwipeUp(int steps) {
mDevice.swipe(
getDisplayCentreWidth(),
(getDisplayCentreHeight() + (getDisplayCentreHeight() / 2)),
getDisplayCentreWidth(),
(getDisplayCentreHeight() / 2),
steps);
}
public void uiDeviceSwipeDown(int steps) {
mDevice.swipe(
getDisplayCentreWidth(),
(getDisplayCentreHeight() / 2),
getDisplayCentreWidth(),
(getDisplayCentreHeight() + (getDisplayCentreHeight() / 2)),
steps);
}
public void uiDeviceSwipeLeft(int steps) {
mDevice.swipe(
(getDisplayCentreWidth() + (getDisplayCentreWidth() / 2)),
getDisplayCentreHeight(),
(getDisplayCentreWidth() / 2),
getDisplayCentreHeight(),
steps);
}
public void uiDeviceSwipeRight(int steps) {
mDevice.swipe(
(getDisplayCentreWidth() / 2),
getDisplayCentreHeight(),
(getDisplayCentreWidth() + (getDisplayCentreWidth() / 2)),
getDisplayCentreHeight(),
steps);
}
public void uiDeviceSwipe(Direction direction, int steps) throws Exception {
switch (direction) {
case UP:
uiDeviceSwipeUp(steps);
break;
case DOWN:
uiDeviceSwipeDown(steps);
break;
case LEFT:
uiDeviceSwipeLeft(steps);
break;
case RIGHT:
uiDeviceSwipeRight(steps);
break;
case NULL:
throw new Exception("No direction specified");
default:
break;
}
}
public void repeatClickUiObject(UiObject view, int repeatCount, int intervalInMillis) throws Exception {
int repeatInterval = intervalInMillis > CLICK_REPEAT_INTERVAL_MINIMUM
? intervalInMillis : CLICK_REPEAT_INTERVAL_DEFAULT;

Binary file not shown.