use of android.test.mock.MockContentResolver in project android_frameworks_base by crdroidandroid.
the class TestContext method createStorageTestContext.
/**
* Returns a Context configured with test provider for authority.
*/
static Context createStorageTestContext(Context context, String authority) {
final MockContentResolver testResolver = new MockContentResolver();
TestContentProvider provider = new TestContentProvider();
testResolver.addProvider(authority, provider);
return new ContextWrapper(context) {
@Override
public ContentResolver getContentResolver() {
return testResolver;
}
};
}
use of android.test.mock.MockContentResolver in project android_frameworks_base by crdroidandroid.
the class ProviderTestCase method newResolverWithContentProviderFromSql.
public static <T extends ContentProvider> ContentResolver newResolverWithContentProviderFromSql(Context targetContext, Class<T> providerClass, String authority, String databaseName, int databaseVersion, String sql) throws IllegalAccessException, InstantiationException {
final String filenamePrefix = "test.";
MockContentResolver resolver = new MockContentResolver();
RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext(// The context that most methods are delegated to
new MockContext(), // The context that file methods are delegated to
targetContext, filenamePrefix);
Context context = new IsolatedContext(resolver, targetContextWrapper);
DatabaseUtils.createDbFromSqlStatements(context, databaseName, databaseVersion, sql);
T provider = ProviderTestCase2.createProviderForTest(context, providerClass, authority);
resolver.addProvider(authority, provider);
return resolver;
}
use of android.test.mock.MockContentResolver in project android_frameworks_base by crdroidandroid.
the class FakeSettingsProviderTest method setUp.
@Override
public void setUp() throws Exception {
mCr = new MockContentResolver();
mCr.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
}
use of android.test.mock.MockContentResolver in project android_frameworks_base by AOSPA.
the class TestContext method createStorageTestContext.
/**
* Returns a Context configured with test provider for authority.
*/
static Context createStorageTestContext(Context context, String authority) {
final MockContentResolver testResolver = new MockContentResolver();
TestContentProvider provider = new TestContentProvider();
testResolver.addProvider(authority, provider);
return new ContextWrapper(context) {
@Override
public ContentResolver getContentResolver() {
return testResolver;
}
};
}
use of android.test.mock.MockContentResolver in project android_frameworks_base by AOSPA.
the class ModelTest method setupTestContext.
private void setupTestContext() {
final MockContentResolver resolver = new MockContentResolver();
context = new ContextWrapper(getContext()) {
@Override
public ContentResolver getContentResolver() {
return resolver;
}
};
provider = new TestContentProvider();
resolver.addProvider(AUTHORITY, provider);
}
Aggregations