use of android.test.mock.MockContentProvider in project tray by grandcentrix.
the class TrayProviderHelperTest method testPersistFail.
public void testPersistFail() throws Exception {
Uri uri = new TrayUri(getProviderMockContext()).get();
MockContentProvider mockContentProvider = new MockContentProvider(getProviderMockContext()) {
@Override
public Uri insert(final Uri uri, final ContentValues values) {
return null;
}
};
getProviderMockContext().addProvider(uri.getAuthority(), mockContentProvider);
getProviderMockContext().enableMockResolver(true);
TrayProviderHelper providerHelper = new TrayProviderHelper(getProviderMockContext());
assertFalse(providerHelper.persist(uri, STRING_A));
assertFalse(providerHelper.persist(uri, STRING_A, null));
assertFalse(providerHelper.persist(MODULE_A, STRING_A, null));
assertFalse(providerHelper.persist(MODULE_A, STRING_A, null, null));
}
use of android.test.mock.MockContentProvider in project tray by grandcentrix.
the class TrayTest method testWipeFails.
public void testWipeFails() 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);
final Tray tray = new Tray(getProviderMockContext());
getProviderMockContext().enableMockResolver(true);
assertFalse(tray.wipe());
}
use of android.test.mock.MockContentProvider in project tray by grandcentrix.
the class TrayTest method testClearButFails.
public void testClearButFails() 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());
tray.clearBut(new AppPreferences(getProviderMockContext()));
}
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);
}
use of android.test.mock.MockContentProvider in project tray by grandcentrix.
the class TrayProviderHelperTest method testWipeFailsHard.
public void testWipeFailsHard() 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);
final TrayProviderHelper helper = new TrayProviderHelper(getProviderMockContext()) {
@Override
public boolean clear() {
// fake working clear
return true;
}
};
assertTrue(helper.clear());
assertFalse(helper.wipe());
}
Aggregations