Skip to content

Instantly share code, notes, and snippets.

@mgasiorowski
Last active August 29, 2015 13:57
Show Gist options
  • Save mgasiorowski/9892682 to your computer and use it in GitHub Desktop.
Save mgasiorowski/9892682 to your computer and use it in GitHub Desktop.
Swipe to left for robotium test for android 2.x and 4.x
private void swipeToLeft(int stepCount, int repNumber) {
for(int x = 0; x < repNumber; x++) {
solo.waitForActivity(solo.getCurrentActivity().toString(), 5000);
Display display = solo.getCurrentActivity().getWindowManager().getDefaultDisplay();
int width = 0;
int height = 0;
if (android.os.Build.VERSION.SDK_INT <= 13) {
width = display.getWidth();
height = display.getHeight();
} else {
Point size = new Point();
display.getSize(size);
width = size.x;
height = size.y;
}
float xStart = width - 10;
float xEnd = 10;
solo.drag(xStart, xEnd, height / 2, height / 2, stepCount);
x++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment