diff options
author | Brian Attwell <brianattwell@google.com> | 2015-01-27 19:07:27 -0800 |
---|---|---|
committer | Brian Attwell <brianattwell@google.com> | 2015-01-30 14:53:53 -0800 |
commit | f256a7cf7f78d5ff2573358eb2eadd6f3a2ec9db (patch) | |
tree | 8a309aa80ec9e908f5ee104207fe4ffd17c522f7 /tests | |
parent | aa7951f3147076cbcb70ec85bb4351600378806a (diff) | |
download | packages_providers_ContactsProvider-f256a7cf7f78d5ff2573358eb2eadd6f3a2ec9db.zip packages_providers_ContactsProvider-f256a7cf7f78d5ff2573358eb2eadd6f3a2ec9db.tar.gz packages_providers_ContactsProvider-f256a7cf7f78d5ff2573358eb2eadd6f3a2ec9db.tar.bz2 |
Remove NAME_VERIFIED. Part3
Support use of IS_SUPER_PRIMARY instead of NAME_VERIFIED.
The contact aggregator now pays attention to
IS_SUPER_PRIMARY.
Remove all references to NAME_VERIFIED from CP2.
Bug: 18777272
Change-Id: I1579a3122b2d45b80de7106a2b9616e323855045
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/providers/contacts/ContactsProvider2Test.java | 4 | ||||
-rw-r--r-- | tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java | 83 |
2 files changed, 64 insertions, 23 deletions
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java index 482a072..d8dc737 100644 --- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java +++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java @@ -318,7 +318,6 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { RawContacts.DISPLAY_NAME_SOURCE, RawContacts.PHONETIC_NAME, RawContacts.PHONETIC_NAME_STYLE, - RawContacts.NAME_VERIFIED, RawContacts.SORT_KEY_PRIMARY, RawContacts.SORT_KEY_ALTERNATIVE, RawContactsColumns.PHONEBOOK_LABEL_PRIMARY, @@ -384,7 +383,6 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { RawContacts.SOURCE_ID, RawContacts.VERSION, RawContacts.DIRTY, - RawContacts.NAME_VERIFIED, RawContacts.RAW_CONTACT_IS_USER_PROFILE, Contacts._ID, Contacts.DISPLAY_NAME_PRIMARY, @@ -550,7 +548,6 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { RawContacts.VERSION, RawContacts.DELETED, RawContacts.DIRTY, - RawContacts.NAME_VERIFIED, RawContacts.SYNC1, RawContacts.SYNC2, RawContacts.SYNC3, @@ -609,7 +606,6 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { RawContacts.SOURCE_ID, RawContacts.VERSION, RawContacts.DIRTY, - RawContacts.NAME_VERIFIED, RawContacts.DELETED, RawContacts.SYNC1, RawContacts.SYNC2, diff --git a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java index c8e6810..204875b 100644 --- a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java +++ b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java @@ -1315,34 +1315,79 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test { assertEquals("Eclair Android", queryDisplayName(contactId)); } - public void testVerifiedName() { - long rawContactId1 = RawContactUtil.createRawContactWithName(mResolver, "test1", "TEST1", - ACCOUNT_1); - storeValue(RawContacts.CONTENT_URI, rawContactId1, RawContacts.NAME_VERIFIED, "1"); - long rawContactId2 = RawContactUtil.createRawContactWithName(mResolver, "test2", "TEST2", - ACCOUNT_2); - long rawContactId3 = RawContactUtil.createRawContactWithName(mResolver, "test3", - "TEST3 LONG", ACCOUNT_3); + public void testMergeSuperPrimaryName_rawContact1() { + // Setup: raw contact #1 has a super primary name. #2 doesn't. + long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1); + DataUtil.insertStructuredName(mResolver, rawContactId1, "name1", null, null, + /* isSuperPrimary = */ true); + long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1); + DataUtil.insertStructuredName(mResolver, rawContactId2, "name2", null, null, + /* isSuperPrimary = */ false); + // Action: aggregate setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER, rawContactId1, rawContactId2); + + // Verify: the aggregate's name comes from raw contact #1 + long contactId = queryContactId(rawContactId1); + assertEquals("name1", queryDisplayName(contactId)); + } + + public void testMergeSuperPrimaryName_rawContact2AndEdit() { + // Setup: raw contact #2 has a super primary name. #1 doesn't. + long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1); + final Uri nameUri1 = DataUtil.insertStructuredName(mResolver, rawContactId1, "name1", + null, null, /* isSuperPrimary = */ false); + long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1); + final Uri nameUri2 = DataUtil.insertStructuredName(mResolver, rawContactId2, "name2", null, + null, /* isSuperPrimary = */ true); + + // Action: aggregate setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER, rawContactId1, - rawContactId3); + rawContactId2); + // Verify: the aggregate's name comes from raw contact #2. This is the opposite of the check + // inside testMergeSuperPrimaryName_rawContact1(). long contactId = queryContactId(rawContactId1); + assertEquals("name2", queryDisplayName(contactId)); - // Should be the verified name - assertEquals("test1 TEST1", queryDisplayName(contactId)); + // Action: edit the super primary name + final ContentValues values = new ContentValues(); + values.put(StructuredName.GIVEN_NAME, "edited name"); + mResolver.update(nameUri2, values, null, null); - // Mark a different name as verified - this should reset the NAME_VERIFIED field - // for the other rawContacts - storeValue(RawContacts.CONTENT_URI, rawContactId2, RawContacts.NAME_VERIFIED, "1"); - assertStoredValue(RawContacts.CONTENT_URI, rawContactId1, RawContacts.NAME_VERIFIED, 0); - assertEquals("test2 TEST2", queryDisplayName(contactId)); + // Verify: editing the super primary name affects aggregate name + assertEquals("edited name", queryDisplayName(contactId)); - // Reset the NAME_VERIFIED flag - now the most complex of the three names should win - storeValue(RawContacts.CONTENT_URI, rawContactId2, RawContacts.NAME_VERIFIED, "0"); - assertEquals("test3 TEST3 LONG", queryDisplayName(contactId)); + // Action: edit the non primary name + values.put(StructuredName.GIVEN_NAME, "edited name2"); + mResolver.update(nameUri1, values, null, null); + + // Verify: aggregate name is still based off the primary name + assertEquals("edited name", queryDisplayName(contactId)); + } + + public void testMergedSuperPrimaryName_changeSuperPrimary() { + // Setup: aggregated contact where raw contact #1 has a super primary name. #2 doesn't. + long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1); + final Uri nameUri1 = DataUtil.insertStructuredName(mResolver, rawContactId1, "name1", + null, null, /* isSuperPrimary = */ true); + long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1); + final Uri nameUri2 = DataUtil.insertStructuredName(mResolver, rawContactId2, "name2", null, + null, /* isSuperPrimary = */ false); + setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER, rawContactId1, + rawContactId2); + + // Action: make raw contact 2's name super primary + storeValue(nameUri2, Data.IS_SUPER_PRIMARY, 1); + + // Sanity check. + assertStoredValue(nameUri1, Data.IS_SUPER_PRIMARY, 0); + assertStoredValue(nameUri2, Data.IS_SUPER_PRIMARY, 1); + + // Verify: aggregate name is based off of the newly super primary name + long contactId = queryContactId(rawContactId1); + assertEquals("name2", queryDisplayName(contactId)); } public void testAggregationModeSuspendedSeparateTransactions() { |