Android MockContentResolver - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android MockContentResolver class.

This code example shows how to use the following methods:
        PeriodicSync sync1 = new PeriodicSync(account1, authority, extras1, period1);
        PeriodicSync sync2 = new PeriodicSync(account1, authority, extras2, period1);
        PeriodicSync sync3 = new PeriodicSync(account1, authority, extras2, period2);
        PeriodicSync sync4 = new PeriodicSync(account2, authority, extras2, period2);
 
        MockContentResolver mockResolver = new MockContentResolver();
 
        SyncStorageEngine engine = SyncStorageEngine.newTestInstance(
                new TestContext(mockResolver, getContext()));
 
        removePeriodicSyncs(engine, account1, 0, authority);
        removePeriodicSyncs(engine, account2, 0, authority);
        removePeriodicSyncs(engine, account1, 1, authority);
 
        // this should add two distinct periodic syncs for account1 and one for account2 
        engine.addPeriodicSync(sync1.account, 0, sync1.authority, sync1.extras, sync1.period);
        engine.addPeriodicSync(sync2.account, 0, sync2.authority, sync2.extras, sync2.period);
        engine.addPeriodicSync(sync3.account, 0, sync3.authority, sync3.extras, sync3.period);
        engine.addPeriodicSync(sync4.account, 0, sync4.authority, sync4.extras, sync4.period);
        // add a second user 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addProvider
    private Intent mIntentForStartActivity;
 
    public ContactsMockContext(Context base) {
        super(base);
        mPackageManager = new ContactsMockPackageManager();
        mContentResolver = new MockContentResolver();
        mContactsProvider = new MockContentProvider();
        mContentResolver.addProvider(ContactsContract.AUTHORITY, mContactsProvider);
        mContactsProvider.attachInfo(this, new ProviderInfo());
        mSettingsProvider = new MockContentProvider();
        mSettingsProvider.attachInfo(this, new ProviderInfo());
        mContentResolver.addProvider(Settings.AUTHORITY, mSettingsProvider);
    } 
 
    public void setMockAccountTypeManager(MockAccountTypeManager mockAccountTypeManager) {
        mMockAccountTypeManager = mockAccountTypeManager;
    } 
 
    @Override 
    public ContentResolver getContentResolver() {
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: insert, query, update
        value.put(Registry.AUTHORIZE_URL, "http://authorize");
        value.put(Registry.CONSUMER_KEY, "key");
        value.put(Registry.CONSUMER_SECRET, "secret123");
        value.put(Registry.URL, "http://twitter.com");
 
        Uri uri = mResolver.insert(REGISTRY_URI, value);
        assertNotNull(uri);
 
        value.clear();
        value.put(Registry.ACCESS_SECRET, "mysec");
        value.put(Registry.ACCESS_TOKEN, "mytok");
        assertEquals(1, mResolver.update(uri, value, null, null));
 
        Cursor cur = mResolver.query(uri, new String[] {
                Registry.ACCESS_SECRET, Registry.ACCESS_TOKEN 
        }, null, null, null); 
         
        assertTrue(cur.moveToFirst());
        assertEquals("mysec", cur.getString(cur.getColumnIndexOrThrow(Registry.ACCESS_SECRET)));
        assertEquals("mytok", cur.getString(cur.getColumnIndexOrThrow(Registry.ACCESS_TOKEN)));
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addProvider
        assertNotNull(activity);
 
        ContentProvider provider = new ChromeBrowserProvider();
        provider.attachInfo(activity, null);
 
        MockContentResolver resolver = new MockContentResolver();
        resolver.addProvider(ChromeBrowserProvider.getApiAuthority(activity), provider);
        resolver.addProvider(ChromeBrowserProvider.getInternalAuthority(activity), provider);
 
        mContext = new IsolatedContext(resolver, activity);
        assertTrue(getContentResolver() instanceof MockContentResolver);
    } 
 
    protected ContentResolver getContentResolver() {
        return mContext.getContentResolver();
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addProvider
        SynchronousContactsProvider2.resetOpenHelper(); 
    } 
 
    public void testPerformance() { 
        final Context targetContext = getContext();
        MockContentResolver resolver = new MockContentResolver();
        MockContext context = new MockContext() {
            @Override 
            public Resources getResources() {
                return targetContext.getResources();
            } 
 
            @Override 
            public String getPackageName() {
                return "no.package"; 
            } 
        }; 
        RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext(context,
                targetContext, "perf_imp.");
        targetContextWrapper.makeExistingFilesAndDbsAccessible();

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android MockContentResolver Questions & Answers:

See Code Examples for Android MockContentResolver Methods: