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


Java IsolatedContext类代码示例

本文整理汇总了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;未经允许,请勿转载。