diff options
author | Daniel Lehmann <lehmannd@google.com> | 2010-07-13 17:41:49 -0700 |
---|---|---|
committer | Daniel Lehmann <lehmannd@google.com> | 2010-07-13 17:50:07 -0700 |
commit | ca98444277723c60be83062cf5a25ec7ca1fdb34 (patch) | |
tree | 909178ecf23224f32cca077f56e0b221d8235144 /tests | |
parent | 2776c7fe8117773fdf773396f61ed047238470f9 (diff) | |
download | packages_apps_Contacts-ca98444277723c60be83062cf5a25ec7ca1fdb34.tar.gz packages_apps_Contacts-ca98444277723c60be83062cf5a25ec7ca1fdb34.tar.bz2 packages_apps_Contacts-ca98444277723c60be83062cf5a25ec7ca1fdb34.zip |
Instant save in the Editor; renamed EntitySet to EntityDeltaList
Change-Id: Ib4b57e76db346bec38dcf294d895f13d4b2fc6d3
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/contacts/EntityDeltaListTests.java (renamed from tests/src/com/android/contacts/EntitySetTests.java) | 92 | ||||
-rw-r--r-- | tests/src/com/android/contacts/EntityModifierTests.java | 56 |
2 files changed, 74 insertions, 74 deletions
diff --git a/tests/src/com/android/contacts/EntitySetTests.java b/tests/src/com/android/contacts/EntityDeltaListTests.java index edfca6d0d..efd843fb3 100644 --- a/tests/src/com/android/contacts/EntitySetTests.java +++ b/tests/src/com/android/contacts/EntityDeltaListTests.java @@ -25,7 +25,7 @@ import com.android.contacts.EntityModifierTests.MockContactsSource; import com.android.contacts.model.ContactsSource; import com.android.contacts.model.EntityDelta; import com.android.contacts.model.EntityModifier; -import com.android.contacts.model.EntitySet; +import com.android.contacts.model.EntityDeltaList; import com.android.contacts.model.EntityDelta.ValuesDelta; import com.google.android.collect.Lists; @@ -46,12 +46,12 @@ import java.lang.reflect.Field; import java.util.ArrayList; /** - * Tests for {@link EntitySet} which focus on "diff" operations that should + * Tests for {@link EntityDeltaList} which focus on "diff" operations that should * create {@link AggregationExceptions} in certain cases. */ @LargeTest -public class EntitySetTests extends AndroidTestCase { - public static final String TAG = "EntitySetTests"; +public class EntityDeltaListTests extends AndroidTestCase { + public static final String TAG = "EntityDeltaListTests"; private static final long CONTACT_FIRST = 1; private static final long CONTACT_SECOND = 2; @@ -71,7 +71,7 @@ public class EntitySetTests extends AndroidTestCase { public static final String TEST_PHONE = "555-1212"; public static final String TEST_ACCOUNT = "org.example.test"; - public EntitySetTests() { + public EntityDeltaListTests() { super(); } @@ -112,8 +112,8 @@ public class EntitySetTests extends AndroidTestCase { return new EntityDelta(values); } - static EntitySet buildSet(EntityDelta... deltas) { - final EntitySet set = EntitySet.fromSingle(deltas[0]); + static EntityDeltaList buildSet(EntityDelta... deltas) { + final EntityDeltaList set = EntityDeltaList.fromSingle(deltas[0]); for (int i = 1; i < deltas.length; i++) { set.add(deltas[i]); } @@ -166,12 +166,12 @@ public class EntitySetTests extends AndroidTestCase { return values; } - static void insertPhone(EntitySet set, long rawContactId, ContentValues values) { + static void insertPhone(EntityDeltaList set, long rawContactId, ContentValues values) { final EntityDelta match = set.getByRawContactId(rawContactId); match.addEntry(ValuesDelta.fromAfter(values)); } - static ValuesDelta getPhone(EntitySet set, long rawContactId, long dataId) { + static ValuesDelta getPhone(EntityDeltaList set, long rawContactId, long dataId) { final EntityDelta match = set.getByRawContactId(rawContactId); return match.getEntry(dataId); } @@ -183,7 +183,7 @@ public class EntitySetTests extends AndroidTestCase { assertDiffPattern(diff, pattern); } - static void assertDiffPattern(EntitySet set, ContentProviderOperation... pattern) { + static void assertDiffPattern(EntityDeltaList set, ContentProviderOperation... pattern) { assertDiffPattern(set.buildDiff(), pattern); } @@ -283,7 +283,7 @@ public class EntitySetTests extends AndroidTestCase { return null; } - static Long getVersion(EntitySet set, Long rawContactId) { + static Long getVersion(EntityDeltaList set, Long rawContactId) { return set.getByRawContactId(rawContactId).getValues().getAsLong(RawContacts.VERSION); } @@ -304,7 +304,7 @@ public class EntitySetTests extends AndroidTestCase { public void testInsert() { final EntityDelta insert = getInsert(); - final EntitySet set = buildSet(insert); + final EntityDeltaList set = buildSet(insert); // Inserting single shouldn't create rules final ArrayList<ContentProviderOperation> diff = set.buildDiff(); @@ -315,7 +315,7 @@ public class EntitySetTests extends AndroidTestCase { public void testUpdateUpdate() { final EntityDelta updateFirst = getUpdate(CONTACT_FIRST); final EntityDelta updateSecond = getUpdate(CONTACT_SECOND); - final EntitySet set = buildSet(updateFirst, updateSecond); + final EntityDeltaList set = buildSet(updateFirst, updateSecond); // Updating two existing shouldn't create rules final ArrayList<ContentProviderOperation> diff = set.buildDiff(); @@ -326,7 +326,7 @@ public class EntitySetTests extends AndroidTestCase { public void testUpdateInsert() { final EntityDelta update = getUpdate(CONTACT_FIRST); final EntityDelta insert = getInsert(); - final EntitySet set = buildSet(update, insert); + final EntityDeltaList set = buildSet(update, insert); // New insert should only create one rule final ArrayList<ContentProviderOperation> diff = set.buildDiff(); @@ -338,7 +338,7 @@ public class EntitySetTests extends AndroidTestCase { final EntityDelta insertFirst = getInsert(); final EntityDelta update = getUpdate(CONTACT_FIRST); final EntityDelta insertSecond = getInsert(); - final EntitySet set = buildSet(insertFirst, update, insertSecond); + final EntityDeltaList set = buildSet(insertFirst, update, insertSecond); // Two inserts should create two rules to bind against single existing final ArrayList<ContentProviderOperation> diff = set.buildDiff(); @@ -350,7 +350,7 @@ public class EntitySetTests extends AndroidTestCase { final EntityDelta insertFirst = getInsert(); final EntityDelta insertSecond = getInsert(); final EntityDelta insertThird = getInsert(); - final EntitySet set = buildSet(insertFirst, insertSecond, insertThird); + final EntityDeltaList set = buildSet(insertFirst, insertSecond, insertThird); // Three new inserts should create only two binding rules final ArrayList<ContentProviderOperation> diff = set.buildDiff(); @@ -359,20 +359,20 @@ public class EntitySetTests extends AndroidTestCase { } public void testMergeDataRemoteInsert() { - final EntitySet first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, + final EntityDeltaList first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, buildPhone(PHONE_RED))); - final EntitySet second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, + final EntityDeltaList second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, buildPhone(PHONE_RED), buildPhone(PHONE_GREEN))); // Merge in second version, verify they match - final EntitySet merged = EntitySet.mergeAfter(second, first); + final EntityDeltaList merged = EntityDeltaList.mergeAfter(second, first); assertEquals("Unexpected change when merging", second, merged); } public void testMergeDataLocalUpdateRemoteInsert() { - final EntitySet first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, + final EntityDeltaList first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, buildPhone(PHONE_RED))); - final EntitySet second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, + final EntityDeltaList second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, buildPhone(PHONE_RED), buildPhone(PHONE_GREEN))); // Change the local number to trigger update @@ -386,7 +386,7 @@ public class EntitySetTests extends AndroidTestCase { buildUpdateAggregationDefault()); // Merge in the second version, verify diff matches - final EntitySet merged = EntitySet.mergeAfter(second, first); + final EntityDeltaList merged = EntityDeltaList.mergeAfter(second, first); assertDiffPattern(merged, buildAssertVersion(VER_SECOND), buildUpdateAggregationSuspended(), @@ -395,9 +395,9 @@ public class EntitySetTests extends AndroidTestCase { } public void testMergeDataLocalUpdateRemoteDelete() { - final EntitySet first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, + final EntityDeltaList first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, buildPhone(PHONE_RED))); - final EntitySet second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, + final EntityDeltaList second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, buildPhone(PHONE_GREEN))); // Change the local number to trigger update @@ -412,7 +412,7 @@ public class EntitySetTests extends AndroidTestCase { // Merge in the second version, verify that our update changed to // insert, since RED was deleted on remote side - final EntitySet merged = EntitySet.mergeAfter(second, first); + final EntityDeltaList merged = EntityDeltaList.mergeAfter(second, first); assertDiffPattern(merged, buildAssertVersion(VER_SECOND), buildUpdateAggregationSuspended(), @@ -421,9 +421,9 @@ public class EntitySetTests extends AndroidTestCase { } public void testMergeDataLocalDeleteRemoteUpdate() { - final EntitySet first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, + final EntityDeltaList first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, buildPhone(PHONE_RED))); - final EntitySet second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, + final EntityDeltaList second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, buildPhone(PHONE_RED, TEST_PHONE))); // Delete phone locally @@ -437,7 +437,7 @@ public class EntitySetTests extends AndroidTestCase { buildUpdateAggregationDefault()); // Merge in the second version, verify that our delete remains - final EntitySet merged = EntitySet.mergeAfter(second, first); + final EntityDeltaList merged = EntityDeltaList.mergeAfter(second, first); assertDiffPattern(merged, buildAssertVersion(VER_SECOND), buildUpdateAggregationSuspended(), @@ -446,9 +446,9 @@ public class EntitySetTests extends AndroidTestCase { } public void testMergeDataLocalInsertRemoteInsert() { - final EntitySet first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, + final EntityDeltaList first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, buildPhone(PHONE_RED))); - final EntitySet second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, + final EntityDeltaList second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, buildPhone(PHONE_RED), buildPhone(PHONE_GREEN))); // Insert new phone locally @@ -461,7 +461,7 @@ public class EntitySetTests extends AndroidTestCase { buildUpdateAggregationDefault()); // Merge in the second version, verify that our insert remains - final EntitySet merged = EntitySet.mergeAfter(second, first); + final EntityDeltaList merged = EntityDeltaList.mergeAfter(second, first); assertDiffPattern(merged, buildAssertVersion(VER_SECOND), buildUpdateAggregationSuspended(), @@ -470,9 +470,9 @@ public class EntitySetTests extends AndroidTestCase { } public void testMergeRawContactLocalInsertRemoteInsert() { - final EntitySet first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, + final EntityDeltaList first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, buildPhone(PHONE_RED))); - final EntitySet second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, + final EntityDeltaList second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, buildPhone(PHONE_RED)), buildBeforeEntity(CONTACT_MARY, VER_SECOND, buildPhone(PHONE_RED))); @@ -490,7 +490,7 @@ public class EntitySetTests extends AndroidTestCase { buildUpdateAggregationKeepTogether(CONTACT_BOB)); // Merge in the second version, verify that our insert remains - final EntitySet merged = EntitySet.mergeAfter(second, first); + final EntityDeltaList merged = EntityDeltaList.mergeAfter(second, first); assertDiffPattern(merged, buildAssertVersion(VER_SECOND), buildAssertVersion(VER_SECOND), @@ -501,10 +501,10 @@ public class EntitySetTests extends AndroidTestCase { } public void testMergeRawContactLocalDeleteRemoteDelete() { - final EntitySet first = buildSet( + final EntityDeltaList first = buildSet( buildBeforeEntity(CONTACT_BOB, VER_FIRST, buildPhone(PHONE_RED)), buildBeforeEntity(CONTACT_MARY, VER_FIRST, buildPhone(PHONE_RED))); - final EntitySet second = buildSet( + final EntityDeltaList second = buildSet( buildBeforeEntity(CONTACT_BOB, VER_SECOND, buildPhone(PHONE_RED))); // Remove contact locally @@ -515,15 +515,15 @@ public class EntitySetTests extends AndroidTestCase { buildDelete(RawContacts.CONTENT_URI)); // Merge in the second version, verify that our delete isn't needed - final EntitySet merged = EntitySet.mergeAfter(second, first); + final EntityDeltaList merged = EntityDeltaList.mergeAfter(second, first); assertDiffPattern(merged); } public void testMergeRawContactLocalUpdateRemoteDelete() { - final EntitySet first = buildSet( + final EntityDeltaList first = buildSet( buildBeforeEntity(CONTACT_BOB, VER_FIRST, buildPhone(PHONE_RED)), buildBeforeEntity(CONTACT_MARY, VER_FIRST, buildPhone(PHONE_RED))); - final EntitySet second = buildSet( + final EntityDeltaList second = buildSet( buildBeforeEntity(CONTACT_BOB, VER_SECOND, buildPhone(PHONE_RED))); // Perform local update @@ -542,7 +542,7 @@ public class EntitySetTests extends AndroidTestCase { contactInsert.put(RawContacts.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_SUSPENDED); // Merge and verify that update turned into insert - final EntitySet merged = EntitySet.mergeAfter(second, first); + final EntityDeltaList merged = EntityDeltaList.mergeAfter(second, first); assertDiffPattern(merged, buildAssertVersion(VER_SECOND), buildOper(RawContacts.CONTENT_URI, TYPE_INSERT, contactInsert), @@ -552,22 +552,22 @@ public class EntitySetTests extends AndroidTestCase { } public void testMergeUsesNewVersion() { - final EntitySet first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, + final EntityDeltaList first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, buildPhone(PHONE_RED))); - final EntitySet second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, + final EntityDeltaList second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, buildPhone(PHONE_RED))); assertEquals((Long)VER_FIRST, getVersion(first, CONTACT_BOB)); assertEquals((Long)VER_SECOND, getVersion(second, CONTACT_BOB)); - final EntitySet merged = EntitySet.mergeAfter(second, first); + final EntityDeltaList merged = EntityDeltaList.mergeAfter(second, first); assertEquals((Long)VER_SECOND, getVersion(merged, CONTACT_BOB)); } public void testMergeAfterEnsureAndTrim() { - final EntitySet first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, + final EntityDeltaList first = buildSet(buildBeforeEntity(CONTACT_BOB, VER_FIRST, buildEmail(EMAIL_YELLOW))); - final EntitySet second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, + final EntityDeltaList second = buildSet(buildBeforeEntity(CONTACT_BOB, VER_SECOND, buildEmail(EMAIL_YELLOW))); // Ensure we have at least one phone @@ -588,7 +588,7 @@ public class EntitySetTests extends AndroidTestCase { assertDiffPattern(first); // Now re-parent the change, which should remain no-op - final EntitySet merged = EntitySet.mergeAfter(second, first); + final EntityDeltaList merged = EntityDeltaList.mergeAfter(second, first); assertDiffPattern(merged); } } diff --git a/tests/src/com/android/contacts/EntityModifierTests.java b/tests/src/com/android/contacts/EntityModifierTests.java index 18877a301..af3681529 100644 --- a/tests/src/com/android/contacts/EntityModifierTests.java +++ b/tests/src/com/android/contacts/EntityModifierTests.java @@ -23,7 +23,7 @@ import static android.content.ContentProviderOperation.TYPE_UPDATE; import com.android.contacts.model.ContactsSource; import com.android.contacts.model.EntityDelta; import com.android.contacts.model.EntityModifier; -import com.android.contacts.model.EntitySet; +import com.android.contacts.model.EntityDeltaList; import com.android.contacts.model.Sources; import com.android.contacts.model.ContactsSource.DataKind; import com.android.contacts.model.ContactsSource.EditType; @@ -376,23 +376,23 @@ public class EntityModifierTests extends AndroidTestCase { final EditType typeHome = EntityModifier.getType(kindPhone, Phone.TYPE_HOME); // Test row that has type values, but values are spaces - final EntityDelta state = EntitySetTests.buildBeforeEntity(TEST_ID, VER_FIRST); + final EntityDelta state = EntityDeltaListTests.buildBeforeEntity(TEST_ID, VER_FIRST); final ValuesDelta values = EntityModifier.insertChild(state, kindPhone, typeHome); values.put(Phone.NUMBER, " "); // Build diff, expecting insert for data row and update enforcement - EntitySetTests.assertDiffPattern(state, - EntitySetTests.buildAssertVersion(VER_FIRST), - EntitySetTests.buildUpdateAggregationSuspended(), - EntitySetTests.buildOper(Data.CONTENT_URI, TYPE_INSERT, - EntitySetTests.buildDataInsert(values, TEST_ID)), - EntitySetTests.buildUpdateAggregationDefault()); + EntityDeltaListTests.assertDiffPattern(state, + EntityDeltaListTests.buildAssertVersion(VER_FIRST), + EntityDeltaListTests.buildUpdateAggregationSuspended(), + EntityDeltaListTests.buildOper(Data.CONTENT_URI, TYPE_INSERT, + EntityDeltaListTests.buildDataInsert(values, TEST_ID)), + EntityDeltaListTests.buildUpdateAggregationDefault()); // Trim empty rows and try again, expecting delete of overall contact EntityModifier.trimEmpty(state, source); - EntitySetTests.assertDiffPattern(state, - EntitySetTests.buildAssertVersion(VER_FIRST), - EntitySetTests.buildDelete(RawContacts.CONTENT_URI)); + EntityDeltaListTests.assertDiffPattern(state, + EntityDeltaListTests.buildAssertVersion(VER_FIRST), + EntityDeltaListTests.buildDelete(RawContacts.CONTENT_URI)); } public void testTrimLeaveValid() { @@ -401,26 +401,26 @@ public class EntityModifierTests extends AndroidTestCase { final EditType typeHome = EntityModifier.getType(kindPhone, Phone.TYPE_HOME); // Test row that has type values with valid number - final EntityDelta state = EntitySetTests.buildBeforeEntity(TEST_ID, VER_FIRST); + final EntityDelta state = EntityDeltaListTests.buildBeforeEntity(TEST_ID, VER_FIRST); final ValuesDelta values = EntityModifier.insertChild(state, kindPhone, typeHome); values.put(Phone.NUMBER, TEST_PHONE); // Build diff, expecting insert for data row and update enforcement - EntitySetTests.assertDiffPattern(state, - EntitySetTests.buildAssertVersion(VER_FIRST), - EntitySetTests.buildUpdateAggregationSuspended(), - EntitySetTests.buildOper(Data.CONTENT_URI, TYPE_INSERT, - EntitySetTests.buildDataInsert(values, TEST_ID)), - EntitySetTests.buildUpdateAggregationDefault()); + EntityDeltaListTests.assertDiffPattern(state, + EntityDeltaListTests.buildAssertVersion(VER_FIRST), + EntityDeltaListTests.buildUpdateAggregationSuspended(), + EntityDeltaListTests.buildOper(Data.CONTENT_URI, TYPE_INSERT, + EntityDeltaListTests.buildDataInsert(values, TEST_ID)), + EntityDeltaListTests.buildUpdateAggregationDefault()); // Trim empty rows and try again, expecting no differences EntityModifier.trimEmpty(state, source); - EntitySetTests.assertDiffPattern(state, - EntitySetTests.buildAssertVersion(VER_FIRST), - EntitySetTests.buildUpdateAggregationSuspended(), - EntitySetTests.buildOper(Data.CONTENT_URI, TYPE_INSERT, - EntitySetTests.buildDataInsert(values, TEST_ID)), - EntitySetTests.buildUpdateAggregationDefault()); + EntityDeltaListTests.assertDiffPattern(state, + EntityDeltaListTests.buildAssertVersion(VER_FIRST), + EntityDeltaListTests.buildUpdateAggregationSuspended(), + EntityDeltaListTests.buildOper(Data.CONTENT_URI, TYPE_INSERT, + EntityDeltaListTests.buildDataInsert(values, TEST_ID)), + EntityDeltaListTests.buildUpdateAggregationDefault()); } public void testTrimEmptyUntouched() { @@ -507,7 +507,7 @@ public class EntityModifierTests extends AndroidTestCase { // Try creating a contact without any child entries final EntityDelta state = getEntity(null); - final EntitySet set = EntitySet.fromSingle(state); + final EntityDeltaList set = EntityDeltaList.fromSingle(state); // Build diff, expecting single insert final ArrayList<ContentProviderOperation> diff = Lists.newArrayList(); @@ -535,7 +535,7 @@ public class EntityModifierTests extends AndroidTestCase { // Try creating a contact with single empty entry final EntityDelta state = getEntity(null); final ValuesDelta values = EntityModifier.insertChild(state, kindPhone, typeHome); - final EntitySet set = EntitySet.fromSingle(state); + final EntityDeltaList set = EntityDeltaList.fromSingle(state); // Build diff, expecting two insert operations final ArrayList<ContentProviderOperation> diff = Lists.newArrayList(); @@ -579,7 +579,7 @@ public class EntityModifierTests extends AndroidTestCase { second.put(Phone.NUMBER, TEST_PHONE); final EntityDelta state = getEntity(TEST_ID, first, second); - final EntitySet set = EntitySet.fromSingle(state); + final EntityDeltaList set = EntityDeltaList.fromSingle(state); // Build diff, expecting no changes final ArrayList<ContentProviderOperation> diff = Lists.newArrayList(); @@ -644,7 +644,7 @@ public class EntityModifierTests extends AndroidTestCase { first.put(Phone.NUMBER, TEST_PHONE); final EntityDelta state = getEntity(TEST_ID, first); - final EntitySet set = EntitySet.fromSingle(state); + final EntityDeltaList set = EntityDeltaList.fromSingle(state); // Build diff, expecting no changes final ArrayList<ContentProviderOperation> diff = Lists.newArrayList(); |