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.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* import-globals-from mocks/head-usb-runtimes-mock.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Load USB Runtimes mock module
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "mocks/head-usb-runtimes-mock.js", this);
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
|
||||
// Test that USB runtimes appear and disappear from the sidebar.
|
||||
add_task(async function() {
|
||||
const usbRuntimesMock = createUsbRuntimesMock();
|
||||
const observerMock = addObserverMock(usbRuntimesMock);
|
||||
enableUsbRuntimesMock(usbRuntimesMock);
|
||||
|
||||
// Disable our mock when the test ends.
|
||||
registerCleanupFunction(() => {
|
||||
disableUsbRuntimesMock();
|
||||
});
|
||||
const mocks = new Mocks();
|
||||
|
||||
const { document, tab } = await openAboutDebugging();
|
||||
|
||||
usbRuntimesMock.getUSBRuntimes = function() {
|
||||
return [{
|
||||
id: "test_device_id",
|
||||
_socketPath: "test/path",
|
||||
deviceName: "test device name",
|
||||
shortName: "testshort",
|
||||
}];
|
||||
};
|
||||
observerMock.emit("runtime-list-updated");
|
||||
mocks.createUSBRuntime("test_device_id", {
|
||||
deviceName: "test device name",
|
||||
shortName: "testshort",
|
||||
});
|
||||
mocks.emitUSBUpdate();
|
||||
|
||||
info("Wait until the USB sidebar item appears");
|
||||
await waitUntil(() => findSidebarItemByText("test device name", document));
|
||||
@ -38,10 +24,8 @@ add_task(async function() {
|
||||
ok(usbRuntimeSidebarItem.textContent.includes("testshort"),
|
||||
"The short name of the usb runtime is visible");
|
||||
|
||||
usbRuntimesMock.getUSBRuntimes = function() {
|
||||
return [];
|
||||
};
|
||||
observerMock.emit("runtime-list-updated");
|
||||
mocks.removeUSBRuntime("test_device_id");
|
||||
mocks.emitUSBUpdate();
|
||||
|
||||
info("Wait until the USB sidebar item disappears");
|
||||
await waitUntil(() => !findSidebarItemByText("test device name", document));
|
||||
|
Loading…
Reference in New Issue
Block a user