Bug 1770237: Part 9 - Update VacuumParticipant test mocks to not use chrome manifests for registration. r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D148189
This commit is contained in:
Kris Maglione 2022-06-22 20:31:34 +00:00
Родитель 360a2f6d5c
Коммит 97ceba4b1d
4 изменённых файлов: 24 добавлений и 31 удалений

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

@ -4,9 +4,8 @@
// This testing component is used in test_vacuum* tests.
const { ComponentUtils } = ChromeUtils.import(
"resource://gre/modules/ComponentUtils.jsm"
);
var EXPORTED_SYMBOLS = ["VacuumParticipant"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
/**
@ -27,16 +26,12 @@ function getDatabase(aFile) {
return Services.storage.openDatabase(aFile);
}
function vacuumParticipant() {
function VacuumParticipant() {
this._dbConn = getDatabase(new_db_file("testVacuum"));
Services.obs.addObserver(this, "test-options");
}
vacuumParticipant.prototype = {
classDescription: "vacuumParticipant",
classID: Components.ID("{52aa0b22-b82f-4e38-992a-c3675a3355d2}"),
contractID: "@unit.test.com/test-vacuum-participant;1",
VacuumParticipant.prototype = {
get expectedDatabasePageSize() {
return this._dbConn.defaultPageSize;
},
@ -105,6 +100,3 @@ vacuumParticipant.prototype = {
"nsIObserver",
]),
};
var gComponentsArray = [vacuumParticipant];
this.NSGetFactory = ComponentUtils.generateNSGetFactory(gComponentsArray);

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

@ -4,6 +4,10 @@
// This file tests the Vacuum Manager.
const { MockRegistrar } = ChromeUtils.import(
"resource://testing-common/MockRegistrar.jsm"
);
/**
* Loads a test component that will register as a vacuum-participant.
* If other participants are found they will be unregistered, to avoid conflicts
@ -11,27 +15,28 @@
*/
function load_test_vacuum_component() {
const CATEGORY_NAME = "vacuum-participant";
const CONTRACT_ID = "@unit.test.com/test-vacuum-participant;1";
do_load_manifest("vacuumParticipant.manifest");
MockRegistrar.registerJSM(
CONTRACT_ID,
"resource://test/VacuumParticipant.jsm",
"VacuumParticipant"
);
// This is a lazy check, there could be more participants than just this test
// we just mind that the test exists though.
const EXPECTED_ENTRIES = ["vacuumParticipant"];
let { catMan } = Services;
let found = false;
// Temporary unregister other participants for this test.
for (let { data: entry } of catMan.enumerateCategory(CATEGORY_NAME)) {
print("Check if the found category entry (" + entry + ") is expected.");
if (EXPECTED_ENTRIES.includes(entry)) {
print("Check that only one test entry exists.");
Assert.ok(!found);
found = true;
} else {
// Temporary unregister other participants for this test.
catMan.deleteCategoryEntry("vacuum-participant", entry, false);
}
catMan.deleteCategoryEntry("vacuum-participant", entry, false);
}
catMan.addCategoryEntry(
CATEGORY_NAME,
"vacuumParticipant",
CONTRACT_ID,
false,
false
);
print("Check the test entry exists.");
Assert.ok(found);
}
/**

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

@ -1,3 +0,0 @@
component {52aa0b22-b82f-4e38-992a-c3675a3355d2} vacuumParticipant.js
contract @unit.test.com/test-vacuum-participant;1 {52aa0b22-b82f-4e38-992a-c3675a3355d2}
category vacuum-participant vacuumParticipant @unit.test.com/test-vacuum-participant;1

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

@ -6,8 +6,7 @@ support-files =
fakeDB.sqlite
goodDB.sqlite
locale_collation.txt
vacuumParticipant.js
vacuumParticipant.manifest
VacuumParticipant.jsm
[test_retry_on_busy.js]
[test_bug-365166.js]