当前位置: 首页>>代码示例>>Java>>正文


Java MockContentResolver.addProvider方法代码示例

本文整理汇总了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);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:17,代码来源:SearchEngineTest.java

示例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);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:17,代码来源:MyTracksProviderUtilsImplTest.java

示例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());
}
 
开发者ID:nutellarlz,项目名称:AppHub,代码行数:30,代码来源:ProviderTestCase2MockContext.java

示例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());
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:20,代码来源:DBProviderTestCase.java

示例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();
}
 
开发者ID:reark,项目名称:reark,代码行数:23,代码来源:GitHubRepositoryStoreTest.java

示例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();
}
 
开发者ID:reark,项目名称:reark,代码行数:22,代码来源:GitHubRepositoryStoreCoreTest.java

示例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>();
}
 
开发者ID:aulanov,项目名称:altidroid,代码行数:19,代码来源:SkydiveControllerTest.java

示例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);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:38,代码来源:FileTrackExporterTest.java

示例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()));
}
 
开发者ID:CmDnoEdition,项目名称:fdroid,代码行数:11,代码来源:MultiRepoUpdaterTest.java

示例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());
}
 
开发者ID:CmDnoEdition,项目名称:fdroid,代码行数:39,代码来源:ProviderTestCase2MockContext.java

示例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;
}
 
开发者ID:grandcentrix,项目名称:tray,代码行数:8,代码来源:TrayProviderTestCase.java

示例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;
}
 
开发者ID:souch,项目名称:SMP,代码行数:10,代码来源:RowsTest.java

示例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());
}
 
开发者ID:jeske717,项目名称:injected-test-runner,代码行数:11,代码来源:InjectedContentProviderTestCase.java

示例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());
}
 
开发者ID:jeske717,项目名称:injected-test-runner,代码行数:10,代码来源:InjectedContentProviderTestCase.java

示例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;
}
 
开发者ID:vuisis-ammo,项目名称:ammo-core,代码行数:9,代码来源:JsonSerializerTest.java


注:本文中的android.test.mock.MockContentResolver.addProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。