diff options
Diffstat (limited to 'tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java')
-rw-r--r-- | tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java b/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java index b90e88b..ed0c06d 100644 --- a/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java +++ b/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java @@ -232,16 +232,24 @@ public abstract class BaseContactsProvider2Test extends PhotoLoadingTestCase { } protected Uri insertOrganization(long rawContactId, ContentValues values) { - return insertOrganization(rawContactId, values, false); + return insertOrganization(rawContactId, values, false, false); } protected Uri insertOrganization(long rawContactId, ContentValues values, boolean primary) { + return insertOrganization(rawContactId, values, primary, false); + } + + protected Uri insertOrganization(long rawContactId, ContentValues values, boolean primary, + boolean superPrimary) { values.put(Data.RAW_CONTACT_ID, rawContactId); values.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); values.put(Organization.TYPE, Organization.TYPE_WORK); if (primary) { values.put(Data.IS_PRIMARY, 1); } + if (superPrimary) { + values.put(Data.IS_SUPER_PRIMARY, 1); + } Uri resultUri = mResolver.insert(Data.CONTENT_URI, values); return resultUri; @@ -252,11 +260,21 @@ public abstract class BaseContactsProvider2Test extends PhotoLoadingTestCase { } protected Uri insertPhoneNumber(long rawContactId, String phoneNumber, boolean primary) { - return insertPhoneNumber(rawContactId, phoneNumber, primary, Phone.TYPE_HOME); + return insertPhoneNumber(rawContactId, phoneNumber, primary, false, Phone.TYPE_HOME); + } + + protected Uri insertPhoneNumber(long rawContactId, String phoneNumber, boolean primary, + boolean superPrimary) { + return insertPhoneNumber(rawContactId, phoneNumber, primary, superPrimary, Phone.TYPE_HOME); } protected Uri insertPhoneNumber(long rawContactId, String phoneNumber, boolean primary, int type) { + return insertPhoneNumber(rawContactId, phoneNumber, primary, false, type); + } + + protected Uri insertPhoneNumber(long rawContactId, String phoneNumber, boolean primary, + boolean superPrimary, int type) { ContentValues values = new ContentValues(); values.put(Data.RAW_CONTACT_ID, rawContactId); values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); @@ -265,6 +283,9 @@ public abstract class BaseContactsProvider2Test extends PhotoLoadingTestCase { if (primary) { values.put(Data.IS_PRIMARY, 1); } + if (superPrimary) { + values.put(Data.IS_SUPER_PRIMARY, 1); + } Uri resultUri = mResolver.insert(Data.CONTENT_URI, values); return resultUri; @@ -712,6 +733,20 @@ public abstract class BaseContactsProvider2Test extends PhotoLoadingTestCase { } } + protected void assertSuperPrimary(Long dataId, boolean isSuperPrimary) { + final String[] projection = new String[]{Data.MIMETYPE, Data._ID, Data.IS_SUPER_PRIMARY}; + Cursor c = mResolver.query(ContentUris.withAppendedId(Data.CONTENT_URI, dataId), + projection, null, null, null); + + c.moveToFirst(); + if (isSuperPrimary) { + assertEquals(1, c.getInt(c.getColumnIndexOrThrow(Data.IS_SUPER_PRIMARY))); + } else { + assertEquals(0, c.getInt(c.getColumnIndexOrThrow(Data.IS_SUPER_PRIMARY))); + } + + } + protected void assertDataRow(ContentValues actual, String expectedMimetype, Object... expectedArguments) { assertEquals(actual.toString(), expectedMimetype, actual.getAsString(Data.MIMETYPE)); |