diff options
| author | Marc Blank <mblank@google.com> | 2010-02-23 14:37:28 -0800 |
|---|---|---|
| committer | Marc Blank <mblank@google.com> | 2010-02-24 15:13:57 -0800 |
| commit | 89be77eaea65211fea0ca32efd538318c7e049b3 (patch) | |
| tree | 7abb9498db584537512fde4c0aac18e1a1a7e470 /tests | |
| parent | 438dfe64ec2cccbd929edb74c7436851dacfce56 (diff) | |
| download | android_packages_apps_Email-89be77eaea65211fea0ca32efd538318c7e049b3.tar.gz android_packages_apps_Email-89be77eaea65211fea0ca32efd538318c7e049b3.tar.bz2 android_packages_apps_Email-89be77eaea65211fea0ca32efd538318c7e049b3.zip | |
Send replies to exchange meeting requests
* When the user selects accept/decline/tentative in MessageView, we now send
an email to the organizer, with an iCalendar attachment indicating the reply
* Added a unit test for the reply case, but more tests to be added to handle
other circumstances
Change-Id: Iff799d88a92b6546735bf4965b22febf3a82b56f
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java index e8155a824..9ff3db55e 100644 --- a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java +++ b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java @@ -16,6 +16,16 @@ package com.android.exchange.utility; +import com.android.email.R; +import com.android.email.mail.Address; +import com.android.email.provider.EmailContent.Account; +import com.android.email.provider.EmailContent.Attachment; +import com.android.email.provider.EmailContent.Message; + +import android.content.ContentValues; +import android.content.Entity; +import android.provider.Calendar.Attendees; +import android.provider.Calendar.Events; import android.test.AndroidTestCase; import java.util.Calendar; @@ -95,7 +105,7 @@ public class CalendarUtilitiesTests extends AndroidTestCase { } public void testRecurrenceUntilToEasUntil() { - // Test full format + // Test full formatCC assertEquals("YYYY-MM-DDTHH:MM:SS.000Z", CalendarUtilities.recurrenceUntilToEasUntil("YYYYMMDDTHHMMSSZ")); // Test date only format @@ -133,6 +143,72 @@ public class CalendarUtilitiesTests extends AndroidTestCase { assertEquals(cal.get(Calendar.SECOND), 17); } + public void testCreateMessageForEntity_Reply() { + // Create an Entity for an Event + ContentValues entityValues = new ContentValues(); + Entity entity = new Entity(entityValues); + + // Set up values for the Event + String attendee = "attendee@server.com"; + String organizer = "organizer@server.com"; + String location = "Meeting Location"; + String title = "Discuss Unit Tests"; + + // Fill in times, location, title, and organizer + entityValues.put("DTSTAMP", + CalendarUtilities.convertEmailDateTimeToCalendarDateTime("2010-04-05T14:30:51Z")); + entityValues.put(Events.DTSTART, + CalendarUtilities.parseEmailDateTimeToMillis("2010-04-12T18:30:00Z")); + entityValues.put(Events.DTEND, + CalendarUtilities.parseEmailDateTimeToMillis("2010-04-12T19:30:00Z")); + entityValues.put(Events.EVENT_LOCATION, location); + entityValues.put(Events.TITLE, title); + entityValues.put(Events.ORGANIZER, organizer); + + // Add the attendee + ContentValues attendeeValues = new ContentValues(); + attendeeValues.put(Attendees.ATTENDEE_RELATIONSHIP, Attendees.RELATIONSHIP_ATTENDEE); + attendeeValues.put(Attendees.ATTENDEE_EMAIL, attendee); + entity.addSubValue(Attendees.CONTENT_URI, attendeeValues); + + // Add the organizer + ContentValues organizerValues = new ContentValues(); + organizerValues.put(Attendees.ATTENDEE_RELATIONSHIP, Attendees.RELATIONSHIP_ORGANIZER); + organizerValues.put(Attendees.ATTENDEE_EMAIL, organizer); + entity.addSubValue(Attendees.CONTENT_URI, organizerValues); + + String uid = "31415926535"; + Account account = new Account(); + + // The attendee is responding + account.mEmailAddress = attendee; + + // Create the outgoing message + Message msg = CalendarUtilities.createMessageForEntity(mContext, entity, + Message.FLAG_OUTGOING_MEETING_ACCEPT, uid, account); + + // First, we should have a message + assertNotNull(msg); + + // Now check some of the fields of the message + assertEquals(Address.pack(new Address[] {new Address(organizer)}), msg.mTo); + String accept = getContext().getResources().getString(R.string.meeting_accepted); + assertEquals(accept + ": " + title, msg.mSubject); + + // And make sure we have an attachment + assertNotNull(msg.mAttachments); + assertEquals(1, msg.mAttachments.size()); + Attachment att = msg.mAttachments.get(0); + // And that the attachment has the correct elements + assertEquals("invite.ics", att.mFileName); + assertEquals(Attachment.FLAG_SUPPRESS_DISPOSITION, + att.mFlags & Attachment.FLAG_SUPPRESS_DISPOSITION); + assertEquals("text/calendar; method=REPLY", att.mMimeType); + assertNotNull(att.mContent); + + //TODO Check the contents of the attachment using an iCalendar parser + } + // Tests in progress... // public void testTimeZoneToTziString() { |
