Android IsolatedContext - 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 IsolatedContext class.

This code example shows how to use the following methods:getContentResolver
 
        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();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
            } 
        }; 
        RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext(context,
                targetContext, "perf_imp.");
        targetContextWrapper.makeExistingFilesAndDbsAccessible();
        IsolatedContext providerContext = new IsolatedContext(resolver, targetContextWrapper);
        SynchronousContactsProvider2 provider = new SynchronousContactsProvider2();
        provider.setDataWipeEnabled(false);
        provider.attachInfo(providerContext, null);
        resolver.addProvider(ContactsContract.AUTHORITY, provider);
 
        ContentProvider callLogProvider = new TestCallLogProvider();
        callLogProvider.attachInfo(providerContext, null);
        resolver.addProvider(CallLog.AUTHORITY, callLogProvider);
 
        LegacyContactImporter importer = new LegacyContactImporter(providerContext, provider);
 
        provider.wipeData();
 
        long start = System.currentTimeMillis();
        if (TRACE) {
6
CodeRank
This code example shows how to use the following methods:
            } 
        }; 
        RenamingDelegatingContext targetContextWrapper =
                new RenamingDelegatingContext(context, targetContext, "perf.");
        targetContextWrapper.makeExistingFilesAndDbsAccessible();
        IsolatedContext providerContext = new IsolatedContext(resolver, targetContextWrapper);
        SynchronousContactsProvider2 provider = new SynchronousContactsProvider2();
        provider.setDataWipeEnabled(false);
        provider.attachInfo(providerContext, null);
        resolver.addProvider(ContactsContract.AUTHORITY, provider);
 
        long rawContactCount = provider.getRawContactCount();
        if (rawContactCount == 0) {
            Log.w(TAG, "The test has not been set up. Use this command to copy a contact db"
                    + " to the device:\nadb push <large contacts2.db> " 
                    + "data/data/com.android.providers.contacts/databases/perf.contacts2.db"); 
            return; 
        } 
 
        provider.prepareForFullAggregation(500);
6
CodeRank
This code example shows how to use the following methods:
        final String filenamePrefix = "test.";
        RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext(new MockContext2(), // The context that most methods are
                                                                                                           //delegated to 
                getContext(), // The context that file methods are delegated to
                filenamePrefix);
        mDatabaseContext = new IsolatedContext(mResolver, targetContextWrapper);
 
        onCreateDatabase(mDatabaseContext);
 
        mDBTestCase.setUp();
    } 
 
    /* 
     * (non-Javadoc) 
     *  
     * @see org.dbunit.DatabaseTestCase#tearDown() 
     */ 
    protected void tearDown() throws Exception { 
        mDBTestCase.tearDown();
        super.tearDown(); 
6
CodeRank
This code example shows how to use the following methods:
    @Override 
    @Before 
    public void setUp() throws Exception { 
        super.setUp(); 
        mMockContext = new IsolatedContext(new MockContentResolver(),
                                           getContext());
    } 
 
    /** 
     * Gets the isolated context created by this class during initialization. 
     * @return The isolated context instance 
     */ 
    protected IsolatedContext getMockContext() {
        return mMockContext;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
    @Override 
    protected void setUp() throws Exception { 
        super.setUp(); 
        final String filenamePrefix = "test.";
        RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext(new MockContext2(), getContext(), filenamePrefix);
        _openHelperContext = new IsolatedContext(new MockContentResolver(), targetContextWrapper);
        _openHelper = createSQLiteOpenHelper(_openHelperContext);
    } 
 
    @Override 
    protected void tearDown() throws Exception { 
        _openHelper.close();
        super.tearDown(); 
    } 
 
    /** 
     * @return Returns the actual SQLiteOpenHelper under test. 
     */ 
    public T getSQLiteOpenHelper() { 
        return _openHelper;
5
CodeRank
This code example shows how to use the following methods:
            } 
        }; 
        RenamingDelegatingContext targetContextWrapper =
                new RenamingDelegatingContext(context, targetContext, "perf.");
        targetContextWrapper.makeExistingFilesAndDbsAccessible();
        IsolatedContext providerContext = new IsolatedContext(resolver, targetContextWrapper);
        SynchronousContactsProvider2 provider = new SynchronousContactsProvider2();
        provider.setDataWipeEnabled(false);
        provider.attachInfo(providerContext, null);
        resolver.addProvider(ContactsContract.AUTHORITY, provider);
 
        long rawContactCount = provider.getRawContactCount();
        if (rawContactCount == 0) {
            Log.w(TAG, "The test has not been set up. Use this command to copy a contact db"
                    + " to the device:\nadb push <large contacts2.db> " 
                    + "data/data/com.android.providers.contacts/databases/perf.contacts2.db"); 
            return; 
        } 
 
        provider.prepareForFullAggregation(500);
5
CodeRank
This code example shows how to use the following methods:createDbFromSqlStatements
This code example shows how to use the following methods:getContentResolver
 
        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();
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
 
    @Override 
    protected void setUp() throws Exception { 
        super.setUp(); 
        final MockContentResolver mcr = new MockContentResolver();
        setContext(new IsolatedContext(mcr, getContext()));
 
    } 
 
    public void testSync() { 
        // startService(new Intent(getContext(), SyncService.class)); 
        // final SyncService svc = getService(); 
        // 
        // assertNotNull(svc); 
 
    } 
 
 
} 
4
CodeRank

Related Android IsolatedContext Questions & Answers:

See Code Examples for Android IsolatedContext Methods: