• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IsolatedContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.test.IsolatedContext的典型用法代码示例。如果您正苦于以下问题:Java IsolatedContext类的具体用法?Java IsolatedContext怎么用?Java IsolatedContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IsolatedContext类属于android.test包,在下文中一共展示了IsolatedContext类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createTables

import android.test.IsolatedContext; //导入依赖的package包/类
private SQLiteDatabase createTables(final boolean delete, final UniversalSearchContract.Table... tables) {
    SQLiteDatabase db = null;
    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);
    final Context context = new IsolatedContext(super.getContext().getContentResolver(), targetContextWrapper);
    try {
        db = context.openOrCreateDatabase(DATABASE, 1, null);
        for (final UniversalSearchContract.Table table : tables) {
            table.onCreate(db);
            log("Table " + table + " onCreate successful");
        }
        return db;
    } finally {
        if (null != db && delete) {
            db.close();
            context.deleteDatabase(DATABASE);
        }
    }
}
 
开发者ID:googlecodelabs,项目名称:android-tv-leanback,代码行数:25,代码来源:UniversalSearchContractTest.java


示例2: setUpContentProvider

import android.test.IsolatedContext; //导入依赖的package包/类
private void setUpContentProvider(ContentProvider targetProvider) throws Exception {
    mResolver = new ChangeRecordingMockContentResolver();

    final String filenamePrefix = this.getClass().getSimpleName() + ".";
    RenamingDelegatingContext targetContextWrapper =
            new RenamingDelegatingContext(
                new ContentProviderMockContext(),
                (Context)getActivity(),
                filenamePrefix);

    mProviderContext = new IsolatedContext(mResolver, targetContextWrapper);

    targetProvider.attachInfo(mProviderContext, null);

    mProvider = new DelegatingTestContentProvider(targetProvider);
    mProvider.attachInfo(mProviderContext, null);

    mResolver.addProvider(mProviderAuthority, mProvider);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:20,代码来源:ContentProviderTest.java


示例3: XmlPullParserTest

import android.test.IsolatedContext; //导入依赖的package包/类
public XmlPullParserTest() {
	String root = "http://tomas-vondracek.net/Data/upload/test/";
	String xml1 = "akcie_cz_rss.xml";
	String xml2 = "patria_cz_rss.xml";
	String xml3 = "cyrrus_cz_rss.xml";
	try {
		this.dataUrl1 = new URL(root + xml1);
		this.dataUrl2 = new URL(root + xml2);
		this.dataUrl3 = new URL(root + xml3);
	} catch (MalformedURLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	this.feed = new Feed();
	this.feed.setCountryCode("cz");
	this.feed.setFeedId(0);
	this.feed.setTitle("xml test feed");
	this.feed.setUrl(this.dataUrl1);
	
	this.context = new IsolatedContext(new MockContentResolver(), getContext());
}
 
开发者ID:kultus,项目名称:StockAnalyze,代码行数:23,代码来源:XmlPullParserTest.java


示例4: setUp

import android.test.IsolatedContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
	super.setUp();

	Context context = new IsolatedContext(new MockContentResolver(), getContext());
	this.portfolio = new Portfolio(context);
}
 
开发者ID:kultus,项目名称:StockAnalyze,代码行数:8,代码来源:PortfolioTest.java


示例5: setUp

import android.test.IsolatedContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
	super.setUp();
	
	this.context = new IsolatedContext(new MockContentResolver(), getContext());
	sqlStore = StockDataSqlStore.getInstance(this.context);
	ConnectivityManager connectivity = (ConnectivityManager) this.context.getSystemService(Context.CONNECTIVITY_SERVICE);
	
	this.dataManager = DataManager.getInstance(context);
}
 
开发者ID:kultus,项目名称:StockAnalyze,代码行数:11,代码来源:DataManagerTest.java


示例6: setUp

import android.test.IsolatedContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
	super.setUp();
	if (this.infrastructure == null) {
		this.infrastructure = new Infrastructure(new IsolatedContext(new MockContentResolver(), getContext()));
	}
}
 
开发者ID:kultus,项目名称:StockAnalyze,代码行数:8,代码来源:ChartinfrastructureTest.java


示例7: testClearBut

import android.test.IsolatedContext; //导入依赖的package包/类
public void testClearBut() throws Exception {
    // We need a package name in this test, thus creating our own mock context
    final IsolatedContext context = getProviderMockContext();

    assertTrue(mProviderHelper.persist(MODULE_A, KEY_A, STRING_A));
    assertTrue(mProviderHelper.persist(MODULE_A, KEY_B, STRING_B));
    assertTrue(mProviderHelper.persist(MODULE_B, KEY_A, STRING_A));
    assertTrue(mProviderHelper.persist(MODULE_B, KEY_B, STRING_B));
    assertTrue(mProviderHelper.persist(MODULE_C, KEY_A, STRING_A));
    assertTrue(mProviderHelper.persist(MODULE_C, KEY_B, STRING_B));
    assertTrue(mProviderHelper.persist(context.getPackageName(), KEY_A, STRING_A));
    assertTrue(mProviderHelper.persist(context.getPackageName(), KEY_B, STRING_B));
    assertUserDatabaseSize(8);

    mProviderHelper.clearBut(new AppPreferences(context),
            new TestTrayModulePreferences(context, MODULE_A),
            new TestTrayModulePreferences(context, MODULE_B));
    assertUserDatabaseSize(6);

    mProviderHelper.clearBut(new TestTrayModulePreferences(context, MODULE_A),
            new TestTrayModulePreferences(context, MODULE_B));
    assertUserDatabaseSize(4);

    mProviderHelper.clearBut(new TestTrayModulePreferences(context, MODULE_A));
    assertUserDatabaseSize(2);

    mProviderHelper.clearBut((TrayPreferences) null);
    assertUserDatabaseSize(0);

    assertTrue(mProviderHelper.persist(MODULE_A, KEY_A, STRING_A));
    assertTrue(mProviderHelper.persist(MODULE_A, KEY_B, STRING_B));
    assertTrue(mProviderHelper.persist(context.getPackageName(), KEY_A, STRING_A));
    assertTrue(mProviderHelper.persist(context.getPackageName(), KEY_B, STRING_B));
    mProviderHelper.clearBut(new AppPreferences(context));
    assertUserDatabaseSize(2);

    // Also test empty values (= clear everything)
    assertTrue(mProviderHelper.persist(MODULE_A, KEY_A, STRING_A));
    assertTrue(mProviderHelper.persist(MODULE_A, KEY_B, STRING_B));

    mProviderHelper.clearBut((TrayPreferences) null);
    assertUserDatabaseSize(0);
}
 
开发者ID:grandcentrix,项目名称:tray,代码行数:44,代码来源:TrayProviderHelperTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SearchResultEvent类代码示例发布时间:2022-05-22
下一篇:
Java ProviderId类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap