Fast scroll in Robotium

谁说我不能喝 提交于 2019-12-11 06:19:29

问题


I have created a test project for my Android project. In my app there is a listview that has a lot of data. I need to scroll this listview up and down using Robotium. I have used the scrollUp() and scrollDown() functions, but it is scrolling too slowly.

I am using Robotium 3.3. Is there any way to make a fast scroll?


回答1:


int screenWidth = getActivity().getWindowManager().getDefaultDisplay().getWidth();
int screenHeight = getActivity().getWindowManager().getDefaultDisplay().getHeight();

         int fromX, toX, fromY, toY = 0,stepCount=1;

         // Scroll Down // Drag Up
         fromX = screenWidth/2;
         toX = screenWidth/2;
         fromY = (screenHeight/2) + (screenHeight/3);
         toY = (screenHeight/2) - (screenHeight/3);

solo.drag(fromX, toX, fromY, toY, stepCount);

here

[1] stepCount=1; // very fast scroll

[2] stepCount=10; // medium scroll

[3] stepCount=17; // slow scroll

So you adjust " stepCount " value according to your scroll required speed.

i hope this will help you for your better scroll list view. Thanks.



来源:https://stackoverflow.com/questions/11682196/fast-scroll-in-robotium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!