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
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
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.");
        targetContextWrapper.makeExistingFilesAndDbsAccessible();

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: addProvider
	    protected void setUp() throws Exception { 
	        super.setUp(); 
 
 
 
	        mResolver = new MockContentResolver();
	        final String filenamePrefix = "test.";
	        RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext(
	                new MockContext(), // The context that most methods are
	                // delegated to 
	                getContext(), // The context that file methods are delegated to
	                filenamePrefix);
	        mProviderContext = new MyIsolatedContext(mResolver, targetContextWrapper);
 
	        mProvider = mProviderClass.newInstance();
	        mProvider.attachInfo(mProviderContext, null);
	        assertNotNull(mProvider);
	        mResolver.addProvider(mProviderAuthority, getProvider());
	    } 
 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: insert, query
 
        ContentValues values = createReg("regkey123");
        setPermission(true); 
        setPackage(PACKAGE_UNDER_TEST);
        values.put(Consumers.ACTIVITY, ".MyActivity");
        assertNotNull(mResolver.insert(REGISTRY_URI, values));
 
        Cursor cur = mResolver.query(REGISTRY_URI, new String[] {
                Consumers.ACTIVITY, Consumers.PACKAGE_NAME 
        }, Registry.CONSUMER_KEY + "=?", new String[] {
            "regkey123" 
        }, null); 
 
        assertEquals(1, cur.getCount());
        assertTrue(cur.moveToFirst());
        assertEquals(PACKAGE_UNDER_TEST, cur.getString(cur
                .getColumnIndexOrThrow(Consumers.PACKAGE_NAME)));
        assertEquals(".MyActivity", cur.getString(cur.getColumnIndexOrThrow(Consumers.ACTIVITY)));
    } 
 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: addProvider
    @Override 
    public void setUp() throws Exception { 
        super.setUp(); 
        mMockContext = getMockContext();
        mMockResolver = (MockContentResolver)mMockContext.getContentResolver();
        mMockResolver.addProvider(CANHAZ_AUTHORITY, new MockProvider(mMockContext));
    } 
 
    @Override 
    public void tearDown() throws Exception { 
        super.tearDown(); 
    } 
 
    private ContentValues ponyValues(String name, String type, int legs, boolean canRide) {
        ContentValues cv = new ContentValues();
        cv.put(PONY_COLUMN_NAME, name);
        cv.put(PONY_COLUMN_TYPE, type);
        cv.put(PONY_COLUMN_LEGS, legs);
        cv.put(PONY_COLUMN_CAN_RIDE, canRide ? 1 : 0);
        return cv;
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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);
    } 
 
    @Override 
    public ContentResolver getContentResolver() {
        return mContentResolver;
    } 
 
    public MockContentProvider getContactsProvider() {
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android MockContentResolver Questions & Answers:

See Code Examples for Android MockContentResolver Methods: