Fix for ContactsTest#testGroupMembershipTable
Check that one of the groups matches the group membership for the
person. There may be multiple groups for the person due to auto
adding groups.
Change-Id: Iee96435c6ce59015f9b82e8b44f747865bb745ce
diff --git a/tests/tests/provider/src/android/provider/cts/ContactsTest.java b/tests/tests/provider/src/android/provider/cts/ContactsTest.java
index fa1e431..1c74b7f 100644
--- a/tests/tests/provider/src/android/provider/cts/ContactsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/ContactsTest.java
@@ -820,10 +820,20 @@
GroupMembership.CONTENT_URI, GROUP_MEMBERSHIP_PROJECTION,
GroupMembership.PERSON_ID + " = " + peopleId,
null, null);
- assertTrue(cursor.moveToNext());
- assertEquals(peopleId, cursor.getInt(PERSON_ID_INDEX));
- assertEquals(groupId1, cursor.getInt(GROUP_ID_INDEX));
- int id = cursor.getInt(ID_INDEX);
+
+ // Check that the person has been associated with the group. The person may be in
+ // additional groups by being added automatically.
+ int id = -1;
+ while(true) {
+ assertTrue(cursor.moveToNext());
+ assertEquals(peopleId, cursor.getInt(PERSON_ID_INDEX));
+ int cursorGroupId = cursor.getInt(GROUP_ID_INDEX);
+ if (groupId1 == cursorGroupId) {
+ id = cursor.getInt(ID_INDEX);
+ break;
+ }
+ }
+ assertTrue(id != -1);
cursor.close();
// Test: update