android.test.mock.MockContentProvider Java Examples
The following examples show how to use
android.test.mock.MockContentProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TrayTest.java From tray with Apache License 2.0 | 6 votes |
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); }
Example #2
Source File: SimpleOperationTest.java From arca-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void testSimpleOperationSucceeds() { final AssertionLatch latch = new AssertionLatch(1); final TestSimpleOperation operation = new TestSimpleOperation(URI); operation.setRequestExecutor(new RequestExecutor.SerialRequestExecutor()); operation.setContext(new MockContextWithProvider(new MockContentProvider() { @Override public int bulkInsert(Uri uri, ContentValues[] values) { return 0; } })); operation.setOperationObserver(new OperationObserver() { @Override public void onOperationComplete(final Operation o) { latch.countDown(); assertNull(o.getError()); } }); operation.execute(); latch.assertComplete(); }
Example #3
Source File: TrayTest.java From tray with Apache License 2.0 | 5 votes |
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())); }
Example #4
Source File: TrayTest.java From tray with Apache License 2.0 | 5 votes |
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()); }
Example #5
Source File: SimpleOperationTest.java From arca-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void testSimpleOperationInsertsDataOnSuccess() throws Exception { final AssertionLatch latch = new AssertionLatch(1); final MockContext context = new MockContextWithProvider(new MockContentProvider() { @Override public int bulkInsert(Uri u, ContentValues[] v) { latch.countDown(); assertEquals(URI, u); return 0; } }); final TestSimpleOperation operation = new TestSimpleOperation(URI); operation.onPostExecute(context, new ContentValues[0]); latch.assertComplete(); }
Example #6
Source File: SimpleOperationTest.java From arca-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public MockContextWithProvider(final MockContentProvider provider) { mProvider = provider; }