When I try to manually send the motion events, the security exception
comes when I send the ACTION_MOVE event:
Instrumentation instrumentation = getInstrumentation();
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
int x = 20;
int y = 150;
// down
MotionEvent event = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_DOWN, x, y, 0);
instrumentation.sendPointerSync(event);
instrumentation.waitForIdleSync();
Thread.sleep(1000); // long click
// move
for (; x<200; x+=3) {
event = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_MOVE, x, y, 0);
// **************** SecurityException will be thrown
************/
instrumentation.sendPointerSync(event);
instrumentation.waitForIdleSync();
}
// up
event = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_UP, x, y, 0);
instrumentation.sendPointerSync(event);
instrumentation.waitForIdleSync();
On 6 Mai, 10:06, jjoe64 <[email protected]> wrote:
> hello,
>
> since honeycomb (api level 11) there is a the feature "dragging and
> dropping".
> I wrote a very small and simple app to get involed with this new
> feature.
>
> Now I'd like to unit test this. I tried two ways to test it:
> 1. Robotium: solo.drag(...)
> 2. TouchUtils.dragViewBy(this, img, Gravity.TOP |
> Gravity.CENTER_HORIZONTAL, -80, -5);
>
> But both fail with this error: I/TestRunner( 648):
> java.lang.SecurityException: Injecting to another application requires
> INJECT_EVENTS permission
> 1. in the manifest, this permission is included
> 2. the app has the focus, there is no lock screen or something...
>
> When I try to debug the method TouchUtils.drag the javavm crashes at a
> simple integer calculation.
>
> It there any way to unit test the new drag n drop feature? Can anybody
> give me an example?
>
> Thanks,
> Jonas
--
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