diff options
author | Brian Attwell <brianattwell@google.com> | 2015-02-03 22:07:29 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-02-03 22:07:29 +0000 |
commit | 0f6927a6946350dcb3031baa9ce1c7575f48307e (patch) | |
tree | cc8181b268797a37c7174c9d755a6810fdf30d09 /tests | |
parent | abaa423fa15f00b07b9c92c16ee186c909cac145 (diff) | |
parent | ec22e2147d07c8a6de7fabeb0c45d22e844d0e6e (diff) | |
download | packages_providers_ContactsProvider-0f6927a6946350dcb3031baa9ce1c7575f48307e.zip packages_providers_ContactsProvider-0f6927a6946350dcb3031baa9ce1c7575f48307e.tar.gz packages_providers_ContactsProvider-0f6927a6946350dcb3031baa9ce1c7575f48307e.tar.bz2 |
Merge "Additional change to IS_SUPER_PRIMARY" into lmp-mr1-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java | 18 | ||||
-rw-r--r-- | tests/src/com/android/providers/contacts/testutil/DataUtil.java | 14 |
2 files changed, 31 insertions, 1 deletions
diff --git a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java index 78f1b80..0e0264c 100644 --- a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java +++ b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java @@ -1620,6 +1620,24 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test { assertSuperPrimary(ContentUris.parseId(uri_org2), false); } + public void testAggregation_clearSuperPrimarySingleMimetype() { + // Setup: two raw contacts, each has a single name. One of the names is super primary. + long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1); + long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1); + final Uri uri = DataUtil.insertStructuredName(mResolver, rawContactId1, "name1", + null, null, /* isSuperPrimary = */ true); + + // Sanity check. + assertStoredValue(uri, Data.IS_SUPER_PRIMARY, 1); + + // Action: aggregate + setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER, rawContactId1, + rawContactId2); + + // Verify: name is still super primary + assertStoredValue(uri, Data.IS_SUPER_PRIMARY, 1); + } + public void testNotAggregate_TooManyRawContactsInCandidate() { long preId= 0; for (int i = 0; i < ContactAggregator.AGGREGATION_CONTACT_SIZE_LIMIT; i++) { diff --git a/tests/src/com/android/providers/contacts/testutil/DataUtil.java b/tests/src/com/android/providers/contacts/testutil/DataUtil.java index 194e67d..1f4f35a 100644 --- a/tests/src/com/android/providers/contacts/testutil/DataUtil.java +++ b/tests/src/com/android/providers/contacts/testutil/DataUtil.java @@ -22,6 +22,7 @@ import android.content.ContentValues; import android.net.Uri; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.StructuredName; +import android.provider.ContactsContract.Data; import android.test.mock.MockContentResolver; /** @@ -59,6 +60,13 @@ public class DataUtil { public static Uri insertStructuredName( ContentResolver resolver, long rawContactId, String givenName, String familyName, String phoneticGiven) { + return insertStructuredName(resolver, rawContactId, givenName, familyName, phoneticGiven, + /* isSuperPrimary = true */ false); + } + + public static Uri insertStructuredName( + ContentResolver resolver, long rawContactId, String givenName, String familyName, + String phoneticGiven, boolean isSuperPrimary) { ContentValues values = new ContentValues(); StringBuilder sb = new StringBuilder(); if (givenName != null) { @@ -79,7 +87,11 @@ public class DataUtil { if (phoneticGiven != null) { values.put(StructuredName.PHONETIC_GIVEN_NAME, phoneticGiven); } + if (isSuperPrimary) { + values.put(Data.IS_PRIMARY, 1); + values.put(Data.IS_SUPER_PRIMARY, 1); + } return insertStructuredName(resolver, rawContactId, values); } -} +}
\ No newline at end of file |