2012-06-14 105 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/