Bug 1752389 - Use CalendarTestUtils.createCalendar to create calendars in tests. r=darktrojan
Differential Revision: https://phabricator.services.mozilla.com/D137188
This commit is contained in:
Родитель
ba930a418c
Коммит
84bc229a28
|
@ -119,11 +119,8 @@ add_task(async () => {
|
|||
await dialogPromise;
|
||||
|
||||
// Add some new calendars, check their properties.
|
||||
let uri = Services.io.newURI("moz-memory-calendar://");
|
||||
for (let i = 1; i <= 3; i++) {
|
||||
calendars[i] = manager.createCalendar("memory", uri);
|
||||
calendars[i].name = `Mochitest ${i}`;
|
||||
manager.registerCalendar(calendars[i]);
|
||||
calendars[i] = CalendarTestUtils.createCalendar(`Mochitest ${i}`, "memory");
|
||||
}
|
||||
|
||||
Assert.equal(manager.getCalendars().length, 4);
|
||||
|
@ -312,7 +309,7 @@ add_task(async () => {
|
|||
// Test deleting calendars.
|
||||
|
||||
// Delete a calendar by unregistering it.
|
||||
manager.unregisterCalendar(calendars[3]);
|
||||
CalendarTestUtils.removeCalendar(calendars[3]);
|
||||
Assert.equal(manager.getCalendars().length, 3);
|
||||
Assert.equal(calendarList.rowCount, 3);
|
||||
checkSortOrder(0, 1, 2);
|
||||
|
|
|
@ -15,16 +15,12 @@ let { TelemetryTestUtils } = ChromeUtils.import("resource://testing-common/Telem
|
|||
add_task(async function test_calendar_count() {
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
let manager = cal.getCalendarManager();
|
||||
let uri = Services.io.newURI("moz-memory-calendar://");
|
||||
let calendars = manager.getCalendars();
|
||||
let calendars = cal.getCalendarManager().getCalendars();
|
||||
for (let i = 1; i <= 3; i++) {
|
||||
calendars[i] = manager.createCalendar("memory", uri);
|
||||
calendars[i].name = `Mochitest ${i}`;
|
||||
calendars[i] = CalendarTestUtils.createCalendar(`Mochitest ${i}`, "memory");
|
||||
if (i === 1 || i === 3) {
|
||||
calendars[i].readOnly = true;
|
||||
}
|
||||
manager.registerCalendar(calendars[i]);
|
||||
}
|
||||
|
||||
reportCalendars();
|
||||
|
@ -43,6 +39,6 @@ add_task(async function test_calendar_count() {
|
|||
|
||||
// Clean up.
|
||||
for (let i = 1; i <= 3; i++) {
|
||||
manager.removeCalendar(calendars[i]);
|
||||
CalendarTestUtils.removeCalendar(calendars[i]);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -4,11 +4,9 @@ var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
|||
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
|
||||
|
||||
add_task(async () => {
|
||||
let manager = cal.getCalendarManager();
|
||||
let calendar = manager.createCalendar("memory", Services.io.newURI("moz-memory-calendar://"));
|
||||
let calendar = CalendarTestUtils.createCalendar("Mochitest", "memory");
|
||||
calendar.name = "Mochitest";
|
||||
calendar.setProperty("organizerId", "mailto:mochitest@invalid");
|
||||
manager.registerCalendar(calendar);
|
||||
|
||||
let freeBusyService = cal.getFreeBusyService();
|
||||
freeBusyService.addProvider(freeBusyProvider);
|
||||
|
@ -51,7 +49,7 @@ add_task(async () => {
|
|||
};
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
manager.unregisterCalendar(calendar);
|
||||
CalendarTestUtils.removeCalendar(calendar);
|
||||
freeBusyService.removeProvider(freeBusyProvider);
|
||||
MailServices.ab.deleteAddressBook(book.URI);
|
||||
});
|
||||
|
@ -260,14 +258,11 @@ add_task(async () => {
|
|||
});
|
||||
|
||||
add_task(async () => {
|
||||
let manager = cal.getCalendarManager();
|
||||
let calendar = manager.createCalendar("memory", Services.io.newURI("moz-memory-calendar://"));
|
||||
calendar.name = "Mochitest";
|
||||
let calendar = CalendarTestUtils.createCalendar("Mochitest", "memory");
|
||||
calendar.setProperty("organizerId", "mailto:mochitest@invalid");
|
||||
manager.registerCalendar(calendar);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
manager.unregisterCalendar(calendar);
|
||||
CalendarTestUtils.removeCalendar(calendar);
|
||||
});
|
||||
|
||||
let defaults = {
|
||||
|
|
|
@ -10,17 +10,17 @@ var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
|||
var { PluralForm } = ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var { CalendarTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/calendar/CalendarTestUtils.jsm"
|
||||
);
|
||||
|
||||
const DEFVALUE = 43;
|
||||
|
||||
add_task(async function testDefaultAlarms() {
|
||||
let manager = cal.getCalendarManager();
|
||||
let calendar = manager.createCalendar("memory", Services.io.newURI("moz-memory-calendar://"));
|
||||
calendar.name = "Mochitest";
|
||||
let calendar = CalendarTestUtils.createCalendar("Mochitest", "memory");
|
||||
calendar.setProperty("calendar-main-default", true);
|
||||
manager.registerCalendar(calendar);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
manager.unregisterCalendar(calendar);
|
||||
CalendarTestUtils.removeCalendar(calendar);
|
||||
});
|
||||
|
||||
let localeUnitString = cal.l10n.getCalString("unitDays");
|
||||
|
|
|
@ -4,14 +4,15 @@
|
|||
|
||||
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
var { CalendarTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/calendar/CalendarTestUtils.jsm"
|
||||
);
|
||||
|
||||
add_task(async function testCategoryColors() {
|
||||
let manager = cal.getCalendarManager();
|
||||
let calendar = manager.createCalendar("memory", Services.io.newURI("moz-memory-calendar://"));
|
||||
calendar.name = "Mochitest";
|
||||
manager.registerCalendar(calendar);
|
||||
let calendar = CalendarTestUtils.createCalendar("Mochitest", "memory");
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
manager.unregisterCalendar(calendar);
|
||||
CalendarTestUtils.removeCalendar(calendar);
|
||||
});
|
||||
|
||||
let { prefsWindow, prefsDocument } = await openNewPrefsTab("paneCalendar", "categorieslist");
|
||||
|
|
|
@ -9,13 +9,10 @@
|
|||
|
||||
const { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
const manager = cal.getCalendarManager();
|
||||
const calendar = manager.createCalendar("memory", Services.io.newURI("moz-memory-calendar://"));
|
||||
calendar.name = "Minimonths";
|
||||
const calendar = CalendarTestUtils.createCalendar("Minimonths", "memory");
|
||||
|
||||
manager.registerCalendar(calendar);
|
||||
registerCleanupFunction(() => {
|
||||
manager.unregisterCalendar(calendar);
|
||||
CalendarTestUtils.removeCalendar(calendar);
|
||||
});
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
|
|
@ -7,23 +7,15 @@
|
|||
const { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
const { CalEvent } = ChromeUtils.import("resource:///modules/CalEvent.jsm");
|
||||
|
||||
let manager = cal.getCalendarManager();
|
||||
let composite = cal.view.getCompositeCalendar(window);
|
||||
|
||||
// This is the calendar we're going to change the properties of.
|
||||
let thisCalendar = manager.createCalendar("memory", Services.io.newURI("moz-memory-calendar://"));
|
||||
thisCalendar.name = `This Calendar`;
|
||||
let thisCalendar = CalendarTestUtils.createCalendar("This Calendar", "memory");
|
||||
thisCalendar.setProperty("color", "#ffee22");
|
||||
manager.registerCalendar(thisCalendar);
|
||||
|
||||
// This calendar isn't going to change, and we'll check it doesn't.
|
||||
let notThisCalendar = manager.createCalendar(
|
||||
"memory",
|
||||
Services.io.newURI("moz-memory-calendar://")
|
||||
);
|
||||
notThisCalendar.name = `Not This Calendar`;
|
||||
let notThisCalendar = CalendarTestUtils.createCalendar("Not This Calendar", "memory");
|
||||
notThisCalendar.setProperty("color", "#dd3333");
|
||||
manager.registerCalendar(notThisCalendar);
|
||||
|
||||
add_task(async function setUp() {
|
||||
let { dedent } = CalendarTestUtils;
|
||||
|
@ -260,6 +252,6 @@ add_task(async function testDayView() {
|
|||
});
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
manager.unregisterCalendar(thisCalendar);
|
||||
manager.unregisterCalendar(notThisCalendar);
|
||||
CalendarTestUtils.removeCalendar(thisCalendar);
|
||||
CalendarTestUtils.removeCalendar(notThisCalendar);
|
||||
});
|
||||
|
|
|
@ -42,20 +42,16 @@ class TestCalFilter extends CalFilterMixin(class {}) {
|
|||
}
|
||||
}
|
||||
|
||||
let manager, calendar, testWidget;
|
||||
let calendar, testWidget;
|
||||
let testItems = {};
|
||||
let addedTestItems = {};
|
||||
|
||||
add_task(async function setUp() {
|
||||
await new Promise(resolve => do_calendar_startup(resolve));
|
||||
|
||||
manager = cal.getCalendarManager();
|
||||
|
||||
calendar = manager.createCalendar("storage", Services.io.newURI(`moz-storage-calendar://`));
|
||||
calendar.name = "test";
|
||||
calendar = CalendarTestUtils.createCalendar("test", "storage");
|
||||
calendar.setProperty("calendar-main-in-composite", true);
|
||||
Assert.ok(!calendar.getProperty("disabled"));
|
||||
manager.registerCalendar(calendar);
|
||||
|
||||
testWidget = new TestCalFilter();
|
||||
testWidget.startDate = cal.createDateTime("20210801");
|
||||
|
|
Загрузка…
Ссылка в новой задаче