2012-06-14 171 views

回答

4

拖(浮動fromX,浮TOX,浮弗羅米,浮玩具,INT STEPCOUNT)Robotium確實工作過,那裏的刷卡和scrollToSide似乎沒有工作。

使用android.support.v4.view.ViewPager,下面的代碼對我的作品:

solo.drag(300,0,100,100,1); 
2

我用Robotium下面的方法。我需要使用這種冒險的方式,因爲v4.view.ViewPager總是讓我的測試套件由於某些原因停止運行。

private void swipeToLeft(int stepCount) { 
    Display display = solo.getCurrentActivity().getWindowManager().getDefaultDisplay(); 
    int width = display.getWidth(); 
    int height = display.getHeight(); 
    float xStart = width - 10 ; 
    float xEnd = 10; 
    solo.drag(xStart, xEnd, height/2, height/2, stepCount); 
} 

private void swipeToRight(int stepCount) { 
    Display display = solo.getCurrentActivity().getWindowManager().getDefaultDisplay(); 
    int width = display.getWidth(); 
    int height = display.getHeight(); 
    float xStart = 10 ; 
    float xEnd = width - 10; 
    solo.drag(xStart, xEnd, height/2, height/2, stepCount); 
} 

而且整個想法是從這個偉大的職位由傑森: http://blogs.steeplesoft.com/posts/2013/02/13/simulating-swipes-in-your-android-tests/