Am trying to write an instrumentation test which can simulate
scrolling. Since I don't have an handle on the view, it's not as easy
as:

view.scrollBy(0, y); // I get security exception

Also tried my luck (in vain) with the following code:

final long downTime = SystemClock.uptimeMillis();
final long eventTime = SystemClock.uptimeMillis();
final MotionEvent event = MotionEvent.obtain(downTime, eventTime +
100, MotionEvent.ACTION_MOVE, x, y, 0);
event.addBatch(eventTime + 200, x, y * 3, 1, 1, 0);
final Instrumentation inst = getInstrumentation();
inst.sendPointerSync(event);
inst.waitForIdleSync();

Another option is to save the scrolling action as a gesture and use
gestures. Can anyone share the code for simulating a gesture (pre-
defined in the gestures file) in an instrumentation test? I've seen
plenty of examples that show you how to write a listener, but am
trying to do the opposite here.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to