jeudi 5 mars 2015

Using TouchUtils in Android testing

I'm testing on an actual device, with the screen unlocked. Here's my code:



public class TouchUtilsTest extends ActivityInstrumentationTestCase2<MainActivity> {

Activity mActivity;
Instrumentation mInstrumentation;

public TouchUtilsTest() {
super(MainActivity.class);
}

@Override
protected void setUp() throws Exception {
super.setUp();

setActivityInitialTouchMode(false);

mActivity = getActivity();
mInstrumentation = getInstrumentation();
}

public void testTapOnView() {
View v = mActivity.findViewById(3);
Log.d("testTapOnView", "weee");

TouchUtils.tapView(this, v);
}
}


Even with this simple code I run into the following issue:



java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission


I'm not sure what I'm doing wrong... Any suggestions are appreciated.


Aucun commentaire:

Enregistrer un commentaire