use of android.test.mock.MockContentProvider in project tray by grandcentrix.
the class TrayProviderHelperTest method testQueryFails.
public void testQueryFails() throws Exception {
Uri uri = new TrayUri(getProviderMockContext()).get();
MockContentProvider mockContentProvider = new MockContentProvider(getProviderMockContext()) {
@Override
public Cursor query(final Uri uri, final String[] projection, final String selection, final String[] selectionArgs, final String sortOrder) {
throw new IllegalStateException("something serious is wrong");
}
};
getProviderMockContext().addProvider(uri.getAuthority(), mockContentProvider);
getProviderMockContext().enableMockResolver(true);
try {
mProviderHelper.queryProvider(getUri(MODULE_A, KEY_A));
fail("did not throw");
} catch (TrayException e) {
e.getCause().getMessage().equals("something serious is wrong");
}
final List<TrayItem> trayItems = mProviderHelper.queryProviderSafe(getUri(MODULE_A, KEY_A));
assertEquals(0, trayItems.size());
}
use of android.test.mock.MockContentProvider in project tray by grandcentrix.
the class TrayProviderHelperTest method testClearFails.
public void testClearFails() throws Exception {
Uri uri = new TrayUri(getProviderMockContext()).get();
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(uri.getAuthority(), mockContentProvider);
getProviderMockContext().enableMockResolver(true);
assertFalse(mProviderHelper.clear());
}
use of android.test.mock.MockContentProvider in project tray by grandcentrix.
the class TrayProviderHelperTest method testClearButFails.
public void testClearButFails() throws Exception {
Uri uri = new TrayUri(getProviderMockContext()).get();
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(uri.getAuthority(), mockContentProvider);
getProviderMockContext().enableMockResolver(true);
assertFalse(mProviderHelper.clearBut(new AppPreferences(getProviderMockContext())));
}
use of android.test.mock.MockContentProvider in project tray by grandcentrix.
the class TrayProviderHelperTest method testPersistFails.
public void testPersistFails() throws Exception {
Uri uri = new TrayUri(getProviderMockContext()).get();
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(uri.getAuthority(), mockContentProvider);
getProviderMockContext().enableMockResolver(true);
assertFalse(mProviderHelper.persist(MODULE_A, KEY_A, STRING_A));
}
use of android.test.mock.MockContentProvider in project tray by grandcentrix.
the class TrayProviderHelperTest method testRemoveFails.
public void testRemoveFails() throws Exception {
Uri uri = new TrayUri(getProviderMockContext()).get();
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(uri.getAuthority(), mockContentProvider);
getProviderMockContext().enableMockResolver(true);
assertEquals(0, mProviderHelper.removeAndCount(getUri(MODULE_A, KEY_A)));
}
Aggregations