本文整理汇总了Java中android.test.mock.MockContentResolver.addProvider方法的典型用法代码示例。如果您正苦于以下问题:Java MockContentResolver.addProvider方法的具体用法?Java MockContentResolver.addProvider怎么用?Java MockContentResolver.addProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.test.mock.MockContentResolver
的用法示例。
在下文中一共展示了MockContentResolver.addProvider方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
MockContentResolver mockContentResolver = new MockContentResolver();
RenamingDelegatingContext targetContext = new RenamingDelegatingContext(
getContext(), getContext(), "test.");
MockContext context = new MockContext(mockContentResolver, targetContext);
MyTracksProvider provider = new MyTracksProvider();
provider.attachInfo(context, null);
mockContentResolver.addProvider(MyTracksProviderUtils.AUTHORITY, provider);
setContext(context);
providerUtils = MyTracksProviderUtils.Factory.get(context);
engine = new SearchEngine(providerUtils);
}
示例2: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
MockContentResolver mockContentResolver = new MockContentResolver();
RenamingDelegatingContext targetContext = new RenamingDelegatingContext(
getContext(), getContext(), "test.");
context = new MockContext(mockContentResolver, targetContext);
MyTracksProvider provider = new MyTracksProvider();
provider.attachInfo(context, null);
mockContentResolver.addProvider(MyTracksProviderUtils.AUTHORITY, provider);
setContext(context);
providerUtils = MyTracksProviderUtils.Factory.get(context);
providerUtils.deleteAllTracks(context);
}
示例3: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
/**
* Sets up the environment for the test fixture.
* <p>
* Creates a new
* {@link android.test.mock.MockContentResolver}, a new IsolatedContext
* that isolates the provider's file operations, and a new instance of
* the provider under test within the isolated environment.
* </p>
*
* @throws Exception
*/
@Override
protected void setUp() throws Exception {
super.setUp();
mResolver = new MockContentResolver();
final String filenamePrefix = "test.";
RenamingDelegatingContext targetContextWrapper = new
RenamingDelegatingContext(
createMockContext(new MockContext2()), // The context that most methods are delegated to
getContext(), // The context that file methods are delegated to
filenamePrefix);
mProviderContext = new IsolatedContext(mResolver, targetContextWrapper);
mProvider = mProviderClass.newInstance();
mProvider.attachInfo(mProviderContext, null);
assertNotNull(mProvider);
mResolver.addProvider(mProviderAuthority, getProvider());
}
示例4: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
File cache = getContext().getCacheDir();
fakeProfileDirectory = new File(cache.getAbsolutePath() + getCacheSuffix());
System.out.println("Test: Creating profile directory " + fakeProfileDirectory.getAbsolutePath());
if (!fakeProfileDirectory.mkdir()) {
throw new IllegalStateException("Could not create temporary directory.");
}
final Context context = getContext();
assertNotNull(context);
resolver = new MockContentResolver();
provider = providerClass.newInstance();
provider.attachInfo(context, null);
assertNotNull(provider);
resolver.addProvider(providerAuthority, getProvider());
}
示例5: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
setContext(InstrumentationRegistry.getTargetContext());
final ProviderInfo providerInfo = new ProviderInfo();
providerInfo.authority = GitHubProvider.AUTHORITY;
contentProvider = new GitHubProvider();
contentProvider.attachInfo(InstrumentationRegistry.getTargetContext(), providerInfo);
contentProvider.delete(GITHUB_REPOSITORIES, null, null);
Thread.sleep(PROVIDER_WAIT_TIME);
final MockContentResolver contentResolver = new MockContentResolver();
contentResolver.addProvider(GitHubProvider.AUTHORITY, contentProvider);
gitHubRepositoryStore = new GitHubRepositoryStore(contentResolver, gson);
testObserver = new TestObserver<>();
super.setUp();
}
示例6: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
setContext(InstrumentationRegistry.getTargetContext());
final ProviderInfo providerInfo = new ProviderInfo();
providerInfo.authority = GitHubProvider.AUTHORITY;
contentProvider = new GitHubProvider();
contentProvider.attachInfo(InstrumentationRegistry.getTargetContext(), providerInfo);
contentProvider.delete(GITHUB_REPOSITORIES, null, null);
Thread.sleep(PROVIDER_WAIT_TIME);
final MockContentResolver contentResolver = new MockContentResolver();
contentResolver.addProvider(GitHubProvider.AUTHORITY, contentProvider);
gitHubRepositoryStoreCore = new GitHubRepositoryStoreCore(contentResolver, new Gson());
super.setUp();
}
示例7: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final MockContentResolver contentResolver = new MockContentResolver();
contentResolver.addProvider("", new AlarmsProvider());
contentResolver.addProvider(".log", new LogProvider());
mContext = getInstrumentation().getContext();
mController = new SkydiveController(new ContextWrapper(mContext) {
@Override
public ContentResolver getContentResolver() {
return contentResolver;
}
});
mFiredAlarms = new ArrayList<Alarm>();
}
示例8: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
MockContentResolver mockContentResolver = new MockContentResolver();
RenamingDelegatingContext targetContext = new RenamingDelegatingContext(
getContext(), getContext(), "test.");
Context context = new MockContext(mockContentResolver, targetContext);
MyTracksProvider myTracksProvider = new MyTracksProvider();
myTracksProvider.attachInfo(context, null);
mockContentResolver.addProvider(MyTracksProviderUtils.AUTHORITY, myTracksProvider);
setContext(context);
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
oldProviderUtilsFactory = TestingProviderUtilsFactory.installWithInstance(
myTracksProviderUtils);
mocksControl = EasyMock.createStrictControl();
trackWriter = mocksControl.createMock(TrackWriter.class);
Track track = new Track();
track.setName(TRACK_NAME);
track.setId(TRACK_ID);
tracks = new Track[] {track};
outputStream = new ByteArrayOutputStream();
TrackExporterListener trackExporterListener = new TrackExporterListener() {
@Override
public void onProgressUpdate(int number, int max) {
// Safe to ignore
}
};
fileTrackExporter = new FileTrackExporter(
myTracksProviderUtils, tracks, trackWriter, trackExporterListener);
}
示例9: TestContext
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
public TestContext() {
super(getInstrumentation().getTargetContext(), "test.");
resolver = new MockContentResolver();
resolver.addProvider(AppProvider.getAuthority(), prepareProvider(new AppProvider()));
resolver.addProvider(ApkProvider.getAuthority(), prepareProvider(new ApkProvider()));
resolver.addProvider(RepoProvider.getAuthority(), prepareProvider(new RepoProvider()));
resolver.addProvider(TempAppProvider.getAuthority(), prepareProvider(new TempAppProvider()));
resolver.addProvider(TempApkProvider.getAuthority(), prepareProvider(new TempApkProvider()));
}
示例10: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
/**
* Sets up the environment for the test fixture.
* <p>
* Creates a new
* {@link android.test.mock.MockContentResolver}, a new IsolatedContext
* that isolates the provider's file operations, and a new instance of
* the provider under test within the isolated environment.
* </p>
*
* @throws Exception
*/
@Override
@Before
protected void setUp() throws Exception {
super.setUp();
mResolver = new MockContentResolver();
final String filenamePrefix = "test.";
final RenamingDelegatingContext targetContextWrapper = new
RenamingDelegatingContext(
createMockContext(new MockContext2()), // The context that most methods are delegated to
getContext(), // The context that file methods are delegated to
filenamePrefix);
mProviderContext = new IsolatedContext(mResolver, new ContextWrapper(targetContextWrapper) {
// The FDroidProvider class needs access to an application context in order to initialize
// the singleton DBHelper instance.
@Override
public Context getApplicationContext() {
return targetContextWrapper;
}
});
mProvider = mProviderClass.newInstance();
mProvider.attachInfo(mProviderContext, null);
assertNotNull(mProvider);
mResolver.addProvider(mProviderAuthority, getProvider());
}
示例11: getMockResolver
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
public ContentResolver getMockResolver() {
final MockContentResolver mockContentResolver = new MockContentResolver(mTargetContext);
for (String authority : mProviders.keySet()) {
mockContentResolver.addProvider(authority, mProviders.get(authority));
}
return mockContentResolver;
}
示例12: initRows
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
private Rows initRows(String[][] data, Filter filter) {
MockContentResolver resolver = new MockContentResolver();
TestContentProvider provider = new TestContentProvider(getContext(), data);
resolver.addProvider(MediaStore.AUTHORITY, provider);
Rows rows = new Rows(resolver, new ParametersStub(), null);
rows.setFilter(filter);
rows.init();
return rows;
}
示例13: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
AndroidMockitoInitializer.setupMockito(this, getContext());
DaggerTestInitializer.addMockModuleToObjectGraph(this);
resolver = new MockContentResolver();
provider = providerClass.newInstance();
provider.attachInfo(getContext().getApplicationContext(), null);
resolver.addProvider(providerAuthority, getProvider());
}
示例14: setUp
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
GuiceInitializer.initialize(this, new AndroidTestCaseInitializationStrategy(this));
resolver = new MockContentResolver();
provider = providerClass.newInstance();
provider.attachInfo(getContext().getApplicationContext(), null);
resolver.addProvider(providerAuthority, getProvider());
}
示例15: utilGetContentResolver
import android.test.mock.MockContentResolver; //导入方法依赖的package包/类
private MockContentResolver utilGetContentResolver()
{
final MockContentResolver mcr = new MockContentResolver();
mcr.addProvider(AmmoMockSchema01.AUTHORITY,
AmmoMockProvider01.getInstance(getContext()));
return mcr;
}