Code example for RenamingDelegatingContext

0
    protected Context targetContext;
 
    @Override 
    protected void setUp() { 
        // Run tests in an isolated context 
        targetContext = new RenamingDelegatingContext(getInstrumentation().getTargetContext(), "test_");
        testContext = getInstrumentation().getContext();
    } 
 
    public void testLoadDB() { 
        SQLiteDatabase db = TestUtils.loadDBFromDump(targetContext, testContext,
                "one_category.sql"); 
        CategoryNode node = CategoryNode.createCategoryTreeFromDB(1);
        // At least 1 category exists in test db: malformed_category_parent_id.sql 
        assertTrue((node.getChildren().size() != 0));
        db.close();
    } 
 
    public void testLoadDB_MalformedCategoryParentId() { 
        SQLiteDatabase db = TestUtils.loadDBFromDump(targetContext, testContext,
                "malformed_category_parent_id.sql");