옵션 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | private InstrumentationTestCase uiAutoClass = new InstrumentationTestCase(); private void moveClick(boolean isClick, int x, int y){ if(isClick){ mCursorView.setImageResource(R.drawable.cursor_clicked); final UiAutomation uiAutomation = uiAutoClass.getInstrumentation().getUiAutomation(); //NULL_POINTER_EXCEPTION final long eventTime = SystemClock.uptimeMillis(); MotionEvent motionDown = MotionEvent.obtain(eventTime, eventTime, KeyEvent.ACTION_DOWN, x, y, 0); motionDown.setSource(InputDevice.SOURCE_TOUCHSCREEN); uiAutomation.injectInputEvent(motionDown, true); MotionEvent motionUp = MotionEvent.obtain(eventTime, eventTime, KeyEvent.ACTION_UP, x, y, 0); motionUp.setSource(InputDevice.SOURCE_TOUCHSCREEN); uiAutomation.injectInputEvent(motionUp, true); motionUp.recycle(); motionDown.recycle(); }else{ mCursorView.setImageResource(R.drawable.cursor_norm); } } public class UIAutomationTest extends InstrumentationTestCase { private Instrumentation instr; public UIAutomationTest() { instr = getInstrumentation(); Log.d("TAG", "UIAutomationTest instrumentation: " + instr); } @Override protected void setUp() throws Exception { super.setUp(); instr = getInstrumentation(); Log.d("TAG", "setUp instrumentation: " + instr); } } | cs |