views:

444

answers:

1

This is the code for motion events in my instrumentation testing.

   long downTime = SystemClock.uptimeMillis();

   long eventTime = SystemClock.uptimeMillis();

   MotionEvent event = MotionEvent.obtain(downTime, eventTime,
   MotionEvent.ACTION_DOWN, 100,100, 0);

   MotionEvent event2 = MotionEvent.obtain(downTime, eventTime,
   MotionEvent.ACTION_UP, 100, 100, 0);

   instrumentation.sendPointerSync(event);

   instrumentation.sendPointerSync(event2);

And the following is the error iam getting:

java.lang.NullPointerException
at com.ni.fastflip.test.FastFlipWebviewTest.test(FastFlipWebviewTest.java:28)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:205)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:195)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:175)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)

Can any body suggest me what to do please

A: 

Which ones of these lines is line 28? thats where the null pointer exep was.

Use

if(whatever==null){ Log.d("tag","whatever was null"); }

to figure out which reference was null on line 28 if you have to.

Nathan
Null pointer Exception is at instrumentation.sendPointerSync(event);event is null here.What do i do now?
siri
I don't know :/
Nathan