Has anyone been able to successfully perform unit testing on the Android Emulator using methods offered by the TouchUtils
class?
I m able to get the test(s) to pass on my device but when I run the exact same test(s) (and test suite) on an emulator, any test using a TouchUtils
methods always throws the following exception:
java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
at android.os.Parcel.readException(Parcel.java:1327)
at android.os.Parcel.readException(Parcel.java:1281)
at android.view.IWindowManager$Stub$Proxy.injectPointerEvent(IWindowManager.java:1196)
at android.app.Instrumentation.sendPointerSync(Instrumentation.java:902)
at android.test.TouchUtils.drag(TouchUtils.java:786)
at android.test.TouchUtils.dragViewTo(TouchUtils.java:633)
...
I ve unlocked the keyguard and even ran other (non TouchUtils) test cases which have passed.
I do not have the @UiThreadTest
applied nor am I running anything that requires code to run on the UI thread.
When I comment out the line that employs TouchUtils.dragViewTo(...)
and put in a simple assert(true)
, the test runs and passes.
任何想法?