Bug 1495380 - Rename head-usb-mocks to head-mocks to prepare for network mocks;r=ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 30 Nov 2018 15:55:28 +0000
changeset 505411 5cbf345f59e22896245f7b4bf948189af02ab845
parent 505410 9d5cf15c67fcd7ccb5c3debd8766ec92736289e5
child 505412 77a11b6a13ec51370c1d3bec60d9b77783fb90e0
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersladybenko
bugs1495380
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1495380 - Rename head-usb-mocks to head-mocks to prepare for network mocks;r=ladybenko Depends on D12945 Differential Revision: https://phabricator.services.mozilla.com/D12946
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_usb_runtime.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime_connect.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime_refresh.js
devtools/client/aboutdebugging-new/test/browser/head-mocks.js
devtools/client/aboutdebugging-new/test/browser/mocks/head-usb-mocks.js
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -3,16 +3,17 @@ tags = devtools
 subsuite = devtools
 prefs =
   # showSystemAddons has different values depending on the build flags,
   # ensure consistent test behavior by always setting this to false.
   devtools.aboutdebugging.showSystemAddons=false
 support-files =
   debug-target-pane_collapsibilities_head.js
   head-addons-script.js
+  head-mocks.js
   head.js
   mocks/*
   resources/test-adb-extension/*
   resources/test-temporary-extension/*
   test-tab-favicons.html
   !/devtools/client/shared/test/shared-head.js
   !/devtools/client/shared/test/shared-redux-head.js
   !/devtools/client/shared/test/telemetry-test-helpers.js
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_usb_runtime.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_usb_runtime.js
@@ -2,32 +2,32 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const RUNTIME_ID = "test-runtime-id";
 const RUNTIME_DEVICE_NAME = "test device name";
 const RUNTIME_APP_NAME = "TestApp";
 
-/* import-globals-from mocks/head-usb-mocks.js */
-Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "mocks/head-usb-mocks.js", this);
+/* import-globals-from head-mocks.js */
+Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
 
 // Test that addons are displayed and updated for USB runtimes when expected.
 add_task(async function() {
-  const usbMocks = new UsbMocks();
-  usbMocks.enableMocks();
-  registerCleanupFunction(() => usbMocks.disableMocks());
+  const mocks = new Mocks();
+  mocks.enableMocks();
+  registerCleanupFunction(() => mocks.disableMocks());
 
   const { document, tab } = await openAboutDebugging();
 
-  const usbClient = usbMocks.createRuntime(RUNTIME_ID, {
+  const usbClient = mocks.createUSBRuntime(RUNTIME_ID, {
     deviceName: RUNTIME_DEVICE_NAME,
     name: RUNTIME_APP_NAME,
   });
-  usbMocks.emitUpdate();
+  mocks.emitUSBUpdate();
 
   await connectToRuntime(RUNTIME_DEVICE_NAME, document);
   await selectRuntime(RUNTIME_DEVICE_NAME, RUNTIME_APP_NAME, document);
 
   const extensionPane = getDebugTargetPane("Extensions", document);
   info("Check an empty target pane message is displayed");
   ok(extensionPane.querySelector(".js-debug-target-list-empty"),
     "Extensions list is empty");
@@ -46,17 +46,17 @@ add_task(async function() {
   // The goal here is to check that USB runtimes addons are only updated when the USB
   // runtime is sending addonListChanged events. The reason for this test is because the
   // previous implementation was updating the USB runtime extensions list when the _local_
   // AddonManager was updated.
   info("Remove the extension from the remote client WITHOUT sending an event");
   usbClient.listAddons = () => [];
 
   info("Simulate an addon update on the ThisFirefox client");
-  usbMocks.thisFirefoxClient._eventEmitter.emit("addonListChanged");
+  mocks.thisFirefoxClient._eventEmitter.emit("addonListChanged");
 
   // To avoid wait for a set period of time we trigger another async update, adding a new
   // tab. We assume that if the addon update mechanism had started, it would also be done
   // when the new tab was processed.
   info("Wait until the tab target for 'http://some.random/url.com' appears");
   const testTab = { outerWindowID: 0, url: "http://some.random/url.com" };
   usbClient.listTabs = () => ({ tabs: [testTab] });
   usbClient._eventEmitter.emit("tabListChanged");
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js
@@ -2,34 +2,34 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const RUNTIME_ID = "test-runtime-id";
 const RUNTIME_DEVICE_NAME = "test device name";
 const RUNTIME_APP_NAME = "TestApp";
 
-/* import-globals-from mocks/head-usb-mocks.js */
-Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "mocks/head-usb-mocks.js", this);
+/* import-globals-from head-mocks.js */
+Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
 
 // Test that the expected supported categories are displayed for USB runtimes.
 add_task(async function() {
-  const usbMocks = new UsbMocks();
-  usbMocks.enableMocks();
+  const mocks = new Mocks();
+  mocks.enableMocks();
   registerCleanupFunction(() => {
-    usbMocks.disableMocks();
+    mocks.disableMocks();
   });
 
   const { document, tab } = await openAboutDebugging();
 
-  usbMocks.createRuntime(RUNTIME_ID, {
+  mocks.createUSBRuntime(RUNTIME_ID, {
     deviceName: RUNTIME_DEVICE_NAME,
     name: RUNTIME_APP_NAME,
   });
-  usbMocks.emitUpdate();
+  mocks.emitUSBUpdate();
 
   await connectToRuntime(RUNTIME_DEVICE_NAME, document);
   await selectRuntime(RUNTIME_DEVICE_NAME, RUNTIME_APP_NAME, document);
 
   const SUPPORTED_TARGET_PANES = [
     "Extensions",
     "Tabs",
   ];
@@ -39,16 +39,16 @@ add_task(async function() {
     if (SUPPORTED_TARGET_PANES.includes(title)) {
       ok(debugTargetPaneEl, `Supported target pane [${title}] is displayed`);
     } else {
       ok(!debugTargetPaneEl, `Unsupported target pane [${title}] is hidden`);
     }
   }
 
   info("Remove USB runtime");
-  usbMocks.removeRuntime(RUNTIME_ID);
-  usbMocks.emitUpdate();
+  mocks.removeUSBRuntime(RUNTIME_ID);
+  mocks.emitUSBUpdate();
 
   info("Wait until the USB sidebar item disappears");
   await waitUntil(() => !findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
 
   await removeTab(tab);
 });
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime_connect.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime_connect.js
@@ -1,43 +1,43 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
-/* import-globals-from mocks/head-usb-mocks.js */
-Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "mocks/head-usb-mocks.js", this);
+/* import-globals-from head-mocks.js */
+Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
 
 const RUNTIME_ID = "test-runtime-id";
 const RUNTIME_DEVICE_NAME = "test device name";
 
 // Test that USB runtimes appear and disappear from the sidebar.
 add_task(async function() {
-  const usbMocks = new UsbMocks();
-  usbMocks.enableMocks();
+  const mocks = new Mocks();
+  mocks.enableMocks();
   registerCleanupFunction(() => {
-    usbMocks.disableMocks();
+    mocks.disableMocks();
   });
 
   const { document, tab } = await openAboutDebugging();
 
-  usbMocks.createRuntime(RUNTIME_ID, { deviceName: RUNTIME_DEVICE_NAME });
-  usbMocks.emitUpdate();
+  mocks.createUSBRuntime(RUNTIME_ID, { deviceName: RUNTIME_DEVICE_NAME });
+  mocks.emitUSBUpdate();
 
   info("Wait until the USB sidebar item appears");
   await waitUntil(() => findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
   const usbRuntimeSidebarItem = findSidebarItemByText(RUNTIME_DEVICE_NAME, document);
   const connectButton = usbRuntimeSidebarItem.querySelector(".js-connect-button");
   ok(connectButton, "Connect button is displayed for the USB runtime");
 
   info("Click on the connect button and wait until it disappears");
   connectButton.click();
   await waitUntil(() => !usbRuntimeSidebarItem.querySelector(".js-connect-button"));
 
   info("Remove all USB runtimes");
-  usbMocks.removeRuntime(RUNTIME_ID);
-  usbMocks.emitUpdate();
+  mocks.removeUSBRuntime(RUNTIME_ID);
+  mocks.emitUSBUpdate();
 
   info("Wait until the USB sidebar item disappears");
   await waitUntil(() => !findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
 
   await removeTab(tab);
 });
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime_refresh.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_runtime_refresh.js
@@ -5,44 +5,44 @@
 
 const RUNTIME_ID = "test-runtime-id";
 const RUNTIME_DEVICE_NAME = "test device name";
 const RUNTIME_APP_NAME = "TestApp";
 
 const OTHER_RUNTIME_ID = "other-runtime-id";
 const OTHER_RUNTIME_APP_NAME = "OtherApp";
 
-/* import-globals-from mocks/head-usb-mocks.js */
-Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "mocks/head-usb-mocks.js", this);
+/* import-globals-from head-mocks.js */
+Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
 
 // Test that USB runtimes are ot disconnected on refresh.
 add_task(async function() {
-  const usbMocks = new UsbMocks();
-  usbMocks.enableMocks();
-  registerCleanupFunction(() => usbMocks.disableMocks());
+  const mocks = new Mocks();
+  mocks.enableMocks();
+  registerCleanupFunction(() => mocks.disableMocks());
 
   const { document, tab } = await openAboutDebugging();
 
   info("Create a first runtime and connect to it");
-  usbMocks.createRuntime(RUNTIME_ID, {
+  mocks.createUSBRuntime(RUNTIME_ID, {
     deviceName: RUNTIME_DEVICE_NAME,
     name: RUNTIME_APP_NAME,
   });
-  usbMocks.emitUpdate();
+  mocks.emitUSBUpdate();
 
   await connectToRuntime(RUNTIME_DEVICE_NAME, document);
   await selectRuntime(RUNTIME_DEVICE_NAME, RUNTIME_APP_NAME, document);
 
   info("Create a second runtime and click on Refresh Devices");
-  usbMocks.createRuntime(OTHER_RUNTIME_ID, {
+  mocks.createUSBRuntime(OTHER_RUNTIME_ID, {
     deviceName: OTHER_RUNTIME_APP_NAME,
   });
 
   // Mock the refreshUSBRuntimes to emit an update.
-  usbMocks.usbRuntimesMock.refreshUSBRuntimes = () => usbMocks.emitUpdate();
+  mocks.usbRuntimesMock.refreshUSBRuntimes = () => mocks.emitUSBUpdate();
   document.querySelector(".js-refresh-devices-button").click();
 
   info(`Wait until the sidebar item for ${OTHER_RUNTIME_APP_NAME} appears`);
   await waitUntil(() => findSidebarItemByText(OTHER_RUNTIME_APP_NAME, document));
 
   const sidebarItem = findSidebarItemByText(RUNTIME_DEVICE_NAME, document);
   ok(!sidebarItem.querySelector(".js-connect-button"),
     "Original USB runtime is still connected");
rename from devtools/client/aboutdebugging-new/test/browser/mocks/head-usb-mocks.js
rename to devtools/client/aboutdebugging-new/test/browser/head-mocks.js
--- a/devtools/client/aboutdebugging-new/test/browser/mocks/head-usb-mocks.js
+++ b/devtools/client/aboutdebugging-new/test/browser/head-mocks.js
@@ -2,29 +2,29 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const MOCKS_ROOT = CHROME_URL_ROOT + "mocks/";
 
 const { RUNTIMES } = require("devtools/client/aboutdebugging-new/src/constants");
 
-/* import-globals-from head-client-wrapper-mock.js */
+/* import-globals-from mocks/head-client-wrapper-mock.js */
 Services.scriptloader.loadSubScript(MOCKS_ROOT + "head-client-wrapper-mock.js", this);
-/* import-globals-from head-runtime-client-factory-mock.js */
+/* import-globals-from mocks/head-runtime-client-factory-mock.js */
 Services.scriptloader.loadSubScript(MOCKS_ROOT + "head-runtime-client-factory-mock.js",
   this);
-/* import-globals-from head-usb-runtimes-mock.js */
+/* import-globals-from mocks/head-usb-runtimes-mock.js */
 Services.scriptloader.loadSubScript(MOCKS_ROOT + "head-usb-runtimes-mock.js", this);
 
 /**
  * This wrapper around the USB mocks used in about:debugging tests provides helpers to
  * quickly setup mocks for typical USB runtime tests.
  */
-class UsbMocks {
+class Mocks {
   constructor() {
     // Setup the usb-runtimes mock to rely on the internal _runtimes array.
     this.usbRuntimesMock = createUsbRuntimesMock();
     this._runtimes = [];
     this.usbRuntimesMock.getUSBRuntimes = () => {
       return this._runtimes;
     };
 
@@ -59,17 +59,17 @@ class UsbMocks {
     enableRuntimeClientFactoryMock(this.runtimeClientFactoryMock);
   }
 
   disableMocks() {
     disableUsbRuntimesMock();
     disableRuntimeClientFactoryMock();
   }
 
-  emitUpdate() {
+  emitUSBUpdate() {
     this._observerMock.emit("runtime-list-updated");
   }
 
   /**
    * Creates a USB runtime for which a client conenction can be established.
    * @param {String} id
    *        The id of the runtime.
    * @param {Object} optional object used to create the fake runtime & device
@@ -77,17 +77,17 @@ class UsbMocks {
    *        - shortName: {String} Short name for the device
    *        - name: {String} Application name, for instance "Firefox"
    *        - channel: {String} Release channel, for instance "release", "nightly"
    *        - version: {String} Version, for instance "63.0a"
    *        - socketPath: {String} (should only be used for connecting, so not here)
    * @return {Object} Returns the mock client created for this runtime so that methods
    * can be overridden on it.
    */
-  createRuntime(id, runtimeInfo = {}) {
+  createUSBRuntime(id, runtimeInfo = {}) {
     // Add a new runtime to the list of scanned runtimes.
     this._runtimes.push({
       id: id,
       _socketPath: runtimeInfo.socketPath || "test/path",
       deviceName: runtimeInfo.deviceName || "test device name",
       shortName: runtimeInfo.shortName || "testshort",
     });
 
@@ -100,13 +100,13 @@ class UsbMocks {
         version: runtimeInfo.version || "1.0",
       };
     };
     this._clients[id] = mockUsbClient;
 
     return mockUsbClient;
   }
 
-  removeRuntime(id) {
+  removeUSBRuntime(id) {
     this._runtimes = this._runtimes.filter(runtime => runtime.id !== id);
     delete this._clients[id];
   }
 }