Hi,
I try to build a class which extends ProviderTestCase2 to test my
content provider.
But I don't know how to connect my content provider and also don't
find any document about this case.
In CalendarProviderTest, they create a Mock Provider and use
mResolver = getMockContentResolver();
mResolver.addProvider
to new a provider.
But I still don't know why they use this method.
My sample code as follows:
@LargeTest
public class ABCProviderTest extends ProviderTestCase2<TaskProvider> {
private SQLiteDatabase mDb;
private Context mContext;
private MockContentResolver mResolver;
public ABCProviderTest () {
super(ABCProvider.class, "com.android.abc.providers");
}
@Override
protected void setUp() throws Exception {
super.setUp();
mContext = getMockContext();
mResolver = getMockContentResolver();
mDb = getProvider().getDatabase();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
public void testProviderColumns() {
Cursor cursor;
Uri url = ABCProvider.CONTENT_URI;
cursor = mResolver.query(url, null, null, null, null);
assertEquals(10, cursor.getColumnCount());
cursor.close();
}
Is there any suggestion about how to connect content provider and test
it by ProviderTestCase2?
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---