UriMatcherTestpublic class UriMatcherTest extends TestCase
Fields Summary |
---|
static final int | ROOT | static final int | PEOPLE | static final int | PEOPLE_ID | static final int | PEOPLE_PHONES | static final int | PEOPLE_PHONES_ID | static final int | PEOPLE_ADDRESSES | static final int | PEOPLE_ADDRESSES_ID | static final int | PEOPLE_CONTACTMETH | static final int | PEOPLE_CONTACTMETH_ID | static final int | CALLS | static final int | CALLS_ID | static final int | CALLERID | static final int | CALLERID_TEXT | static final int | FILTERRECENT | private static final android.content.UriMatcher | mURLMatcher |
Methods Summary |
---|
void | check(java.lang.String uri, int expected)
mURLMatcher.addURI("people", null, PEOPLE);
mURLMatcher.addURI("people", "#", PEOPLE_ID);
mURLMatcher.addURI("people", "#/phones", PEOPLE_PHONES);
mURLMatcher.addURI("people", "#/phones/blah", PEOPLE_PHONES_ID);
mURLMatcher.addURI("people", "#/phones/#", PEOPLE_PHONES_ID);
mURLMatcher.addURI("people", "#/addresses", PEOPLE_ADDRESSES);
mURLMatcher.addURI("people", "#/addresses/#", PEOPLE_ADDRESSES_ID);
mURLMatcher.addURI("people", "#/contact-methods", PEOPLE_CONTACTMETH);
mURLMatcher.addURI("people", "#/contact-methods/#", PEOPLE_CONTACTMETH_ID);
mURLMatcher.addURI("calls", null, CALLS);
mURLMatcher.addURI("calls", "#", CALLS_ID);
mURLMatcher.addURI("caller-id", null, CALLERID);
mURLMatcher.addURI("caller-id", "*", CALLERID_TEXT);
mURLMatcher.addURI("filter-recent", null, FILTERRECENT);
int result = mURLMatcher.match(Uri.parse(uri));
if (result != expected) {
String msg = "failed on " + uri;
msg += " expected " + expected + " got " + result;
throw new RuntimeException(msg);
}
| public void | testContentUris()
check("content://asdf", UriMatcher.NO_MATCH);
check("content://people", PEOPLE);
check("content://people/1", PEOPLE_ID);
check("content://people/asdf", UriMatcher.NO_MATCH);
check("content://people/2/phones", PEOPLE_PHONES);
check("content://people/2/phones/3", PEOPLE_PHONES_ID);
check("content://people/2/phones/asdf", UriMatcher.NO_MATCH);
check("content://people/2/addresses", PEOPLE_ADDRESSES);
check("content://people/2/addresses/3", PEOPLE_ADDRESSES_ID);
check("content://people/2/addresses/asdf", UriMatcher.NO_MATCH);
check("content://people/2/contact-methods", PEOPLE_CONTACTMETH);
check("content://people/2/contact-methods/3", PEOPLE_CONTACTMETH_ID);
check("content://people/2/contact-methods/asdf", UriMatcher.NO_MATCH);
check("content://calls", CALLS);
check("content://calls/1", CALLS_ID);
check("content://calls/asdf", UriMatcher.NO_MATCH);
check("content://caller-id", CALLERID);
check("content://caller-id/asdf", CALLERID_TEXT);
check("content://caller-id/1", CALLERID_TEXT);
check("content://filter-recent", FILTERRECENT);
|
|