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.
Any ideas?
It happens if your phone is locked or there is some other Activity on the HomeScreen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With