forked from malintha/gsoc-14
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-imip.patch
183 lines (182 loc) · 6.19 KB
/
test-imip.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# HG changeset patch
# Parent 239bf16df29626650ea4ea4a82bd86363dcb818a
diff -r 239bf16df296 mail/test/mozmill/calendar/test-imip.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/test/mozmill/calendar/test-imip.js Tue May 20 06:29:40 2014 +0530
@@ -0,0 +1,176 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+var MODULE_NAME = 'test-imip';
+var RELATIVE_ROOT = '../shared-modules';
+var MODULE_REQUIRES = ['folder-display-helpers',
+ 'window-helpers','calendar-utils','compose-helpers','prompt-helpers'];
+var calUtils = require("../shared-modules/calendar-utils");
+var folder;
+var os = {};
+Components.utils.import('resource://mozmill/stdlib/os.js', os);
+const sleep = 500;
+
+//Create the text/calendar attachment to be injected
+const invitationAttachment = [
+ "BEGIN:VCALENDAR",
+ "PRODID:-//Inverse inc./SOGo 2.1.1b//EN",
+ "VERSION:2.0",
+ "CALSCALE:GREGORIAN",
+ "METHOD:REQUEST",
+ "BEGIN:VEVENT",
+ "DTSTART:20140515T050000Z",
+ "DTEND:20140515T063000Z",
+ "DTSTAMP:20140514T034846Z",
+ "RRULE:FREQ=3DYEARLY;BYMONTH=3D3;BYDAY=3D2SU",
+ "ORGANIZER;CN=John Doe:mailto:[email protected]",
+ "UID:576-53715980-1-5E904600",
+ "CLASS:PUBLIC",
+ "ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Tinderbox;X-NUM-GUESTS=0:mailto:[email protected]",
+ "ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE;CN=John Doeo;X-NUM-GUESTS=0:mailto:[email protected]",
+ "LOCATION:Hell",
+ "SEQUENCE:0",
+ "STATUS:CONFIRMED",
+ "SUMMARY:IMIP testing event",
+ "TRANSP:OPAQUE",
+ "CREATED:20140511T112534Z",
+ "END:VEVENT",
+ "END:VCALENDAR" ]
+ .join("\r\n");
+
+/**
+ * initialize modules and inject the email with attachment
+ */
+
+function setupModule(module) {
+ controller = mozmill.getMail3PaneController();
+ let fdh = collector.getModule('folder-display-helpers');
+ fdh.installInto(module);
+ let ch = collector.getModule("compose-helpers");
+ ch.installInto(module);
+ let wh = collector.getModule('window-helpers');
+ wh.installInto(module);
+
+ collector.getModule("prompt-helpers").installInto(module);
+ folder = create_folder('ImipFolder');
+ messenger = Components.classes['@mozilla.org/messenger;1']
+ .createInstance(Components.interfaces.nsIMessenger);
+
+ let msg = create_message(
+ {
+ from : [ "malintha", "[email protected]" ],
+ to : [ "Tinderbox", "[email protected]" ],
+ subject : [ "Invitation: TestingEvent @ Sun May 11, 2014 10am - 11am ([email protected])" ],
+ body : {
+ to : "[email protected]",
+ body : "",
+ subject : "Customized: TestingEvent @ Sun May 11, 2014 10am - 11am"
+ },
+ attachments : [ {
+ from : [ "John Doe", "[email protected]" ],
+ to : [ "Tinderbox", "[email protected]" ],
+ contentType : 'text/calendar',
+ MIMEVersion : '1.0',
+ method : 'REQUEST',
+ messageId : 'CAGFBr6MY94cd_PFW5zxkAxjubHpW1OgsurjWdFKpZDmjh4VTaw@mail.gmail.com',
+ charset : 'UTF-8',
+ body : invitationAttachment,
+ filename : 'invite.ics',
+ format : ''
+ } ]
+
+ });
+ add_message_to_folder(folder, msg);
+}
+
+/**
+ * move to the folder, display the message and check whether IMIP bar accept button is showed up.
+ * try{}/catch{} is for, accepting any exceptions throw when accepting the invitation by trying to send out emails.
+ */
+function testAcceptREQUEST() {
+ be_in_folder(folder);
+ select_click_row(0);
+ assert_selected_and_displayed(0);
+ controller.sleep(sleep);
+ let btnAccept = new elementslib.ID(controller.window.document, "imipAcceptButton");
+ gMockPromptService.register();
+ //assert for existence of the accept button.
+ controller.assertNode(btnAccept);
+ //to return the value for not send email notifications button on the dialog
+ gMockPromptService.returnValue = 1;
+ try{
+ promptState = gMockPromptService.promptState;
+ controller.click(btnAccept);
+ }
+ catch(e){}
+ gMockPromptService.unregister();
+}
+
+/**
+ * check whether event is added to the right slot and assert to make sure properties remain the same.
+ */
+function testEvent() {
+ // check for the event injected by mail
+ controller.click(new elementslib.ID(controller.window.document,
+ "calendar-tab-button"));
+ calUtils.switchToView(controller, "day");
+ calUtils.goToDate(controller, 2014, 5, 15);
+ controller.sleep(sleep);
+
+ // make sure event was added to the right position
+ controller.assertNode(new elementslib.Lookup(controller.window.document,
+ calUtils.getEventBoxPath(controller, "day", calUtils.CANVAS_BOX,
+ undefined, 1, 11)));
+ /*
+ * element.occurence didn't work for me. Appeared it didn't return any calendar
+ * properties.
+ */
+
+ controller.doubleClick(new elementslib.Lookup(controller.window.document,
+ calUtils.getEventBoxPath(controller, "day", calUtils.CANVAS_BOX,
+ undefined, 1, 11)));
+ controller
+ .waitFor(
+ function() {
+ return mozmill.utils
+ .getWindows("Calendar:EventSummaryDialog").length > 0
+ }, sleep);
+ controller.sleep(sleep);
+ let
+ event = new mozmill.controller.MozMillController(mozmill.utils
+ .getWindows("Calendar:EventSummaryDialog")[0]);
+
+ // check title
+ let title = new elementslib.ID(event.window.document, "item-title");
+ controller.assertValue(title, "IMIP testing event");
+
+ // check organizer
+ let organizer = new elementslib.ID(event.window.document, "item-organizer");
+ controller.assertValue(organizer, "John Doe");
+
+ // check location
+ let location = new elementslib.ID(event.window.document, "item-location");
+ controller.assertValue(location, "Hell");
+
+ // press escape to close Event-Summary-Dialog
+ event.keypress(undefined, "VK_ESCAPE", {});
+}
+
+/**
+ * Delete the event from calendar
+ */
+function testDeleteEvent() {
+ gMockPromptService.register();
+ gMockPromptService.returnValue = 1;
+ calUtils.goToDate(controller, 2014, 5, 15);
+ controller.sleep(sleep);
+ try {
+ promptState = gMockPromptService.promptState;
+ controller.keypress(new elementslib.ID(controller.window.document,
+ "day-view"), "VK_DELETE", {});
+ } catch (e) {
+ }
+ gMockPromptService.unregister();
+}