use of android.test.mock.MockContentResolver in project android_frameworks_base by DirtyUnicorns.
the class TestContext method testPurgeActiveSync.
/**
* Test that we handle the case of a history row being old enough to purge before the
* corresponding sync is finished. This can happen if the clock changes while we are syncing.
*
*/
// TODO: this test causes AidlTest to fail. Omit for now
// @SmallTest
public void testPurgeActiveSync() throws Exception {
final Account account = new Account("a@example.com", "example.type");
final String authority = "testprovider";
MockContentResolver mockResolver = new MockContentResolver();
SyncStorageEngine engine = SyncStorageEngine.newTestInstance(new TestContext(mockResolver, getContext()));
long time0 = 1000;
SyncOperation op = new SyncOperation(account, 0, 0, "foo", SyncOperation.REASON_PERIODIC, SyncStorageEngine.SOURCE_LOCAL, authority, Bundle.EMPTY, true);
long historyId = engine.insertStartSyncEvent(op, time0);
long time1 = time0 + SyncStorageEngine.MILLIS_IN_4WEEKS * 2;
engine.stopSyncEvent(historyId, time1 - time0, "yay", 0, 0);
}
use of android.test.mock.MockContentResolver in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
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);
}
use of android.test.mock.MockContentResolver in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
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;
}
};
}
Aggregations