summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorZheng Fu <zhengfu@google.com>2015-07-14 17:38:03 -0700
committerZheng Fu <zhengfu@google.com>2015-07-15 16:01:43 -0700
commit772eda381913cc74f9d6f861c4236b95bb75ed9f (patch)
tree5af8c244759abb467f6c63d1d431cb3614fe59f4 /tests
parentcc9ce6b1c8f9d7c4d8b4da96003ce74ccaa636cc (diff)
downloadpackages_providers_ContactsProvider-772eda381913cc74f9d6f861c4236b95bb75ed9f.zip
packages_providers_ContactsProvider-772eda381913cc74f9d6f861c4236b95bb75ed9f.tar.gz
packages_providers_ContactsProvider-772eda381913cc74f9d6f861c4236b95bb75ed9f.tar.bz2
Performance turning for aggregator
1. Move identification matching to secondary 2. In the first stage, do secondary matching only if there is no structured name 3. Aggregate all the raw contacts without structured name if they have matching secondary data 4. Remove approximate name matching in aggregator. (This will not impact the name variant, such as John and Johathan matching) Bug:22200630 Bug:21931859 Change-Id: I295e283dbe1929e20b80272027df226c01bc2f74
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/providers/contacts/aggregation/ContactAggregator2Test.java101
1 files changed, 79 insertions, 22 deletions
diff --git a/tests/src/com/android/providers/contacts/aggregation/ContactAggregator2Test.java b/tests/src/com/android/providers/contacts/aggregation/ContactAggregator2Test.java
index ac64cac..6763412 100644
--- a/tests/src/com/android/providers/contacts/aggregation/ContactAggregator2Test.java
+++ b/tests/src/com/android/providers/contacts/aggregation/ContactAggregator2Test.java
@@ -293,10 +293,16 @@ public class ContactAggregator2Test extends BaseContactsProvider2Test {
long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
insertPhoneNumber(rawContactId1, "(888)555-1231");
- long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_2);
+ long rawContactId2 = RawContactUtil.createRawContactWithName(mResolver, "John", "Doe",
+ ACCOUNT_2);
insertPhoneNumber(rawContactId2, "1(888)555-1231");
+ long rawContactId3 = RawContactUtil.createRawContact(mResolver, ACCOUNT_3);
+ insertPhoneNumber(rawContactId3, "1(888)555-1231");
+
assertNotAggregated(rawContactId1, rawContactId2);
+ assertNotAggregated(rawContactId3, rawContactId2);
+ assertAggregated(rawContactId1, rawContactId3);
}
public void testAggregationBasedOnPhoneNumberWhenTargetAggregateHasNoName() {
@@ -333,26 +339,36 @@ public class ContactAggregator2Test extends BaseContactsProvider2Test {
assertNotAggregated(rawContactId1, rawContactId2);
}
- public void testAggregationBasedOnPhoneNumberWithJustFirstName() {
+ public void testAggregationBasedOnEmailNoNameData() {
long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
- DataUtil.insertStructuredName(mResolver, rawContactId1, "Chick", "Notnull");
- insertPhoneNumber(rawContactId1, "(888)555-1236");
+ insertEmail(rawContactId1, "lightning@android.com");
long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_2);
- DataUtil.insertStructuredName(mResolver, rawContactId2, "Chick", null);
- insertPhoneNumber(rawContactId2, "1(888)555-1236");
+ insertEmail(rawContactId2, "lightning@android.com");
+
+ long rawContactId3 = RawContactUtil.createRawContactWithName(mResolver, "John", "Doe",
+ ACCOUNT_3);
+ insertEmail(rawContactId3, "lightning@android.com");
assertAggregated(rawContactId1, rawContactId2);
+ assertNotAggregated(rawContactId1, rawContactId3);
+ assertNotAggregated(rawContactId2, rawContactId3);
}
- public void testAggregationBasedOnEmailNoNameData() {
+ public void testAggregationByIdentificationNoStructuredNameWithinDifferentAccounts() {
long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
- insertEmail(rawContactId1, "lightning@android.com");
+ insertIdentity(rawContactId1, "jfamily", "google.com");
long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_2);
- insertEmail(rawContactId2, "lightning@android.com");
+ insertIdentity(rawContactId2, "jfamily", "google.com");
- assertNotAggregated(rawContactId1, rawContactId2);
+ long rawContactId3 = RawContactUtil.createRawContactWithName(mResolver, "John", "Doe",
+ ACCOUNT_3);
+ insertIdentity(rawContactId3, "jfamily ", "google.com");
+
+ assertAggregated(rawContactId1, rawContactId2);
+ assertNotAggregated(rawContactId1, rawContactId3);
+ assertNotAggregated(rawContactId2, rawContactId3);
}
public void testAggregationBasedOnEmailWhenTargetAggregateHasNoName() {
@@ -409,16 +425,27 @@ public class ContactAggregator2Test extends BaseContactsProvider2Test {
assertAggregated(rawContactId1, rawContactId2, "Lawrence");
}
- public void testAggregationByNicknameNoStructuredName() {
+ public void testAggregationByNicknameNoStructuredNameWithinSameAccount() {
long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
insertNickname(rawContactId1, "Frozone");
- long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_2);
+ long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
insertNickname(rawContactId2, "Frozone");
assertNotAggregated(rawContactId1, rawContactId2);
}
+ public void testAggregationByNicknameNoStructuredNameWithinDifferentAccounts() {
+ long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
+ insertNickname(rawContactId1, "Frozone");
+
+ long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_2);
+ insertNickname(rawContactId2, "Frozone");
+
+ assertAggregated(rawContactId1, rawContactId2);
+ }
+
+
public void testAggregationByNicknameWithDifferentNames() {
long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
DataUtil.insertStructuredName(mResolver, rawContactId1, "Helen", "Parr");
@@ -445,16 +472,6 @@ public class ContactAggregator2Test extends BaseContactsProvider2Test {
assertNotAggregated(rawContactId1, rawContactId2);
}
- public void testAggregationByIdentity() {
- long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
- insertIdentity(rawContactId1, "iden1", "namespace1");
-
- long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_2);
- insertIdentity(rawContactId2, "iden1", "namespace1");
-
- assertAggregated(rawContactId1, rawContactId2);
- }
-
public void testAggregationExceptionKeepIn() {
long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
DataUtil.insertStructuredName(mResolver, rawContactId1, "Johnk", "Smithk");
@@ -1792,6 +1809,46 @@ public class ContactAggregator2Test extends BaseContactsProvider2Test {
assertNotAggregated(rawContactId4, rawContactId5);
}
+ public void testFamilyMembersWithSimilarNameAndSameHomePhone() {
+ long rawContactId1 = RawContactUtil.createRawContactWithName(mResolver, "John", "Smith",
+ ACCOUNT_1);
+
+ insertPhoneNumber(rawContactId1,"1234", false, 3);
+ insertEmail(rawContactId1, "smithfamily@gmail.com");
+
+ long rawContactId2 = RawContactUtil.createRawContactWithName(mResolver, "Jane", "Smith",
+ ACCOUNT_1);
+ insertPhoneNumber(rawContactId2,"1234", false, 3);
+ insertPhoneNumber(rawContactId2,"8270", false, 4);
+ insertEmail(rawContactId2, "smithfamily@gmail.com");
+
+ long rawContactId3 = RawContactUtil.createRawContactWithName(mResolver, "Karen", "Smith",
+ ACCOUNT_1);
+ insertPhoneNumber(rawContactId3,"1234", false, 3);
+ insertEmail(rawContactId3, "smithfamily@gmail.com");
+
+ assertNotAggregated(rawContactId1, rawContactId2);
+ assertNotAggregated(rawContactId1, rawContactId3);
+ assertNotAggregated(rawContactId2, rawContactId3);
+ }
+
+ public void testNoNameContactsWithSameSecondaryData() {
+ long rawContactId1 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
+
+ insertPhoneNumber(rawContactId1,"1234", false, 3);
+ insertEmail(rawContactId1, "smithfamily@gmail.com");
+
+ long rawContactId2 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
+ insertPhoneNumber(rawContactId2,"1234", false, 3);
+
+ long rawContactId3 = RawContactUtil.createRawContact(mResolver, ACCOUNT_1);
+ insertEmail(rawContactId3, "smithfamily@gmail.com");
+
+ assertAggregated(rawContactId1, rawContactId2);
+ assertAggregated(rawContactId1, rawContactId3);
+ assertAggregated(rawContactId2, rawContactId3);
+ }
+
private void assertSuggestions(long contactId, long... suggestions) {
final Uri aggregateUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
Uri uri = Uri.withAppendedPath(aggregateUri,