Thank you. I will integrate your fix into the repro.
On Mon, Jun 11, 2012 at 6:48 AM, Daniel Kang <[email protected]> wrote:
> Hello,
>
> I'm doing some Unit Test with Android Calendar application.
> In the test code in EditEventHelperTest.java, lots of testSaveEvent*
> encountered "java.lang.NullPointerException".
> This comes from AsyncQueryService. startBatch(...).
>
>
> public void startBatch(int token, Object cookie, String authority,
> ArrayList<ContentProviderOperation> cpo, long delayMillis)
> {
> OperationInfo info = new OperationInfo();
> info.op = Operation.EVENT_ARG_BATCH;
> info.resolver = mContext.getContentResolver();
> info.handler = mHandler;
>
> getContentResolver() cause NULL pointer exception.
>
> I found null resolver derived from wrong mContext. Not in test case
> mContext type is EditEventActivity, but in test case the type is
> MockAbsCalendarActivity.
> MockAbsCalendarActivity in EditEventHelperTest.java is mock test
> module and defines new startBatch for test module.
>
> I changed EditEventHelper creator code like this
>
> public EditEventHelper(Context context, CalendarEventModel model)
> {
> // mService = new AsyncQueryService(context);
> mService =
> ((AbstractCalendarActivity)context).getAsyncQueryService();
> }
>
> This removes Null pointer exception and run test case with right
> startBatch function.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en