Code example for IsolatedContext

0
 
        mMockProvider = new MockProvider();
        mMockAlarmManager = new MockAlarmManager(mContext);
        MockContentResolver mockResolver = new MockContentResolver();
        mockResolver.addProvider(CalendarContract.AUTHORITY, mMockProvider);
        mIsolatedContext = new IsolatedContext(mockResolver, mContext);
    } 
 
    public void testNoEvents() { 
        AlarmScheduler.scheduleNextAlarm(mIsolatedContext, mMockAlarmManager,
                BATCH_SIZE, System.currentTimeMillis());
        assertFalse(mMockAlarmManager.isAlarmSet());
    } 
 
    public void testNonAllDayEvent() { 
        // Set up mock test data. 
        long currentMillis = System.currentTimeMillis();
        long startMillis = currentMillis + DateUtils.HOUR_IN_MILLIS;
        int reminderMin = 10;
        mMockProvider.addEventInfo(1, false, startMillis, reminderMin);
        expectAlarmAt(startMillis - reminderMin * DateUtils.MINUTE_IN_MILLIS);