当前位置: 首页>>代码示例>>Java>>正文


Java MockContentProvider类代码示例

本文整理汇总了Java中android.test.mock.MockContentProvider的典型用法代码示例。如果您正苦于以下问题:Java MockContentProvider类的具体用法?Java MockContentProvider怎么用?Java MockContentProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MockContentProvider类属于android.test.mock包,在下文中一共展示了MockContentProvider类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testClearAllFails

import android.test.mock.MockContentProvider; //导入依赖的package包/类
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);
}
 
开发者ID:grandcentrix,项目名称:tray,代码行数:21,代码来源:TrayTest.java

示例2: testSimpleOperationSucceeds

import android.test.mock.MockContentProvider; //导入依赖的package包/类
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();
}
 
开发者ID:cfmobile,项目名称:arca-android,代码行数:22,代码来源:SimpleOperationTest.java

示例3: testClearButFails

import android.test.mock.MockContentProvider; //导入依赖的package包/类
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()));
}
 
开发者ID:grandcentrix,项目名称:tray,代码行数:15,代码来源:TrayTest.java

示例4: testWipeFails

import android.test.mock.MockContentProvider; //导入依赖的package包/类
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());
}
 
开发者ID:grandcentrix,项目名称:tray,代码行数:15,代码来源:TrayTest.java

示例5: testSimpleOperationInsertsDataOnSuccess

import android.test.mock.MockContentProvider; //导入依赖的package包/类
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();
}
 
开发者ID:cfmobile,项目名称:arca-android,代码行数:15,代码来源:SimpleOperationTest.java

示例6: MockContextWithProvider

import android.test.mock.MockContentProvider; //导入依赖的package包/类
public MockContextWithProvider(final MockContentProvider provider) {
    mProvider = provider;
}
 
开发者ID:cfmobile,项目名称:arca-android,代码行数:4,代码来源:SimpleOperationTest.java


注:本文中的android.test.mock.MockContentProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。