From c34f54849f6f051bc51ea4840d6885fadabb9643 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Wed, 19 Dec 2018 18:07:41 +0000 Subject: [PATCH] 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 --- ...wser_aboutdebugging_sidebar_usb_runtime.js | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime.js b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime.js index 264f7e923215..404727b9f364 100644 --- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime.js +++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime.js @@ -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));