Search in sources :

Example 11 with MockContentProvider

use of android.test.mock.MockContentProvider in project tray by grandcentrix.

the class TrayTest method testClearAllFails.

public void testClearAllFails() throws Exception {
    final MockContentProvider mockContentProvider = new MockContentProvider(getProviderMockContext()) {

        @Override
        public int delete(final Uri uri, final String selection, final String[] selectionArgs) {
            throw new IllegalStateException("something serious is wrong");
        }
    };
    getProviderMockContext().addProvider(MockProvider.AUTHORITY, mockContentProvider);
    getProviderMockContext().enableMockResolver(true);
    final Tray tray = new Tray(getProviderMockContext());
    final TestTrayModulePreferences module2 = new TestTrayModulePreferences(getProviderMockContext(), "module2");
    module2.put("blubb", "hello");
    mTrayModulePref.put("test", "test");
    assertUserDatabaseSize(2);
    assertFalse(tray.clear());
    assertUserDatabaseSize(2);
}
Also used : TestTrayModulePreferences(net.grandcentrix.tray.mock.TestTrayModulePreferences) MockContentProvider(android.test.mock.MockContentProvider) Uri(android.net.Uri)

Aggregations

Uri (android.net.Uri)11 MockContentProvider (android.test.mock.MockContentProvider)11 ContentValues (android.content.ContentValues)1 AppPreferences (net.grandcentrix.tray.AppPreferences)1 TrayException (net.grandcentrix.tray.core.TrayException)1 TrayItem (net.grandcentrix.tray.core.TrayItem)1 TestTrayModulePreferences (net.grandcentrix.tray.mock.TestTrayModulePreferences)1