mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 1508956 - Migrate sidebar_usb_runtime to use head_mocks;r=daisuke
Depends on D14309. Relying on head_mocks will make it easier to update the mocks when we start calling isUnknown() on our USB runtimes. Differential Revision: https://phabricator.services.mozilla.com/D14310 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
eff4be5306
commit
c34f54849f
@ -1,36 +1,22 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
/* import-globals-from mocks/head-usb-runtimes-mock.js */
|
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Load USB Runtimes mock module
|
/* import-globals-from head-mocks.js */
|
||||||
Services.scriptloader.loadSubScript(
|
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||||
CHROME_URL_ROOT + "mocks/head-usb-runtimes-mock.js", this);
|
|
||||||
|
|
||||||
// Test that USB runtimes appear and disappear from the sidebar.
|
// Test that USB runtimes appear and disappear from the sidebar.
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const usbRuntimesMock = createUsbRuntimesMock();
|
const mocks = new Mocks();
|
||||||
const observerMock = addObserverMock(usbRuntimesMock);
|
|
||||||
enableUsbRuntimesMock(usbRuntimesMock);
|
|
||||||
|
|
||||||
// Disable our mock when the test ends.
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
disableUsbRuntimesMock();
|
|
||||||
});
|
|
||||||
|
|
||||||
const { document, tab } = await openAboutDebugging();
|
const { document, tab } = await openAboutDebugging();
|
||||||
|
|
||||||
usbRuntimesMock.getUSBRuntimes = function() {
|
mocks.createUSBRuntime("test_device_id", {
|
||||||
return [{
|
deviceName: "test device name",
|
||||||
id: "test_device_id",
|
shortName: "testshort",
|
||||||
_socketPath: "test/path",
|
});
|
||||||
deviceName: "test device name",
|
mocks.emitUSBUpdate();
|
||||||
shortName: "testshort",
|
|
||||||
}];
|
|
||||||
};
|
|
||||||
observerMock.emit("runtime-list-updated");
|
|
||||||
|
|
||||||
info("Wait until the USB sidebar item appears");
|
info("Wait until the USB sidebar item appears");
|
||||||
await waitUntil(() => findSidebarItemByText("test device name", document));
|
await waitUntil(() => findSidebarItemByText("test device name", document));
|
||||||
@ -38,10 +24,8 @@ add_task(async function() {
|
|||||||
ok(usbRuntimeSidebarItem.textContent.includes("testshort"),
|
ok(usbRuntimeSidebarItem.textContent.includes("testshort"),
|
||||||
"The short name of the usb runtime is visible");
|
"The short name of the usb runtime is visible");
|
||||||
|
|
||||||
usbRuntimesMock.getUSBRuntimes = function() {
|
mocks.removeUSBRuntime("test_device_id");
|
||||||
return [];
|
mocks.emitUSBUpdate();
|
||||||
};
|
|
||||||
observerMock.emit("runtime-list-updated");
|
|
||||||
|
|
||||||
info("Wait until the USB sidebar item disappears");
|
info("Wait until the USB sidebar item disappears");
|
||||||
await waitUntil(() => !findSidebarItemByText("test device name", document));
|
await waitUntil(() => !findSidebarItemByText("test device name", document));
|
||||||
|
Loading…
Reference in New Issue
Block a user