summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2012-06-13 13:08:36 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-13 13:08:36 -0700
commit64ee95a3e48d6f83e338764650c53a915b778cdf (patch)
treed1cab96aade50af44be355c5d373614db3e60e37 /tests
parent2038ce86dc13bff315fa2ec1044a58ddc1f3183b (diff)
parenta499a2adb856223de65d298cd93d70c85afe3d4d (diff)
downloadpackages_providers_ContactsProvider-64ee95a3e48d6f83e338764650c53a915b778cdf.zip
packages_providers_ContactsProvider-64ee95a3e48d6f83e338764650c53a915b778cdf.tar.gz
packages_providers_ContactsProvider-64ee95a3e48d6f83e338764650c53a915b778cdf.tar.bz2
am a499a2ad: Merge "Fix aggregation exception problem"
* commit 'a499a2adb856223de65d298cd93d70c85afe3d4d': Fix aggregation exception problem
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
index 8de5890..795ea9c 100644
--- a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
+++ b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
@@ -537,6 +537,42 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test {
assertEquals("Johnm Smithm", displayName4);
}
+ public void testAggregationExceptionKeepOutCheckResultDisplayNames() {
+ long rawContactId1 = createRawContactWithName("c", "c", ACCOUNT_1);
+ long rawContactId2 = createRawContactWithName("b", "b", ACCOUNT_2);
+ long rawContactId3 = createRawContactWithName("a", "a", ACCOUNT_3);
+
+ // Join all contacts
+ setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER,
+ rawContactId1, rawContactId2);
+ setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER,
+ rawContactId1, rawContactId3);
+ setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER,
+ rawContactId2, rawContactId3);
+
+ // Separate all contacts. The order (2-3 , 1-2, 1-3) is important
+ setAggregationException(AggregationExceptions.TYPE_KEEP_SEPARATE,
+ rawContactId2, rawContactId3);
+ setAggregationException(AggregationExceptions.TYPE_KEEP_SEPARATE,
+ rawContactId1, rawContactId2);
+ setAggregationException(AggregationExceptions.TYPE_KEEP_SEPARATE,
+ rawContactId1, rawContactId3);
+
+ // Verify that we have three different contacts
+ long contactId1 = queryContactId(rawContactId1);
+ long contactId2 = queryContactId(rawContactId2);
+ long contactId3 = queryContactId(rawContactId3);
+
+ assertTrue(contactId1 != contactId2);
+ assertTrue(contactId1 != contactId3);
+ assertTrue(contactId2 != contactId3);
+
+ // Verify that each raw contact contribute to the contact display name
+ assertDisplayNameEquals(contactId1, rawContactId1);
+ assertDisplayNameEquals(contactId2, rawContactId2);
+ assertDisplayNameEquals(contactId3, rawContactId3);
+ }
+
public void testNonAggregationWithMultipleAffinities() {
long rawContactId1 = createRawContactWithName("John", "Doe", ACCOUNT_1);
long rawContactId2 = createRawContactWithName("John", "Doe", ACCOUNT_1);
@@ -1413,4 +1449,18 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test {
cursor.close();
}
+
+ private void assertDisplayNameEquals(long contactId, long rawContactId) {
+
+ String contactDisplayName = queryDisplayName(contactId);
+
+ Cursor c = queryRawContact(rawContactId);
+ assertTrue(c.moveToFirst());
+ String rawDisplayName = c.getString(c.getColumnIndex(RawContacts.DISPLAY_NAME_PRIMARY));
+ c.close();
+
+ assertTrue(contactDisplayName != null);
+ assertTrue(rawDisplayName != null);
+ assertEquals(rawDisplayName, contactDisplayName);
+ }
}