Add support for identity in attendees
Bug: 6353721
Change-Id: If167941b90b256073444f2660df2360f79872276
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 22cb75b..0ce5105 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,13 +24,16 @@
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
-
+
<!--
The test declared in this instrumentation will be run along with tests declared by
all other applications via the command: "adb shell itr".
The "itr" command will find all tests declared by all applications. If you want to run just these
tests on their own then use the command:
"adb shell am instrument -w com.android.providers.calendar.tests/android.test.InstrumentationTestRunner"
+
+ To test db upgrade:
+ adb shell am instrument -w -e class com.android.providers.calendar.CalendarDatabaseHelperTest#testSchemasEqualForAllTables com.android.providers.calendar.tests/android.test.InstrumentationTestRunner
-->
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.android.providers.calendar"
diff --git a/tests/src/com/android/providers/calendar/CalendarDatabaseHelperTest.java b/tests/src/com/android/providers/calendar/CalendarDatabaseHelperTest.java
index fbd737e..9cb2e28 100644
--- a/tests/src/com/android/providers/calendar/CalendarDatabaseHelperTest.java
+++ b/tests/src/com/android/providers/calendar/CalendarDatabaseHelperTest.java
@@ -464,9 +464,21 @@
"tbl_name,sql" /* orderBy */);
while (goodCursor.moveToNext()) {
- assertTrue("Should have same number of tables", badCursor.moveToNext());
+ String goodTableName = goodCursor.getString(0);
+ // Ignore tables that do not belong to calendar
+ if (goodTableName.startsWith("sqlite_") || goodTableName.equals("android_metadata")) {
+ continue;
+ }
+
+ // Ignore tables that do not belong to calendar
+ String badTableName;
+ do {
+ assertTrue("Should have same number of tables", badCursor.moveToNext());
+ badTableName = badCursor.getString(0);
+ } while (badTableName.startsWith("sqlite_") || badTableName.equals("android_metadata"));
+
assertEquals("Table names different between upgraded schema and freshly-created scheme",
- goodCursor.getString(0), badCursor.getString(0));
+ goodTableName, badTableName);
String badString = badCursor.getString(1);
String goodString = goodCursor.getString(1);
diff --git a/tests/src/com/android/providers/calendar/CalendarProvider2Test.java b/tests/src/com/android/providers/calendar/CalendarProvider2Test.java
index 1be6069..dac3162 100644
--- a/tests/src/com/android/providers/calendar/CalendarProvider2Test.java
+++ b/tests/src/com/android/providers/calendar/CalendarProvider2Test.java
@@ -51,6 +51,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import java.util.TimeZone;
/**
@@ -1867,12 +1868,16 @@
attendee.put(CalendarContract.Attendees.ATTENDEE_RELATIONSHIP,
CalendarContract.Attendees.RELATIONSHIP_ORGANIZER);
attendee.put(CalendarContract.Attendees.EVENT_ID, eventId);
+ attendee.put(CalendarContract.Attendees.ATTENDEE_IDENTITY, "ID1");
+ attendee.put(CalendarContract.Attendees.ATTENDEE_ID_NAMESPACE, "IDNS1");
Uri attendeesUri = mResolver.insert(CalendarContract.Attendees.CONTENT_URI, attendee);
Cursor cursor = mResolver.query(CalendarContract.Attendees.CONTENT_URI, null,
"event_id=" + eventId, null, null);
assertEquals("Created event is missing - cannot find EventUri = " + eventUri, 1,
cursor.getCount());
+ Set<String> attendeeColumns = attendee.keySet();
+ verifyContentValueAgainstCursor(attendee, attendeeColumns, cursor);
cursor.close();
cursor = mResolver.query(eventUri, null, null, null, null);
@@ -1885,11 +1890,23 @@
assertEquals(CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED, selfAttendeeStatus);
cursor.close();
- // Change status to declined
+ // Update status to declined and change identity
+ ContentValues attendeeUpdate = new ContentValues();
+ attendeeUpdate.put(CalendarContract.Attendees.ATTENDEE_IDENTITY, "ID2");
+ attendee.put(CalendarContract.Attendees.ATTENDEE_IDENTITY, "ID2");
+ attendeeUpdate.put(CalendarContract.Attendees.ATTENDEE_STATUS,
+ CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED);
attendee.put(CalendarContract.Attendees.ATTENDEE_STATUS,
CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED);
- mResolver.update(attendeesUri, attendee, null, null);
+ mResolver.update(attendeesUri, attendeeUpdate, null, null);
+ // Check in attendees table
+ cursor = mResolver.query(attendeesUri, null, null, null, null);
+ cursor.moveToNext();
+ verifyContentValueAgainstCursor(attendee, attendeeColumns, cursor);
+ cursor.close();
+
+ // Test that the self status in events table is updated
cursor = mResolver.query(eventUri, null, null, null, null);
cursor.moveToNext();
selfAttendeeStatus = cursor.getInt(selfColumn);
@@ -1915,6 +1932,16 @@
cursor.close();
}
+ private void verifyContentValueAgainstCursor(ContentValues cv,
+ Set<String> keys, Cursor cursor) {
+ cursor.moveToFirst();
+ for (String key : keys) {
+ assertEquals(cv.get(key).toString(),
+ cursor.getString(cursor.getColumnIndex(key)));
+ }
+ cursor.close();
+ }
+
/**
* Test the event's dirty status and clear it.
*