Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

slow or fast drag up (scroll) using robotium

this my code for drag up current screen.

int screenWidth = getActivity().getWindowManager().getDefaultDisplay().getWidth();
int screenHeight = getActivity().getWindowManager().getDefaultDisplay().getHeight();
int fromX, toX, fromY, toY = 0;
fromX = screenWidth/2;
toX = screenWidth/2;
fromY = (screenHeight/2) + (screenHeight/3);
toY = (screenHeight/2) - (screenHeight/3);
int scroll_time = 10000;             
solo.sleep(5000);
    // Drag UP  
solo.drag(fromX, toX, fromY, toY, 40);
Log.d(TAG, "Drag 1");
    // here default origin (x,y = 0,0) is left upper corner

here scroll is working but very slow.

So for fast scroll what changes in this code required ?

like image 249
VISHAL VIRADIA Avatar asked Sep 27 '12 05:09

VISHAL VIRADIA


1 Answers

I faced the same problem, what you need to do is adjust the following line of code,

solo.drag(fromX, toX, fromY, toY, 40); //Change 40 to 10

This will increase your scrolling speed, the lower the step count, the faster is the scrolling!

like image 139
Royston Pinto Avatar answered Nov 03 '22 01:11

Royston Pinto