Bug 1718282 - Replace invoke*() functions with CalendarTestUtils equivalents. r=darktrojan

Differential Revision: https://phabricator.services.mozilla.com/D119457
This commit is contained in:
Lasana Murray 2021-07-12 22:34:34 +00:00
Родитель 20a9e2f2f4
Коммит 1593f374a8
21 изменённых файлов: 555 добавлений и 747 удалений

Просмотреть файл

@ -74,8 +74,8 @@ class CalendarDayViewTestUtils {
}
/**
* Provides the element located at the specified hour, which can be double
* clicked to create a new event at the specified hour.
* Provides the .calendar-event-column-linebox element for the specified hour.
* This element can be double clicked to create a new event at that hour.
*
* @param {Window} win - The window the calendar is displayed in.
* @param {number} hour - Must be between 0-23.
@ -257,9 +257,8 @@ class CalendarWeekViewTestUtils {
}
/**
* Provides the .multiday-column-bg-box element located at the specified
* hour, which can be double clicked to create a new event at the specified
* hour.
* Provides the .calendar-event-column-linebox element for the specified hour.
* This element can be double clicked to create a new event at that hour.
*
* @param {Window} win - The window the calendar is displayed in.
* @param {number} day - Day of the week, between 1-7.
@ -785,6 +784,54 @@ const CalendarTestUtils = {
return promise;
},
async _editNewItem(win, target, type) {
let dialogPromise = CalendarTestUtils.waitForEventDialog("edit");
if (target) {
target.scrollIntoView();
EventUtils.synthesizeMouse(target, 1, 1, { clickCount: 2 }, win);
} else {
EventUtils.synthesizeMouseAtCenter(
win.document.getElementById(`calendar-new${type}-button`),
{},
win
);
}
let dialogWindow = await dialogPromise;
let iframe = dialogWindow.document.querySelector("#calendar-item-panel-iframe");
Assert.report(false, undefined, undefined, "New event dialog opened");
return {
dialogWindow,
dialogDocument: dialogWindow.document,
iframeWindow: iframe.contentWindow,
iframeDocument: iframe.contentDocument,
};
},
/**
* Opens the dialog for editing a new event. An optional day/week view
* hour box or multiweek/month view calendar-month-day-box can be specified
* to simulate creation of the event at that target.
*
* @param {Window} win - The window containing the calendar.
* @param {XULElement?} target - The <spacer> or <calendar-month-day-box>
* to click on, if not specified, the new event
* button is used.
*/
async editNewEvent(win, target) {
return this._editNewItem(win, target, "event");
},
/**
* Opens the dialog for editing a new task.
*
* @param {Window} win - The window containing the task tree.
*/
async editNewTask(win) {
return this._editNewItem(win, null, "task");
},
async _editItem(win, item, selector) {
let summaryWin = await this.viewItem(win, item);
let promise = this.waitForEventDialog("edit");

Просмотреть файл

@ -11,11 +11,6 @@ const EXPORTED_SYMBOLS = [
"switchToView",
"goToDate",
"goToToday",
"invokeNewEventDialog",
"invokeNewTaskDialog",
"invokeViewingEventDialog",
"invokeEditingEventDialog",
"invokeEditingRepeatEventDialog",
"execEventDialogCallback",
"ensureViewLoaded",
"checkMonthAlarmIcon",
@ -30,7 +25,6 @@ const EXPORTED_SYMBOLS = [
];
var { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm");
var { BrowserTestUtils } = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
var { CalendarTestUtils } = ChromeUtils.import(
"resource://testing-common/calendar/CalendarTestUtils.jsm"
);
@ -193,161 +187,6 @@ function goToToday(controller) {
ensureViewLoaded(controller);
}
/**
* This callback should close the dialog when finished.
* @callback EventDialogCallback
* @param {Window} dialogWindow - Item dialog outer window.
* @param {Window} iframeWindow - Item dialog inner iframe.
* @returns {Promise}
*/
/**
* Opens a new event dialog by clicking on the (optional) box and executing the
* callback function.
*
* NOTE: This function will timeout if the "clickBox" opens an existing event,
* use the other invoke*EventDialog() functions for existing events instead.
*
* @param {Window} window - The main window.
* @param {Element|null} clickBox - The optional box to click on.
* @param {EventDialogCallback} callback - The function to execute while the
* event dialog is open.
*/
async function invokeNewEventDialog(window, clickBox, callback) {
let eventWindowPromise = CalendarTestUtils.waitForEventDialog("edit");
if (clickBox) {
doubleClickOptionalEventBox(window, clickBox);
} else {
window.document.getElementById("calendar-new-event-menuitem").click();
}
await eventWindowPromise;
Assert.report(false, undefined, undefined, "New event dialog opened");
await execEventDialogCallback(callback);
}
/**
* Opens a new task dialog by clicking on the (optional) box and executing the
* callback function.
*
* NOTE: This function will timeout if the "clickBox" opens an existing task,
* use the other invoke*EventDialog() functions for existing tasks instead.
*
* @param {Window} window - The main window.
* @param {Element|null} clickBox - The optional box to click on.
* @param {EventDialogCallback} callback - The function to execute while the
* task dialog is open.
*/
async function invokeNewTaskDialog(window, clickBox, callback) {
let taskWindowPromise = CalendarTestUtils.waitForEventDialog("edit");
if (clickBox) {
doubleClickOptionalEventBox(window, clickBox);
} else {
window.document.getElementById("calendar-new-task-menuitem").click();
}
await taskWindowPromise;
Assert.report(false, undefined, undefined, "New task dialog opened");
await execEventDialogCallback(callback);
}
/**
* This callback should close the dialog when finished.
* @callback EventSummaryDialogCallback
* @param {Window} window - The event summary window.
* @returns {Promise}
*/
/**
* Opens an existing event in the event summary dialog by clicking on the
* (optional) box and executing the callback function.
*
* NOTE: This function will timeout if the "clickBox" opens a new event
* instead of an existing one.
*
* @param {Window} window - The main window.
* @param {Element|null} clickBox - The optional box to click on.
* @param {EventSummaryDialogCallback} callback - The function to execute while
* the event summary dialog is
* open.
*/
async function invokeViewingEventDialog(window, clickBox, callback) {
let summaryWindowPromise = CalendarTestUtils.waitForEventDialog();
doubleClickOptionalEventBox(window, clickBox);
let summaryWindow = await summaryWindowPromise;
Assert.report(false, undefined, undefined, "Summary dialog opened");
await callback(summaryWindow);
await BrowserTestUtils.windowClosed(summaryWindow);
Assert.report(false, undefined, undefined, "Summary dialog closed");
}
/**
* Opens an existing event for editing in the event dialog by clicking on the
* (optional) box and executing the callback function.
*
* NOTE: This function will timeout if the "clickBox" opens a new event instead
* of an existing one.
*
* @param {Window} window - The main window.
* @param {Element|null} clickBox - The box to click on.
* @param {EventDialogCallback} callback - The function to execute while the
* event dialog is open.
*/
async function invokeEditingEventDialog(window, clickBox, callback) {
let eventWindowPromise = CalendarTestUtils.waitForEventDialog();
doubleClickOptionalEventBox(window, clickBox);
let eventWindow = await eventWindowPromise;
Assert.report(false, undefined, undefined, "Edit event dialog opened");
await new Promise(resolve => eventWindow.setTimeout(resolve, 500));
EventUtils.synthesizeMouseAtCenter(
eventWindow.document.querySelector("dialog").getButton("accept"),
{},
eventWindow
);
await execEventDialogCallback(callback);
}
/**
* Opens an existing, repeating event for editing in the event dialog by
* clicking on the (optional) box and executing the callback function.
*
* NOTE: This function will timeout if the "clickBox" opens a new event instead
* of an existing one.
*
* @param {Window} window - The main window.
* @param {Element|null} clickBox - The box to click on.
* @param {EventDialogCallback} callback - The function to execute while the
* event dialog is open.
* @param {boolean} [editAll=false] - If true, will edit all occurrences of
* the event.
*/
async function invokeEditingRepeatEventDialog(window, clickBox, callback, editAll = false) {
let eventWindowPromise = CalendarTestUtils.waitForEventDialog();
doubleClickOptionalEventBox(window, clickBox);
let eventWindow = await eventWindowPromise;
Assert.report(false, undefined, undefined, "Repeating event dialog opened");
await new Promise(resolve => eventWindow.setTimeout(resolve, 500));
let editButton = eventWindow.document.getElementById("calendar-summary-dialog-edit-menu-button");
let popup = eventWindow.document.getElementById("edit-button-context-menu");
let shownPromise = BrowserTestUtils.waitForEvent(popup, "popupshown");
EventUtils.synthesizeMouseAtCenter(editButton, {}, eventWindow);
await shownPromise;
let target = editAll
? "edit-button-context-menu-all-occurrences"
: "edit-button-context-menu-this-occurrence";
popup.activateItem(eventWindow.document.getElementById(target));
Assert.report(false, undefined, undefined, "Repeating event dialog closed");
await execEventDialogCallback(callback);
}
function doubleClickOptionalEventBox(window, clickBox) {
if (clickBox) {
clickBox.scrollIntoView();
EventUtils.synthesizeMouse(clickBox, 1, 1, { clickCount: 2 }, window);
}
}
async function execEventDialogCallback(callback) {
let eventWindow = Services.wm.getMostRecentWindow(EVENT_DIALOG_NAME);

Просмотреть файл

@ -4,7 +4,7 @@
/* globals createCalendarUsingDialog */
var { controller, deleteCalendars, invokeNewEventDialog } = ChromeUtils.import(
var { controller, deleteCalendars } = ChromeUtils.import(
"resource://testing-common/calendar/CalendarUtils.jsm"
);
var { saveAndCloseItemDialog, setData } = ChromeUtils.import(
@ -31,10 +31,9 @@ add_task(async function testLocalICS() {
// Create new event.
let box = CalendarTestUtils.dayView.getHourBoxAt(controller.window, HOUR);
await invokeNewEventDialog(window, box, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, { title: calendarName, calendar: calendarName });
await saveAndCloseItemDialog(eventWindow);
});
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, box);
await setData(dialogWindow, iframeWindow, { title: calendarName, calendar: calendarName });
await saveAndCloseItemDialog(dialogWindow);
// Assert presence in view.
await CalendarTestUtils.dayView.waitForEventBoxAt(controller.window, 1);

Просмотреть файл

@ -10,8 +10,6 @@ var {
createCalendar,
deleteCalendars,
goToDate,
invokeNewEventDialog,
invokeEditingEventDialog,
switchToView,
viewForward,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
@ -54,15 +52,14 @@ add_task(async function testAlarmDialog() {
},
}
);
await invokeNewEventDialog(window, null, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, {
allday: true,
reminder: "1day",
title: TITLE,
});
await saveAndCloseItemDialog(eventWindow);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window);
await setData(dialogWindow, iframeWindow, {
allday: true,
reminder: "1day",
title: TITLE,
});
await saveAndCloseItemDialog(dialogWindow);
await alarmPromise;
// Change the reminder duration, this resets the alarm.
@ -87,10 +84,10 @@ add_task(async function testAlarmDialog() {
},
}
);
await invokeEditingEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, { reminder: "2days", title: TITLE });
await saveAndCloseItemDialog(eventWindow);
});
({ dialogWindow, iframeWindow } = await CalendarTestUtils.editItem(window, eventBox));
await setData(dialogWindow, iframeWindow, { reminder: "2days", title: TITLE });
await saveAndCloseItemDialog(dialogWindow);
await alarmPromise;
Assert.ok(true, "Test ran to completion");

Просмотреть файл

@ -12,8 +12,6 @@ var {
deleteCalendars,
goToDate,
handleOccurrencePrompt,
invokeNewEventDialog,
invokeViewingEventDialog,
switchToView,
viewBack,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
@ -75,77 +73,79 @@ add_task(async function testEventDialog() {
// Create new event on first day in view.
controller.click(monthView.getDayBox(controller.window, 1, 1));
await invokeNewEventDialog(window, null, async (eventWindow, iframeWindow) => {
let eventDocument = eventWindow.document;
let iframeDocument = iframeWindow.document;
let {
dialogWindow,
iframeWindow,
dialogDocument,
iframeDocument,
} = await CalendarTestUtils.editNewEvent(window);
// First check all standard-values are set correctly.
let startPicker = iframeDocument.getElementById("event-starttime");
Assert.equal(startPicker._timepicker._inputField.value, startTime);
// First check all standard-values are set correctly.
let startPicker = iframeDocument.getElementById("event-starttime");
Assert.equal(startPicker._timepicker._inputField.value, startTime);
// Check selected calendar.
Assert.equal(iframeDocument.getElementById("item-calendar").value, CALENDARNAME);
// Check selected calendar.
Assert.equal(iframeDocument.getElementById("item-calendar").value, CALENDARNAME);
// Check standard title.
let defTitle = cal.l10n.getAnyString("calendar", "calendar", "newEvent");
Assert.equal(iframeDocument.getElementById("item-title").placeholder, defTitle);
// Check standard title.
let defTitle = cal.l10n.getAnyString("calendar", "calendar", "newEvent");
Assert.equal(iframeDocument.getElementById("item-title").placeholder, defTitle);
// Prepare category.
let categories = cal.l10n.getAnyString("calendar", "categories", "categories2");
// Pick 4th value in a comma-separated list.
let category = categories.split(",")[4];
// Calculate date to repeat until.
let untildate = firstDay.clone();
untildate.addDuration(cal.createDuration("P20D"));
// Prepare category.
let categories = cal.l10n.getAnyString("calendar", "categories", "categories2");
// Pick 4th value in a comma-separated list.
let category = categories.split(",")[4];
// Calculate date to repeat until.
let untildate = firstDay.clone();
untildate.addDuration(cal.createDuration("P20D"));
// Fill in the rest of the values.
await setData(eventWindow, iframeWindow, {
title: EVENTTITLE,
location: EVENTLOCATION,
description: EVENTDESCRIPTION,
categories: [category],
repeat: "daily",
repeatuntil: untildate,
reminder: "5minutes",
privacy: "private",
attachment: { add: EVENTURL },
attendees: { add: EVENTATTENDEE },
});
// Verify attendee added.
EventUtils.synthesizeMouseAtCenter(
iframeDocument.getElementById("event-grid-tab-attendees"),
{},
eventWindow
);
let attendeesTab = iframeDocument.getElementById("event-grid-tabpanel-attendees");
let attendeeName = attendeesTab.querySelector(".attendee-list .attendee-name");
Assert.ok(attendeeName);
Assert.equal(attendeeName.textContent, EVENTATTENDEE);
Assert.ok(!iframeDocument.getElementById("notify-attendees-checkbox").checked);
// Verify private label visible.
controller.waitFor(
() => !eventDocument.getElementById("status-privacy-private-box").hasAttribute("collapsed")
);
eventDocument.getElementById("event-privacy-menupopup").hidePopup();
// Add attachment and verify added.
EventUtils.synthesizeMouseAtCenter(
iframeDocument.getElementById("event-grid-tab-attachments"),
{},
iframeWindow
);
let attachmentsTab = iframeDocument.getElementById("event-grid-tabpanel-attachments");
Assert.equal(attachmentsTab.querySelectorAll("richlistitem").length, 1);
// save
await saveAndCloseItemDialog(eventWindow);
// Fill in the rest of the values.
await setData(dialogWindow, iframeWindow, {
title: EVENTTITLE,
location: EVENTLOCATION,
description: EVENTDESCRIPTION,
categories: [category],
repeat: "daily",
repeatuntil: untildate,
reminder: "5minutes",
privacy: "private",
attachment: { add: EVENTURL },
attendees: { add: EVENTATTENDEE },
});
// Verify attendee added.
EventUtils.synthesizeMouseAtCenter(
iframeDocument.getElementById("event-grid-tab-attendees"),
{},
dialogWindow
);
let attendeesTab = iframeDocument.getElementById("event-grid-tabpanel-attendees");
let attendeeName = attendeesTab.querySelector(".attendee-list .attendee-name");
Assert.ok(attendeeName);
Assert.equal(attendeeName.textContent, EVENTATTENDEE);
Assert.ok(!iframeDocument.getElementById("notify-attendees-checkbox").checked);
// Verify private label visible.
controller.waitFor(
() => !dialogDocument.getElementById("status-privacy-private-box").hasAttribute("collapsed")
);
dialogDocument.getElementById("event-privacy-menupopup").hidePopup();
// Add attachment and verify added.
EventUtils.synthesizeMouseAtCenter(
iframeDocument.getElementById("event-grid-tab-attachments"),
{},
iframeWindow
);
let attachmentsTab = iframeDocument.getElementById("event-grid-tabpanel-attachments");
Assert.equal(attachmentsTab.querySelectorAll("richlistitem").length, 1);
// save
await saveAndCloseItemDialog(dialogWindow);
// Catch and dismiss alarm.
plan_for_modal_dialog("Calendar:AlarmWindow", alarm => {
let dismissAllButton = alarm.window.document.getElementById("alarm-dismiss-all-button");
@ -213,39 +213,32 @@ add_task(async function testOpenExistingEventDialog() {
let createBox = dayView.getHourBoxAt(controller.window, 8);
// Create a new event.
await invokeNewEventDialog(window, createBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, {
title: EVENTTITLE,
location: EVENTLOCATION,
description: EVENTDESCRIPTION,
});
await saveAndCloseItemDialog(eventWindow);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, createBox);
await setData(dialogWindow, iframeWindow, {
title: EVENTTITLE,
location: EVENTLOCATION,
description: EVENTDESCRIPTION,
});
await saveAndCloseItemDialog(dialogWindow);
let eventBox = await dayView.waitForEventBoxAt(controller.window, 1);
// Open the event in the summary dialog, it will fail if otherwise.
await invokeViewingEventDialog(
window,
eventBox,
async event => {
Assert.equal(
event.window.document.querySelector("calendar-item-summary .item-title").textContent,
EVENTTITLE
);
Assert.equal(
event.window.document.querySelector("calendar-item-summary .item-location").textContent,
EVENTLOCATION
);
Assert.equal(
event.window.document.querySelector("calendar-item-summary .item-description")
.contentDocument.body.innerText,
EVENTDESCRIPTION
);
EventUtils.synthesizeKey("VK_ESCAPE", {}, event.window);
},
"view"
let eventWin = await CalendarTestUtils.viewItem(window, eventBox);
Assert.equal(
eventWin.document.querySelector("calendar-item-summary .item-title").textContent,
EVENTTITLE
);
Assert.equal(
eventWin.document.querySelector("calendar-item-summary .item-location").textContent,
EVENTLOCATION
);
Assert.equal(
eventWin.document.querySelector("calendar-item-summary .item-description").contentDocument.body
.innerText,
EVENTDESCRIPTION
);
EventUtils.synthesizeKey("VK_ESCAPE", {}, eventWin);
eventBox.focus();
EventUtils.synthesizeKey("VK_DELETE", {}, controller.window);
@ -263,59 +256,45 @@ add_task(async function testEventReminderDisplay() {
let createBox = dayView.getHourBoxAt(controller.window, 8);
// Create an event without a reminder.
await invokeNewEventDialog(window, createBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, {
title: EVENTTITLE,
location: EVENTLOCATION,
description: EVENTDESCRIPTION,
});
await saveAndCloseItemDialog(eventWindow);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, createBox);
await setData(dialogWindow, iframeWindow, {
title: EVENTTITLE,
location: EVENTLOCATION,
description: EVENTDESCRIPTION,
});
await saveAndCloseItemDialog(dialogWindow);
let eventBox = await dayView.waitForEventBoxAt(controller.window, 1);
await invokeViewingEventDialog(
window,
eventBox,
async event => {
let doc = event.window.document;
let row = doc.querySelector(".reminder-row");
Assert.ok(row.hidden, "reminder dropdown is not displayed");
EventUtils.synthesizeKey("VK_ESCAPE", {}, event.window);
},
"view"
);
let eventWindow = await CalendarTestUtils.viewItem(window, eventBox);
let doc = eventWindow.document;
let row = doc.querySelector(".reminder-row");
Assert.ok(row.hidden, "reminder dropdown is not displayed");
EventUtils.synthesizeKey("VK_ESCAPE", {}, eventWindow);
goToDate(controller, 2020, 2, 1);
createBox = dayView.getHourBoxAt(controller.window, 8);
// Create an event with a reminder.
await invokeNewEventDialog(window, createBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, {
title: EVENTTITLE,
location: EVENTLOCATION,
description: EVENTDESCRIPTION,
reminder: "1week",
});
await saveAndCloseItemDialog(eventWindow);
({ dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, createBox));
await setData(dialogWindow, iframeWindow, {
title: EVENTTITLE,
location: EVENTLOCATION,
description: EVENTDESCRIPTION,
reminder: "1week",
});
await saveAndCloseItemDialog(dialogWindow);
eventBox = await dayView.waitForEventBoxAt(controller.window, 1);
await invokeViewingEventDialog(
window,
eventBox,
async event => {
let doc = event.window.document;
let row = doc.querySelector(".reminder-row");
eventWindow = await CalendarTestUtils.viewItem(window, eventBox);
doc = eventWindow.document;
row = doc.querySelector(".reminder-row");
Assert.ok(
row.textContent.includes("7 days before"),
"the details are shown when a reminder is set"
);
EventUtils.synthesizeKey("VK_ESCAPE", {}, event.window);
},
"view"
Assert.ok(
row.textContent.includes("7 days before"),
"the details are shown when a reminder is set"
);
EventUtils.synthesizeKey("VK_ESCAPE", {}, eventWindow);
// This is done so that calItemBase#isInvitation returns true.
let calendar = cal.getCalendarManager().getCalendarById(calId);
@ -353,19 +332,13 @@ add_task(async function testEventReminderDisplay() {
goToDate(controller, 2020, 3, 1);
eventBox = await dayView.waitForEventBoxAt(controller.window, 1);
await invokeViewingEventDialog(
window,
eventBox,
async event => {
let doc = event.window.document;
let row = doc.querySelector(".reminder-row");
eventWindow = await CalendarTestUtils.viewItem(window, eventBox);
doc = eventWindow.document;
row = doc.querySelector(".reminder-row");
Assert.ok(!row.hidden, "reminder row is displayed");
Assert.ok(row.querySelector("menulist") != null, "reminder dropdown is available");
EventUtils.synthesizeKey("VK_ESCAPE", {}, event.window);
},
"view"
);
Assert.ok(!row.hidden, "reminder row is displayed");
Assert.ok(row.querySelector("menulist") != null, "reminder dropdown is available");
EventUtils.synthesizeKey("VK_ESCAPE", {}, eventWindow);
// Delete directly, as using the UI causes a prompt to appear.
calendarProxy.deleteItem(calendarEvent);
@ -382,14 +355,13 @@ add_task(async function testCtrlEnterShortcut() {
goToDate(controller, 2020, 9, 1);
let createBox = dayView.getHourBoxAt(controller.window, 8);
await invokeNewEventDialog(window, createBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, {
title: EVENTTITLE,
location: EVENTLOCATION,
description: EVENTDESCRIPTION,
});
EventUtils.synthesizeKey("VK_RETURN", { ctrlKey: true }, eventWindow);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, createBox);
await setData(dialogWindow, iframeWindow, {
title: EVENTTITLE,
location: EVENTLOCATION,
description: EVENTDESCRIPTION,
});
EventUtils.synthesizeKey("VK_RETURN", { ctrlKey: true }, dialogWindow);
switchToView(controller, "month");

Просмотреть файл

@ -11,8 +11,6 @@ var {
createCalendar,
deleteCalendars,
goToDate,
invokeNewEventDialog,
invokeEditingEventDialog,
switchToView,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
var { cancelItemDialog, saveAndCloseItemDialog, setData } = ChromeUtils.import(
@ -34,39 +32,37 @@ add_task(async function testEventDialogModificationPrompt() {
let createbox = dayView.getHourBoxAt(controller.window, 8);
// Create new event.
await invokeNewEventDialog(window, createbox, async (eventWindow, iframeWindow) => {
let categories = cal.l10n.getAnyString("calendar", "categories", "categories2").split(",");
data[0].categories.push(categories[0]);
data[1].categories.push(categories[1], categories[2]);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, createbox);
let categories = cal.l10n.getAnyString("calendar", "categories", "categories2").split(",");
data[0].categories.push(categories[0]);
data[1].categories.push(categories[1], categories[2]);
// Enter first set of data.
await setData(dialogWindow, iframeWindow, data[0]);
await saveAndCloseItemDialog(dialogWindow);
// Enter first set of data.
await setData(eventWindow, iframeWindow, data[0]);
await saveAndCloseItemDialog(eventWindow);
});
let eventbox = await dayView.waitForEventBoxAt(controller.window, 1);
// Open, but change nothing.
await invokeEditingEventDialog(window, eventbox, (eventWindow, iframeWindow) => {
// Escape the event window, there should be no prompt to save event.
cancelItemDialog(eventWindow);
// Wait to see if the prompt appears.
controller.sleep(2000);
});
({ dialogWindow, iframeWindow } = await CalendarTestUtils.editItem(window, eventbox));
// Escape the event window, there should be no prompt to save event.
cancelItemDialog(dialogWindow);
// Wait to see if the prompt appears.
controller.sleep(2000);
eventbox = await dayView.waitForEventBoxAt(controller.window, 1);
// Open, change all values then revert the changes.
await invokeEditingEventDialog(window, eventbox, async (eventWindow, iframeWindow) => {
// Change all values.
await setData(eventWindow, iframeWindow, data[1]);
({ dialogWindow, iframeWindow } = await CalendarTestUtils.editItem(window, eventbox));
// Change all values.
await setData(dialogWindow, iframeWindow, data[1]);
// Edit all values back to original.
await setData(eventWindow, iframeWindow, data[0]);
// Edit all values back to original.
await setData(dialogWindow, iframeWindow, data[0]);
// Escape the event window, there should be no prompt to save event.
cancelItemDialog(eventWindow);
// Wait to see if the prompt appears.
controller.sleep(2000);
});
// Escape the event window, there should be no prompt to save event.
cancelItemDialog(dialogWindow);
// Wait to see if the prompt appears.
controller.sleep(2000);
// Delete event.
controller.window.document.getElementById("day-view").focus();
@ -84,20 +80,18 @@ add_task(async function testDescriptionWhitespace() {
for (let i = 0; i < newlines.length; i++) {
// test set i
let createbox = dayView.getHourBoxAt(controller.window, 8);
await invokeNewEventDialog(window, createbox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, newlines[i]);
await saveAndCloseItemDialog(eventWindow);
});
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, createbox);
await setData(dialogWindow, iframeWindow, newlines[i]);
await saveAndCloseItemDialog(dialogWindow);
let eventbox = await dayView.waitForEventBoxAt(controller.window, 1);
// Open and close.
await invokeEditingEventDialog(window, eventbox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, newlines[i]);
cancelItemDialog(eventWindow);
// Wait to see if the prompt appears.
controller.sleep(2000);
});
({ dialogWindow, iframeWindow } = await CalendarTestUtils.editItem(window, eventbox));
await setData(dialogWindow, iframeWindow, newlines[i]);
cancelItemDialog(dialogWindow);
// Wait to see if the prompt appears.
controller.sleep(2000);
// Delete it.
controller.window.document.getElementById("day-view").focus();

Просмотреть файл

@ -8,8 +8,6 @@ var {
controller,
createCalendar,
deleteCalendars,
invokeNewEventDialog,
invokeNewTaskDialog,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
var { cancelItemDialog } = ChromeUtils.import(
"resource://testing-common/calendar/ItemEditingHelpers.jsm"
@ -25,113 +23,107 @@ add_task(function setupModule(module) {
});
add_task(async function testEventDialog() {
await invokeNewEventDialog(window, null, (eventWindow, iframeWindow) => {
checkLargeEnough(eventWindow, iframeWindow);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window);
checkLargeEnough(dialogWindow, iframeWindow);
// Much larger than necessary.
eventWindow.resizeTo(650, 690);
checkWithinTolerance(eventWindow.outerWidth, 650);
checkWithinTolerance(eventWindow.outerHeight, 690);
cancelItemDialog(eventWindow);
});
// Much larger than necessary.
dialogWindow.resizeTo(650, 690);
checkWithinTolerance(dialogWindow.outerWidth, 650);
checkWithinTolerance(dialogWindow.outerHeight, 690);
cancelItemDialog(dialogWindow);
checkWithinTolerance(getPersistedValue("width"), 650, LARGE_TOLERANCE);
checkWithinTolerance(getPersistedValue("height"), 690, LARGE_TOLERANCE);
await invokeNewEventDialog(window, null, (eventWindow, iframeWindow) => {
let eventDocEl = eventWindow.document.documentElement;
({ dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window));
let eventDocEl = dialogWindow.document.documentElement;
checkWithinTolerance(eventWindow.outerWidth, 650, LARGE_TOLERANCE);
checkWithinTolerance(eventWindow.outerHeight, 690, LARGE_TOLERANCE);
checkLargeEnough(eventWindow, iframeWindow);
checkWithinTolerance(dialogWindow.outerWidth, 650, LARGE_TOLERANCE);
checkWithinTolerance(dialogWindow.outerHeight, 690, LARGE_TOLERANCE);
checkLargeEnough(dialogWindow, iframeWindow);
// Much smaller than necessary.
eventWindow.resizeTo(350, 400);
checkLargeEnough(eventWindow, iframeWindow);
Assert.less(eventWindow.outerWidth, 650, "dialog shrank");
Assert.less(eventWindow.outerHeight, 690, "dialog shrank");
Assert.greater(eventWindow.outerWidth, 350, "requested size not reached");
Assert.greater(eventWindow.outerHeight, 400, "requested size not reached");
Assert.equal(
eventDocEl.getAttribute("minwidth"),
eventDocEl.getAttribute("width"),
"minimum width attribute set"
);
Assert.equal(
eventDocEl.getAttribute("minheight"),
eventDocEl.getAttribute("height"),
"minimum height attribute set"
);
cancelItemDialog(eventWindow);
});
// Much smaller than necessary.
dialogWindow.resizeTo(350, 400);
checkLargeEnough(dialogWindow, iframeWindow);
Assert.less(dialogWindow.outerWidth, 650, "dialog shrank");
Assert.less(dialogWindow.outerHeight, 690, "dialog shrank");
Assert.greater(dialogWindow.outerWidth, 350, "requested size not reached");
Assert.greater(dialogWindow.outerHeight, 400, "requested size not reached");
Assert.equal(
eventDocEl.getAttribute("minwidth"),
eventDocEl.getAttribute("width"),
"minimum width attribute set"
);
Assert.equal(
eventDocEl.getAttribute("minheight"),
eventDocEl.getAttribute("height"),
"minimum height attribute set"
);
cancelItemDialog(dialogWindow);
await invokeNewEventDialog(window, null, (eventWindow, iframeWindow) => {
checkLargeEnough(eventWindow, iframeWindow);
({ dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window));
checkLargeEnough(dialogWindow, iframeWindow);
// Much larger than necessary.
eventWindow.resizeTo(650, 690);
checkWithinTolerance(eventWindow.outerWidth, 650);
checkWithinTolerance(eventWindow.outerHeight, 690);
cancelItemDialog(eventWindow);
});
// Much larger than necessary.
dialogWindow.resizeTo(650, 690);
checkWithinTolerance(dialogWindow.outerWidth, 650);
checkWithinTolerance(dialogWindow.outerHeight, 690);
cancelItemDialog(dialogWindow);
checkWithinTolerance(getPersistedValue("width"), 650, LARGE_TOLERANCE);
checkWithinTolerance(getPersistedValue("height"), 690, LARGE_TOLERANCE);
});
add_task(async function testTaskDialog() {
await invokeNewTaskDialog(window, null, (taskWindow, iframeWindow) => {
checkWithinTolerance(getPersistedValue("width"), 650, LARGE_TOLERANCE);
checkWithinTolerance(getPersistedValue("height"), 690, LARGE_TOLERANCE);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewTask(window);
checkWithinTolerance(getPersistedValue("width"), 650, LARGE_TOLERANCE);
checkWithinTolerance(getPersistedValue("height"), 690, LARGE_TOLERANCE);
checkLargeEnough(taskWindow, iframeWindow);
checkLargeEnough(dialogWindow, iframeWindow);
// Much larger than necessary.
taskWindow.resizeTo(680, 700);
checkWithinTolerance(taskWindow.outerWidth, 680);
checkWithinTolerance(taskWindow.outerHeight, 700);
cancelItemDialog(taskWindow);
});
// Much larger than necessary.
dialogWindow.resizeTo(680, 700);
checkWithinTolerance(dialogWindow.outerWidth, 680);
checkWithinTolerance(dialogWindow.outerHeight, 700);
cancelItemDialog(dialogWindow);
checkWithinTolerance(getPersistedValue("width"), 680, LARGE_TOLERANCE);
checkWithinTolerance(getPersistedValue("height"), 700, LARGE_TOLERANCE);
await invokeNewTaskDialog(window, null, (taskWindow, iframeWindow) => {
let taskDocEl = taskWindow.document.documentElement;
({ dialogWindow, iframeWindow } = await CalendarTestUtils.editNewTask(window));
let taskDocEl = dialogWindow.document.documentElement;
checkWithinTolerance(taskWindow.outerWidth, 680, LARGE_TOLERANCE);
checkWithinTolerance(taskWindow.outerHeight, 700, LARGE_TOLERANCE);
checkLargeEnough(taskWindow, iframeWindow);
checkWithinTolerance(dialogWindow.outerWidth, 680, LARGE_TOLERANCE);
checkWithinTolerance(dialogWindow.outerHeight, 700, LARGE_TOLERANCE);
checkLargeEnough(dialogWindow, iframeWindow);
// Much smaller than necessary.
taskWindow.resizeTo(350, 400);
checkLargeEnough(taskWindow, iframeWindow);
Assert.less(taskWindow.outerWidth, 680, "dialog shrank");
Assert.less(taskWindow.outerHeight, 700, "dialog shrank");
Assert.greater(taskWindow.outerWidth, 350, "minimum size not reached");
Assert.greater(taskWindow.outerHeight, 400, "minimum size not reached");
Assert.equal(
taskDocEl.getAttribute("minwidth"),
taskDocEl.getAttribute("width"),
"minimum width attribute set"
);
Assert.equal(
taskDocEl.getAttribute("minheight"),
taskDocEl.getAttribute("height"),
"minimum height attribute set"
);
cancelItemDialog(taskWindow);
});
// Much smaller than necessary.
dialogWindow.resizeTo(350, 400);
checkLargeEnough(dialogWindow, iframeWindow);
Assert.less(dialogWindow.outerWidth, 680, "dialog shrank");
Assert.less(dialogWindow.outerHeight, 700, "dialog shrank");
Assert.greater(dialogWindow.outerWidth, 350, "minimum size not reached");
Assert.greater(dialogWindow.outerHeight, 400, "minimum size not reached");
Assert.equal(
taskDocEl.getAttribute("minwidth"),
taskDocEl.getAttribute("width"),
"minimum width attribute set"
);
Assert.equal(
taskDocEl.getAttribute("minheight"),
taskDocEl.getAttribute("height"),
"minimum height attribute set"
);
cancelItemDialog(dialogWindow);
await invokeNewTaskDialog(window, null, (taskWindow, iframeWindow) => {
checkLargeEnough(taskWindow, iframeWindow);
({ dialogWindow, iframeWindow } = await CalendarTestUtils.editNewTask(window));
checkLargeEnough(dialogWindow, iframeWindow);
// Much larger than necessary.
taskWindow.resizeTo(680, 700);
checkWithinTolerance(taskWindow.outerWidth, 680);
checkWithinTolerance(taskWindow.outerHeight, 700);
cancelItemDialog(taskWindow);
});
// Much larger than necessary.
dialogWindow.resizeTo(680, 700);
checkWithinTolerance(dialogWindow.outerWidth, 680);
checkWithinTolerance(dialogWindow.outerHeight, 700);
cancelItemDialog(dialogWindow);
});
registerCleanupFunction(function teardownModule(module) {

Просмотреть файл

@ -7,8 +7,6 @@ var {
controller,
createCalendar,
deleteCalendars,
invokeNewEventDialog,
invokeEditingEventDialog,
switchToView,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
var { cancelItemDialog, saveAndCloseItemDialog, setData } = ChromeUtils.import(
@ -26,43 +24,41 @@ add_task(async function testUTF8() {
// Create new event.
let eventBox = CalendarTestUtils.dayView.getHourBoxAt(controller.window, 8);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
// Fill in name, location, description.
await setData(eventWindow, iframeWindow, {
title: UTF8STRING,
location: UTF8STRING,
description: UTF8STRING,
categories: [UTF8STRING],
});
await saveAndCloseItemDialog(eventWindow);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, eventBox);
// Fill in name, location, description.
await setData(dialogWindow, iframeWindow, {
title: UTF8STRING,
location: UTF8STRING,
description: UTF8STRING,
categories: [UTF8STRING],
});
await saveAndCloseItemDialog(dialogWindow);
// open
eventBox = await CalendarTestUtils.dayView.waitForEventBoxAt(controller.window, 1);
await invokeEditingEventDialog(window, eventBox, (eventWindow, iframeWindow) => {
let iframeDocument = iframeWindow.document;
let { dialogWindow: dlgWindow, iframeDocument } = await CalendarTestUtils.dayView.editEventAt(
controller.window,
1
);
// Check values.
Assert.equal(iframeDocument.getElementById("item-title").value, UTF8STRING);
Assert.equal(iframeDocument.getElementById("item-location").value, UTF8STRING);
// The trailing spaces confuse innerText, so we'll do this longhand
let editorEl = iframeDocument.getElementById("item-description");
let editor = editorEl.getEditor(editorEl.contentWindow);
let description = editor.outputToString("text/plain", 0);
Assert.equal(description, UTF8STRING);
Assert.ok(
iframeDocument
.getElementById("item-categories")
.querySelector(`menuitem[label="${UTF8STRING}"][checked]`)
);
// Check values.
Assert.equal(iframeDocument.getElementById("item-title").value, UTF8STRING);
Assert.equal(iframeDocument.getElementById("item-location").value, UTF8STRING);
// The trailing spaces confuse innerText, so we'll do this longhand
let editorEl = iframeDocument.getElementById("item-description");
let editor = editorEl.getEditor(editorEl.contentWindow);
let description = editor.outputToString("text/plain", 0);
Assert.equal(description, UTF8STRING);
Assert.ok(
iframeDocument
.getElementById("item-categories")
.querySelector(`menuitem[label="${UTF8STRING}"][checked]`)
);
// Escape the event window.
cancelItemDialog(eventWindow);
});
Assert.ok(true, "Test ran to completion");
// Escape the event window.
cancelItemDialog(dlgWindow);
});
Assert.ok(true, "Test ran to completion");
registerCleanupFunction(function teardownModule(module) {
deleteCalendars(controller, UTF8STRING);
Services.prefs.clearUserPref("calendar.categories.names");

Просмотреть файл

@ -8,13 +8,9 @@ var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
var { CalendarTestUtils } = ChromeUtils.import(
"resource://testing-common/calendar/CalendarTestUtils.jsm"
);
var {
controller,
goToToday,
handleOccurrencePrompt,
invokeEditingRepeatEventDialog,
invokeNewEventDialog,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
var { controller, goToToday, handleOccurrencePrompt } = ChromeUtils.import(
"resource://testing-common/calendar/CalendarUtils.jsm"
);
var { PromiseUtils } = ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
var { saveAndCloseItemDialog, setData } = ChromeUtils.import(
"resource://testing-common/calendar/ItemEditingHelpers.jsm"
@ -161,19 +157,18 @@ async function runTestAlarms() {
},
}
);
await invokeNewEventDialog(window, null, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, {
title: "test event",
startdate: start,
starttime: start,
enddate: end,
endtime: end,
reminder: "2days",
repeat: "weekly",
});
await saveAndCloseItemDialog(eventWindow);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window);
await setData(dialogWindow, iframeWindow, {
title: "test event",
startdate: start,
starttime: start,
enddate: end,
endtime: end,
reminder: "2days",
repeat: "weekly",
});
await saveAndCloseItemDialog(dialogWindow);
await alarmDialogPromise;
info("Alarm dialog closed");
@ -196,20 +191,14 @@ async function runTestAlarms() {
);
Assert.ok(!!eventBox.item.parentItem.alarmLastAck);
await invokeEditingRepeatEventDialog(
window,
eventBox,
async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, {
title: "modified test event",
repeat: "weekly",
repeatuntil: repeatUntil,
});
({ dialogWindow, iframeWindow } = await CalendarTestUtils.editItemOccurrences(window, eventBox));
await setData(dialogWindow, iframeWindow, {
title: "modified test event",
repeat: "weekly",
repeatuntil: repeatUntil,
});
await saveAndCloseItemDialog(eventWindow);
},
true
);
await saveAndCloseItemDialog(dialogWindow);
Assert.equal(window.unifinderTreeView.rowCount, 1, "unifinder event count");

Просмотреть файл

@ -10,7 +10,6 @@ var {
deleteCalendars,
goToDate,
handleOccurrencePrompt,
invokeNewEventDialog,
switchToView,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
@ -30,10 +29,9 @@ add_task(async function testAnnualRecurrence() {
// Create yearly recurring all-day event.
let eventBox = dayView.getAllDayHeader(controller.window);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, { title: "Event", repeat: "yearly" });
await saveAndCloseItemDialog(eventWindow);
});
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, eventBox);
await setData(dialogWindow, iframeWindow, { title: "Event", repeat: "yearly" });
await saveAndCloseItemDialog(dialogWindow);
let checkYears = [STARTYEAR, STARTYEAR + 1, EPOCH - 1, EPOCH, EPOCH + 1];
for (let year of checkYears) {

Просмотреть файл

@ -10,7 +10,6 @@ var {
deleteCalendars,
goToDate,
handleOccurrencePrompt,
invokeNewEventDialog,
switchToView,
viewForward,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
@ -30,10 +29,9 @@ add_task(async function testBiweeklyRecurrence() {
// Create biweekly event.
let eventBox = dayView.getHourBoxAt(controller.window, HOUR);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, { title: "Event", repeat: "bi.weekly" });
await saveAndCloseItemDialog(eventWindow);
});
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, eventBox);
await setData(dialogWindow, iframeWindow, { title: "Event", repeat: "bi.weekly" });
await saveAndCloseItemDialog(dialogWindow);
// Check day view.
switchToView(controller, "day");

Просмотреть файл

@ -10,8 +10,6 @@ var {
deleteCalendars,
goToDate,
handleOccurrencePrompt,
invokeNewEventDialog,
invokeEditingRepeatEventDialog,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
@ -39,14 +37,13 @@ add_task(async function testDailyRecurrence() {
// Create daily event.
let eventBox = dayView.getHourBoxAt(controller.window, HOUR);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, {
title: TITLE,
repeat: "daily",
repeatuntil: cal.createDateTime("20090320T000000Z"),
});
await saveAndCloseItemDialog(eventWindow);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, eventBox);
await setData(dialogWindow, iframeWindow, {
title: TITLE,
repeat: "daily",
repeatuntil: cal.createDateTime("20090320T000000Z"),
});
await saveAndCloseItemDialog(dialogWindow);
// Check day view for 7 days.
for (let day = 1; day <= 7; day++) {
@ -115,16 +112,9 @@ add_task(async function testDailyRecurrence() {
// Go to previous day to edit event to occur only on weekdays.
await calendarViewBackward(controller.window, 1);
eventBox = await dayView.waitForEventBoxAt(controller.window, 1);
await invokeEditingRepeatEventDialog(
window,
eventBox,
async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, { repeat: "every.weekday" });
await saveAndCloseItemDialog(eventWindow);
},
true
);
({ dialogWindow, iframeWindow } = await dayView.editEventOccurrencesAt(controller.window, 1));
await setData(dialogWindow, iframeWindow, { repeat: "every.weekday" });
await saveAndCloseItemDialog(dialogWindow);
// Check day view for 7 days.
let dates = [

Просмотреть файл

@ -10,7 +10,6 @@ var {
deleteCalendars,
goToDate,
handleOccurrencePrompt,
invokeNewEventDialog,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
var { menulistSelect } = ChromeUtils.import(
@ -31,10 +30,9 @@ add_task(async function testLastDayOfMonthRecurrence() {
// Create monthly recurring event.
let eventBox = dayView.getHourBoxAt(controller.window, HOUR);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, { title: "Event", repeat: setRecurrence });
await saveAndCloseItemDialog(eventWindow);
});
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, eventBox);
await setData(dialogWindow, iframeWindow, { title: "Event", repeat: setRecurrence });
await saveAndCloseItemDialog(dialogWindow);
// data tuple: [year, month, day, row in month view]
// note: Month starts here with 1 for January.

Просмотреть файл

@ -10,7 +10,6 @@ var {
deleteCalendars,
goToDate,
handleOccurrencePrompt,
invokeNewEventDialog,
switchToView,
viewForward,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
@ -32,10 +31,9 @@ add_task(async function testWeeklyNRecurrence() {
// Create weekly recurring event.
let eventBox = dayView.getHourBoxAt(controller.window, HOUR);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, { title: "Event", repeat: setRecurrence });
await saveAndCloseItemDialog(eventWindow);
});
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, eventBox);
await setData(dialogWindow, iframeWindow, { title: "Event", repeat: setRecurrence });
await saveAndCloseItemDialog(dialogWindow);
// Check day view.
// Monday, Tuesday, Wednesday, Thursday

Просмотреть файл

@ -10,7 +10,6 @@ var {
deleteCalendars,
goToDate,
handleOccurrencePrompt,
invokeNewEventDialog,
switchToView,
viewForward,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
@ -33,10 +32,9 @@ add_task(async function testWeeklyUntilRecurrence() {
// Create weekly recurring event.
let eventBox = dayView.getHourBoxAt(controller.window, HOUR);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, { title: "Event", repeat: setRecurrence });
await saveAndCloseItemDialog(eventWindow);
});
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, eventBox);
await setData(dialogWindow, iframeWindow, { title: "Event", repeat: setRecurrence });
await saveAndCloseItemDialog(dialogWindow);
// Check day view.
for (let week = 0; week < 3; week++) {

Просмотреть файл

@ -10,8 +10,6 @@ var {
deleteCalendars,
goToDate,
handleOccurrencePrompt,
invokeNewEventDialog,
invokeEditingRepeatEventDialog,
switchToView,
viewForward,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
@ -35,37 +33,30 @@ add_task(async function testWeeklyWithExceptionRecurrence() {
// Create weekly recurring event.
let eventBox = dayView.getHourBoxAt(controller.window, HOUR);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, { title: TITLE, repeat: setRecurrence });
await saveAndCloseItemDialog(eventWindow);
});
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, eventBox);
await setData(dialogWindow, iframeWindow, { title: TITLE, repeat: setRecurrence });
await saveAndCloseItemDialog(dialogWindow);
// Move 5th January occurrence to 6th January.
eventBox = await dayView.waitForEventBoxAt(controller.window, 1);
await invokeEditingRepeatEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, {
title: TITLE,
startdate: STARTDATE,
enddate: STARTDATE,
});
await saveAndCloseItemDialog(eventWindow);
({ dialogWindow, iframeWindow } = await dayView.editEventOccurrenceAt(controller.window, 1));
await setData(dialogWindow, iframeWindow, {
title: TITLE,
startdate: STARTDATE,
enddate: STARTDATE,
});
await saveAndCloseItemDialog(dialogWindow);
goToDate(controller, 2009, 1, 6);
await dayView.waitForEventBoxAt(controller.window, 1);
// Change recurrence rule.
goToDate(controller, 2009, 1, 7);
eventBox = await dayView.waitForEventBoxAt(controller.window, 1);
await invokeEditingRepeatEventDialog(
window,
eventBox,
async (eventWindow, iframeWindow) => {
await setData(eventWindow, iframeWindow, { title: "Event", repeat: changeRecurrence });
await saveAndCloseItemDialog(eventWindow);
},
true
);
({ dialogWindow, iframeWindow } = await dayView.editEventOccurrencesAt(controller.window, 1));
await setData(dialogWindow, iframeWindow, {
title: "Event",
repeat: changeRecurrence,
});
await saveAndCloseItemDialog(dialogWindow);
// Check two weeks.
// day view

Просмотреть файл

@ -9,7 +9,6 @@ var {
createCalendar,
controller,
deleteCalendars,
invokeNewEventDialog,
switchToView,
goToDate,
findEventsInNode,
@ -20,9 +19,9 @@ var { saveAndCloseItemDialog, setData } = ChromeUtils.import(
"resource://testing-common/calendar/ItemEditingHelpers.jsm"
);
var { dayView } = ChromeUtils.import(
var { CalendarTestUtils } = ChromeUtils.import(
"resource://testing-common/calendar/CalendarTestUtils.jsm"
).CalendarTestUtils;
);
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
@ -66,22 +65,21 @@ add_task(async function testTimezones2_CreateEvents() {
];
let time = cal.createDateTime();
for (let i = 0; i < TIMEZONES.length; i++) {
let eventBox = dayView.getHourBoxAt(controller.window, i + 11);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
time.hour = times[i][0];
time.minute = times[i][1];
let eventBox = CalendarTestUtils.dayView.getHourBoxAt(controller.window, i + 11);
let { dialogWindow, iframeWindow } = await CalendarTestUtils.editNewEvent(window, eventBox);
time.hour = times[i][0];
time.minute = times[i][1];
// Set event data.
await setData(eventWindow, iframeWindow, {
title: TIMEZONES[i],
repeat: "weekly",
repeatuntil: cal.createDateTime("20091231T000000Z"),
starttime: time,
timezone: TIMEZONES[i],
});
await saveAndCloseItemDialog(eventWindow);
// Set event data.
await setData(dialogWindow, iframeWindow, {
title: TIMEZONES[i],
repeat: "weekly",
repeatuntil: cal.createDateTime("20091231T000000Z"),
starttime: time,
timezone: TIMEZONES[i],
});
await saveAndCloseItemDialog(dialogWindow);
}
});
@ -853,7 +851,7 @@ function verify(dates, timezones, times) {
viewBack(controller, 1);
}
eventNodes = Array.from(dayView.getEventBoxes(controller.window));
eventNodes = Array.from(CalendarTestUtils.dayView.getEventBoxes(controller.window));
eventNodes = eventNodes
.filter(node => node.mOccurrence.title == timezones[tzIdx])
.map(node => node.getBoundingClientRect().y);

Просмотреть файл

@ -9,8 +9,6 @@ var {
createCalendar,
deleteCalendars,
goToDate,
invokeNewEventDialog,
invokeEditingEventDialog,
switchToView,
ensureViewLoaded,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
@ -20,9 +18,9 @@ var { saveAndCloseItemDialog, setData } = ChromeUtils.import(
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
const { dayView } = ChromeUtils.import(
const { CalendarTestUtils } = ChromeUtils.import(
"resource://testing-common/calendar/CalendarTestUtils.jsm"
).CalendarTestUtils;
);
const TITLE1 = "Day View Event";
const TITLE2 = "Day View Event Changed";
@ -42,41 +40,44 @@ add_task(async function testDayView() {
}, "Inspecting the date");
// Create event at 8 AM.
let eventBox = dayView.getHourBoxAt(controller.window, 8);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
// Check that the start time is correct.
let someDate = cal.createDateTime();
someDate.resetTo(2009, 0, 1, 8, 0, 0, cal.dtz.floating);
let eventBox = CalendarTestUtils.dayView.getHourBoxAt(controller.window, 8);
let { dialogWindow, iframeWindow, iframeDocument } = await CalendarTestUtils.editNewEvent(
window,
eventBox
);
let startPicker = iframeWindow.document.getElementById("event-starttime");
Assert.equal(startPicker._timepicker._inputField.value, cal.dtz.formatter.formatTime(someDate));
Assert.equal(
startPicker._datepicker._inputField.value,
cal.dtz.formatter.formatDateShort(someDate)
);
// Check that the start time is correct.
let someDate = cal.createDateTime();
someDate.resetTo(2009, 0, 1, 8, 0, 0, cal.dtz.floating);
// Fill in title, description and calendar.
await setData(eventWindow, iframeWindow, {
title: TITLE1,
description: DESC,
calendar: CALENDARNAME,
});
let startPicker = iframeDocument.getElementById("event-starttime");
Assert.equal(startPicker._timepicker._inputField.value, cal.dtz.formatter.formatTime(someDate));
Assert.equal(
startPicker._datepicker._inputField.value,
cal.dtz.formatter.formatDateShort(someDate)
);
await saveAndCloseItemDialog(eventWindow);
// Fill in title, description and calendar.
await setData(dialogWindow, iframeWindow, {
title: TITLE1,
description: DESC,
calendar: CALENDARNAME,
});
await saveAndCloseItemDialog(dialogWindow);
// If it was created successfully, it can be opened.
eventBox = await dayView.waitForEventBoxAt(controller.window, 1);
await invokeEditingEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
// Change title and save changes.
await setData(eventWindow, iframeWindow, { title: TITLE2 });
await saveAndCloseItemDialog(eventWindow);
});
({ dialogWindow, iframeWindow } = await CalendarTestUtils.dayView.editEventAt(
controller.window,
1
));
await setData(dialogWindow, iframeWindow, { title: TITLE2 });
await saveAndCloseItemDialog(dialogWindow);
ensureViewLoaded(controller);
// Check if name was saved.
eventBox = await dayView.waitForEventBoxAt(controller.window, 1);
eventBox = await CalendarTestUtils.dayView.waitForEventBoxAt(controller.window, 1);
let eventName = eventBox.querySelector(".event-name-label");
Assert.ok(eventName);
@ -86,7 +87,7 @@ add_task(async function testDayView() {
controller.click(eventBox);
eventBox.focus();
EventUtils.synthesizeKey("VK_DELETE", {}, controller.window);
await dayView.waitForNoEventBoxAt(controller.window, 1);
await CalendarTestUtils.dayView.waitForNoEventBoxAt(controller.window, 1);
Assert.ok(true, "Test ran to completion");
});

Просмотреть файл

@ -9,8 +9,6 @@ var {
createCalendar,
deleteCalendars,
goToDate,
invokeNewEventDialog,
invokeEditingEventDialog,
switchToView,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
var { saveAndCloseItemDialog, setData } = ChromeUtils.import(
@ -19,9 +17,9 @@ var { saveAndCloseItemDialog, setData } = ChromeUtils.import(
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
const { monthView } = ChromeUtils.import(
const { CalendarTestUtils } = ChromeUtils.import(
"resource://testing-common/calendar/CalendarTestUtils.jsm"
).CalendarTestUtils;
);
const TITLE1 = "Month View Event";
const TITLE2 = "Month View Event Changed";
@ -43,56 +41,63 @@ add_task(async function testMonthView() {
// Create event.
// Thursday of 2009-01-01 should be the selected box in the first row with default settings.
let hour = new Date().getUTCHours(); // Remember time at click.
let eventBox = monthView.getDayBox(controller.window, 1, 5);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
// Check that the start time is correct.
// Next full hour except last hour hour of the day.
let nextHour = hour == 23 ? hour : (hour + 1) % 24;
let someDate = cal.dtz.now();
someDate.resetTo(2009, 0, 1, nextHour, 0, 0, cal.dtz.floating);
let eventBox = CalendarTestUtils.monthView.getDayBox(controller.window, 1, 5);
let { dialogWindow, iframeWindow, iframeDocument } = await CalendarTestUtils.editNewEvent(
window,
eventBox
);
let startPicker = iframeWindow.document.getElementById("event-starttime");
Assert.equal(startPicker._timepicker._inputField.value, cal.dtz.formatter.formatTime(someDate));
Assert.equal(
startPicker._datepicker._inputField.value,
cal.dtz.formatter.formatDateShort(someDate)
);
// Check that the start time is correct.
// Next full hour except last hour hour of the day.
let nextHour = hour == 23 ? hour : (hour + 1) % 24;
let someDate = cal.dtz.now();
someDate.resetTo(2009, 0, 1, nextHour, 0, 0, cal.dtz.floating);
// Fill in title, description and calendar.
await setData(eventWindow, iframeWindow, {
title: TITLE1,
description: DESC,
calendar: CALENDARNAME,
});
let startPicker = iframeDocument.getElementById("event-starttime");
Assert.equal(startPicker._timepicker._inputField.value, cal.dtz.formatter.formatTime(someDate));
Assert.equal(
startPicker._datepicker._inputField.value,
cal.dtz.formatter.formatDateShort(someDate)
);
await saveAndCloseItemDialog(eventWindow);
// Fill in title, description and calendar.
await setData(dialogWindow, iframeWindow, {
title: TITLE1,
description: DESC,
calendar: CALENDARNAME,
});
await saveAndCloseItemDialog(dialogWindow);
// If it was created successfully, it can be opened.
eventBox = await monthView.waitForItemAt(controller.window, 1, 5, 1);
await invokeEditingEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
// Change title and save changes.
await setData(eventWindow, iframeWindow, { title: TITLE2 });
await saveAndCloseItemDialog(eventWindow);
});
({ dialogWindow, iframeWindow } = await CalendarTestUtils.monthView.editItemAt(
controller.window,
1,
5,
1
));
// Change title and save changes.
await setData(dialogWindow, iframeWindow, { title: TITLE2 });
await saveAndCloseItemDialog(dialogWindow);
// Check if name was saved.
eventBox = await TestUtils.waitForCondition(() => {
let newEventBox = monthView.getItemAt(controller.window, 1, 5, 1);
if (newEventBox && newEventBox != eventBox) {
return newEventBox;
let eventName;
await TestUtils.waitForCondition(() => {
eventBox = CalendarTestUtils.monthView.getItemAt(controller.window, 1, 5, 1);
if (!eventBox) {
return false;
}
return false;
});
let eventName = eventBox.querySelector(".event-name-label");
Assert.ok(eventName);
Assert.equal(eventName.textContent, TITLE2);
eventName = eventBox.querySelector(".event-name-label").textContent;
return eventName == TITLE2;
}, "event name did not update in time");
Assert.equal(eventName, TITLE2);
// Delete event.
controller.click(eventBox);
eventBox.focus();
EventUtils.synthesizeKey("VK_DELETE", {}, controller.window);
await monthView.waitForNoItemAt(controller.window, 1, 5, 1);
await CalendarTestUtils.monthView.waitForNoItemAt(controller.window, 1, 5, 1);
Assert.ok(true, "Test ran to completion");
});

Просмотреть файл

@ -9,8 +9,6 @@ var {
createCalendar,
deleteCalendars,
goToDate,
invokeNewEventDialog,
invokeEditingEventDialog,
switchToView,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
var { saveAndCloseItemDialog, setData } = ChromeUtils.import(
@ -19,9 +17,9 @@ var { saveAndCloseItemDialog, setData } = ChromeUtils.import(
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
const { multiweekView } = ChromeUtils.import(
const { CalendarTestUtils } = ChromeUtils.import(
"resource://testing-common/calendar/CalendarTestUtils.jsm"
).CalendarTestUtils;
);
const TITLE1 = "Multiweek View Event";
const TITLE2 = "Multiweek View Event Changed";
@ -43,42 +41,48 @@ add_task(async function setupModule(module) {
// Create event.
// Thursday of 2009-01-01 should be the selected box in the first row with default settings.
let hour = new Date().getUTCHours(); // Remember time at click.
let eventBox = multiweekView.getDayBox(controller.window, 1, 5);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
// Check that the start time is correct.
// Next full hour except last hour hour of the day.
let nextHour = hour == 23 ? hour : (hour + 1) % 24;
let someDate = cal.dtz.now();
someDate.resetTo(2009, 0, 1, nextHour, 0, 0, cal.dtz.floating);
let eventBox = CalendarTestUtils.multiweekView.getDayBox(controller.window, 1, 5);
let { dialogWindow, iframeWindow, iframeDocument } = await CalendarTestUtils.editNewEvent(
window,
eventBox
);
let startPicker = iframeWindow.document.getElementById("event-starttime");
Assert.equal(startPicker._timepicker._inputField.value, cal.dtz.formatter.formatTime(someDate));
Assert.equal(
startPicker._datepicker._inputField.value,
cal.dtz.formatter.formatDateShort(someDate)
);
// Check that the start time is correct.
// Next full hour except last hour hour of the day.
let nextHour = hour == 23 ? hour : (hour + 1) % 24;
let someDate = cal.dtz.now();
someDate.resetTo(2009, 0, 1, nextHour, 0, 0, cal.dtz.floating);
// Fill in title, description and calendar.
await setData(eventWindow, iframeWindow, {
title: TITLE1,
description: DESC,
calendar: CALENDARNAME,
});
let startPicker = iframeDocument.getElementById("event-starttime");
Assert.equal(startPicker._timepicker._inputField.value, cal.dtz.formatter.formatTime(someDate));
Assert.equal(
startPicker._datepicker._inputField.value,
cal.dtz.formatter.formatDateShort(someDate)
);
await saveAndCloseItemDialog(eventWindow);
// Fill in title, description and calendar.
await setData(dialogWindow, iframeWindow, {
title: TITLE1,
description: DESC,
calendar: CALENDARNAME,
});
await saveAndCloseItemDialog(dialogWindow);
// If it was created successfully, it can be opened.
eventBox = await multiweekView.waitForItemAt(controller.window, 1, 5, 1);
await invokeEditingEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
// Change title and save changes.
await setData(eventWindow, iframeWindow, { title: TITLE2 });
await saveAndCloseItemDialog(eventWindow);
});
({ dialogWindow, iframeWindow } = await CalendarTestUtils.multiweekView.editItemAt(
controller.window,
1,
5,
1
));
// Change title and save changes.
await setData(dialogWindow, iframeWindow, { title: TITLE2 });
await saveAndCloseItemDialog(dialogWindow);
// Check if name was saved.
await TestUtils.waitForCondition(() => {
eventBox = multiweekView.getItemAt(controller.window, 1, 5, 1);
eventBox = CalendarTestUtils.multiweekView.getItemAt(controller.window, 1, 5, 1);
if (eventBox === null) {
return false;
}
@ -90,7 +94,7 @@ add_task(async function setupModule(module) {
controller.click(eventBox);
eventBox.focus();
EventUtils.synthesizeKey("VK_DELETE", {}, controller.window);
await multiweekView.waitForNoItemAt(controller.window, 1, 5, 1);
await CalendarTestUtils.multiweekView.waitForNoItemAt(controller.window, 1, 5, 1);
Assert.ok(true, "Test ran to completion");
});

Просмотреть файл

@ -9,8 +9,6 @@ var {
createCalendar,
deleteCalendars,
goToDate,
invokeNewEventDialog,
invokeEditingEventDialog,
switchToView,
} = ChromeUtils.import("resource://testing-common/calendar/CalendarUtils.jsm");
var { saveAndCloseItemDialog, setData } = ChromeUtils.import(
@ -19,9 +17,9 @@ var { saveAndCloseItemDialog, setData } = ChromeUtils.import(
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
const { weekView } = ChromeUtils.import(
const { CalendarTestUtils } = ChromeUtils.import(
"resource://testing-common/calendar/CalendarTestUtils.jsm"
).CalendarTestUtils;
);
var TITLE1 = "Week View Event";
var TITLE2 = "Week View Event Changed";
@ -42,54 +40,60 @@ add_task(async function testWeekView() {
// Create event at 8 AM.
// Thursday of 2009-01-01 is 4th with default settings.
let eventBox = weekView.getHourBoxAt(controller.window, 5, 8);
await invokeNewEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
// Check that the start time is correct.
let someDate = cal.createDateTime();
someDate.resetTo(2009, 0, 1, 8, 0, 0, cal.dtz.floating);
let eventBox = CalendarTestUtils.weekView.getHourBoxAt(controller.window, 5, 8);
let { dialogWindow, iframeWindow, iframeDocument } = await CalendarTestUtils.editNewEvent(
window,
eventBox
);
let startPicker = iframeWindow.document.getElementById("event-starttime");
Assert.equal(startPicker._timepicker._inputField.value, cal.dtz.formatter.formatTime(someDate));
Assert.equal(
startPicker._datepicker._inputField.value,
cal.dtz.formatter.formatDateShort(someDate)
);
// Check that the start time is correct.
let someDate = cal.createDateTime();
someDate.resetTo(2009, 0, 1, 8, 0, 0, cal.dtz.floating);
// Fill in title, description and calendar.
await setData(eventWindow, iframeWindow, {
title: TITLE1,
description: DESC,
calendar: CALENDARNAME,
});
let startPicker = iframeDocument.getElementById("event-starttime");
Assert.equal(startPicker._timepicker._inputField.value, cal.dtz.formatter.formatTime(someDate));
Assert.equal(
startPicker._datepicker._inputField.value,
cal.dtz.formatter.formatDateShort(someDate)
);
await saveAndCloseItemDialog(eventWindow);
// Fill in title, description and calendar.
await setData(dialogWindow, iframeWindow, {
title: TITLE1,
description: DESC,
calendar: CALENDARNAME,
});
await saveAndCloseItemDialog(dialogWindow);
// If it was created successfully, it can be opened.
eventBox = await weekView.waitForEventBoxAt(controller.window, 5, 1);
await invokeEditingEventDialog(window, eventBox, async (eventWindow, iframeWindow) => {
// Change title and save changes.
await setData(eventWindow, iframeWindow, { title: TITLE2 });
await saveAndCloseItemDialog(eventWindow);
});
({ dialogWindow, iframeWindow } = await CalendarTestUtils.weekView.editEventAt(
controller.window,
5,
1
));
// Change title and save changes.
await setData(dialogWindow, iframeWindow, { title: TITLE2 });
await saveAndCloseItemDialog(dialogWindow);
// Check if name was saved.
eventBox = await TestUtils.waitForCondition(() => {
let newEventBox = weekView.getEventBoxAt(controller.window, 5, 1);
if (newEventBox && newEventBox != eventBox) {
return newEventBox;
let eventName;
await TestUtils.waitForCondition(() => {
eventBox = CalendarTestUtils.weekView.getEventBoxAt(controller.window, 5, 1);
if (!eventBox) {
return false;
}
return false;
});
let eventName = eventBox.querySelector(".event-name-label");
Assert.ok(eventName);
Assert.equal(eventName.textContent, TITLE2);
eventName = eventBox.querySelector(".event-name-label").textContent;
return eventName == TITLE2;
}, "event name did not update in time");
Assert.equal(eventName, TITLE2);
// Delete event.
controller.click(eventBox);
eventBox.focus();
EventUtils.synthesizeKey("VK_DELETE", {}, controller.window);
await weekView.waitForNoEventBoxAt(controller.window, 5, 1);
await CalendarTestUtils.weekView.waitForNoEventBoxAt(controller.window, 5, 1);
Assert.ok(true, "Test ran to completion");
});