Code example for MockContentResolver

Methods: addProvider

0
    protected void setUp() throws Exception { 
        super.setUp(); 
 
        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;