Bug 1505289 - Mock adb instead of usb-runtimes in aboutdebugging tests r=Ola,ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 15 Apr 2019 22:25:21 +0000
changeset 469622 c3aea0459e5c
parent 469621 3b2597e84231
child 469623 5b4e9571635e
push id35878
push userapavel@mozilla.com
push dateTue, 16 Apr 2019 15:43:40 +0000
treeherdermozilla-central@258af4e91151 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersOla, ladybenko
bugs1505289
milestone68.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 1505289 - Mock adb instead of usb-runtimes in aboutdebugging tests r=Ola,ladybenko Depends on D25782 Mocking adb instead of usb-runtimes module. Now that usb-runtimes has more logic, it makes sense to test it in our mochitests. Differential Revision: https://phabricator.services.mozilla.com/D25783
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_persist_connection.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_process_category.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_process_main.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_runtime_usbclient_closed.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_connection_state.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_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/browser_aboutdebugging_sidebar_usb_unknown_runtime.js
devtools/client/aboutdebugging-new/test/browser/head.js
devtools/client/aboutdebugging-new/test/browser/helper-mocks.js
devtools/client/aboutdebugging-new/test/browser/mocks/helper-adb-mock.js
devtools/client/aboutdebugging-new/test/browser/mocks/helper-usb-runtimes-mock.js
--- 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
@@ -48,14 +48,12 @@ async function checkTargetPanes({ enable
     } else {
       ok(!debugTargetPaneEl, `Unsupported target pane [${title}] is hidden`);
     }
   }
 
   info("Remove USB runtime");
   mocks.removeUSBRuntime(RUNTIME_ID);
   mocks.emitUSBUpdate();
-
-  info("Wait until the USB sidebar item disappears");
-  await waitUntil(() => !findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
+  await waitUntilUsbDeviceIsUnplugged(RUNTIME_DEVICE_NAME, document);
 
   await removeTab(tab);
 }
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_persist_connection.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_persist_connection.js
@@ -19,33 +19,35 @@ add_task(async function() {
     deviceName: USB_DEVICE_NAME,
   });
 
   await testRemoteClientPersistConnection(mocks, {
     client: usbClient,
     id: USB_RUNTIME_ID,
     runtimeName: USB_APP_NAME,
     sidebarName: USB_DEVICE_NAME,
+    type: "usb",
   });
 
   info("Test with a network runtime");
   const networkClient = mocks.createNetworkRuntime(NETWORK_RUNTIME_HOST, {
     name: NETWORK_RUNTIME_APP_NAME,
   });
 
   await testRemoteClientPersistConnection(mocks, {
     client: networkClient,
     id: NETWORK_RUNTIME_HOST,
     runtimeName: NETWORK_RUNTIME_APP_NAME,
     sidebarName: NETWORK_RUNTIME_HOST,
+    type: "network",
   });
 });
 
 async function testRemoteClientPersistConnection(mocks,
-  { client, id, runtimeName, sidebarName }) {
+  { client, id, runtimeName, sidebarName, type }) {
   info("Open about:debugging and connect to the test runtime");
   let { document, tab, window } = await openAboutDebugging();
   await selectThisFirefoxPage(document, window.AboutDebugging.store);
 
   await connectToRuntime(sidebarName, document);
   await selectRuntime(sidebarName, runtimeName, document);
 
   info("Reload about:debugging");
@@ -59,14 +61,18 @@ async function testRemoteClientPersistCo
 
   // Remove the runtime without emitting an update.
   // This is what happens today when we simply close Firefox for Android.
   info("Remove the runtime from the list of remote runtimes");
   mocks.removeRuntime(id);
 
   info("Emit 'closed' on the client and wait for the sidebar item to disappear");
   client._eventEmitter.emit("closed");
-  await waitUntil(() => !findSidebarItemByText(sidebarName, document) &&
-                      !findSidebarItemByText(runtimeName, document));
+  if (type === "usb") {
+    await waitUntilUsbDeviceIsUnplugged(sidebarName, document);
+  } else {
+    await waitUntil(() => !findSidebarItemByText(sidebarName, document) &&
+                        !findSidebarItemByText(runtimeName, document));
+  }
 
   info("Remove the tab");
   await removeTab(tab);
 }
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_process_category.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_process_category.js
@@ -34,13 +34,12 @@ add_task(async function() {
   await connectToRuntime(RUNTIME_DEVICE_NAME, document);
   await selectRuntime(RUNTIME_DEVICE_NAME, RUNTIME_APP_NAME, document);
   ok(getDebugTargetPane(CATEGORY_NAME, document),
      "Process category should display for USB runtime");
 
   info("Remove USB runtime");
   mocks.removeUSBRuntime(RUNTIME_ID);
   mocks.emitUSBUpdate();
-  info("Wait until the USB sidebar item disappears");
-  await waitUntil(() => !findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
+  await waitUntilUsbDeviceIsUnplugged(RUNTIME_DEVICE_NAME, document);
 
   await removeTab(tab);
 });
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_process_main.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_process_main.js
@@ -46,15 +46,14 @@ add_task(async function() {
   const processID = url.searchParams.get("id");
   is(processID, "0", "Correct process id");
   const remoteID = url.searchParams.get("remoteId");
   is(remoteID, `${ RUNTIME_ID }-usb`, "Correct remote runtime id");
 
   info("Remove USB runtime");
   mocks.removeUSBRuntime(RUNTIME_ID);
   mocks.emitUSBUpdate();
-  info("Wait until the USB sidebar item disappears");
-  await waitUntil(() => !findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
+  await waitUntilUsbDeviceIsUnplugged(RUNTIME_DEVICE_NAME, document);
 
   await removeTab(devtoolsTab);
   await waitUntil(() => !findDebugTargetByText("about:devtools-toolbox?", document));
   await removeTab(tab);
 });
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_runtime_usbclient_closed.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_runtime_usbclient_closed.js
@@ -24,19 +24,17 @@ add_task(async function testUsbDeviceUnp
 
   info("Connect to and select the USB device");
   await connectToRuntime(USB_DEVICE_NAME, document);
   await selectRuntime(USB_DEVICE_NAME, USB_APP_NAME, document);
 
   info("Simulate a device unplugged");
   mocks.removeUSBRuntime(USB_RUNTIME_ID);
   mocks.emitUSBUpdate();
-
-  info("Wait until the sidebar item for this runtime disappears");
-  await waitUntil(() => !findSidebarItemByText(USB_DEVICE_NAME, document));
+  await waitUntilUsbDeviceIsUnplugged(USB_DEVICE_NAME, document);
 
   is(document.location.hash, `#/runtime/this-firefox`,
     "Redirection to the default page (this-firefox)");
 
   await removeTab(tab);
 });
 
 // Test that about:debugging navigates back to the default page when the server for the
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_connection_state.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_connection_state.js
@@ -64,15 +64,12 @@ add_task(async function() {
   resumeConnection();
   await waitUntil(() => !usbRuntimeSidebarItem.querySelector(".js-connect-button"));
   ok(!document.querySelector(".qa-connection-error"), "Error disappears");
   ok(!document.querySelector(".qa-connection-not-responding"), "Warning disappears");
 
   info("Remove a USB runtime");
   mocks.removeUSBRuntime(RUNTIME_ID);
   mocks.emitUSBUpdate();
-
-  info("Wait until the USB sidebar item disappears");
-  await waitUntil(() => !findSidebarItemByText(RUNTIME_DEVICE_NAME, document) &&
-                      !findSidebarItemByText(RUNTIME_SHORT_NAME, document));
+  await waitUntilUsbDeviceIsUnplugged(RUNTIME_DEVICE_NAME, document);
 
   await removeTab(tab);
 });
--- 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,31 +1,33 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
+const RUNTIME_ID = "RUNTIME_ID";
+const RUNTIME_DEVICE_NAME = "RUNTIME_DEVICE_NAME";
+const RUNTIME_SHORT_NAME = "testshort";
+
 // Test that USB runtimes appear and disappear from the sidebar.
 add_task(async function() {
   const mocks = new Mocks();
 
   const { document, tab } = await openAboutDebugging();
 
-  mocks.createUSBRuntime("test_device_id", {
-    deviceName: "test device name",
-    shortName: "testshort",
+  mocks.createUSBRuntime(RUNTIME_ID, {
+    deviceName: RUNTIME_DEVICE_NAME,
+    shortName: RUNTIME_SHORT_NAME,
   });
   mocks.emitUSBUpdate();
 
   info("Wait until the USB sidebar item appears");
-  await waitUntil(() => findSidebarItemByText("test device name", document));
-  const usbRuntimeSidebarItem = findSidebarItemByText("test device name", document);
-  ok(usbRuntimeSidebarItem.textContent.includes("testshort"),
+  await waitUntil(() => findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
+  const usbRuntimeSidebarItem = findSidebarItemByText(RUNTIME_DEVICE_NAME, document);
+  ok(usbRuntimeSidebarItem.textContent.includes(RUNTIME_SHORT_NAME),
     "The short name of the usb runtime is visible");
 
-  mocks.removeUSBRuntime("test_device_id");
+  mocks.removeUSBRuntime(RUNTIME_ID);
   mocks.emitUSBUpdate();
-
-  info("Wait until the USB sidebar item disappears");
-  await waitUntil(() => !findSidebarItemByText("test device name", document));
+  await waitUntilUsbDeviceIsUnplugged(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
@@ -34,14 +34,12 @@ add_task(async function() {
   await waitUntil(() => !usbRuntimeSidebarItem.querySelector(".js-connect-button"));
 
   info("Check whether the label of item is updated after connecting");
   ok(usbRuntimeSidebarItem.textContent.includes(RUNTIME_NAME), "Label of item updated");
 
   info("Remove all USB runtimes");
   mocks.removeUSBRuntime(RUNTIME_ID);
   mocks.emitUSBUpdate();
-
-  info("Wait until the USB sidebar item disappears");
-  await waitUntil(() => !findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
+  await waitUntilUsbDeviceIsUnplugged(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
@@ -26,18 +26,18 @@ add_task(async function() {
   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");
   mocks.createUSBRuntime(OTHER_RUNTIME_ID, {
     deviceName: OTHER_RUNTIME_APP_NAME,
   });
 
-  // Mock the refreshUSBRuntimes to emit an update.
-  mocks.usbRuntimesMock.refreshUSBRuntimes = () => mocks.emitUSBUpdate();
+  // adb.updateRuntimes should ultimately fire the "runtime-list-updated" event.
+  mocks.adbMock.adb.updateRuntimes = () => 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");
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_unknown_runtime.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_unknown_runtime.js
@@ -1,58 +1,58 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const RUNTIME_NAME = "Firefox 123";
+const DEVICE_NAME = "DEVICE_NAME";
+const DEVICE_ID = "DEVICE_ID";
+const RUNTIME_ID = "RUNTIME_ID";
 
 // Test that unknown runtimes:
 // - are displayed without a connect button.
 // - cannot be selected
 // - display a specific text ("Waiting for runtime") instead of the runtime name
 add_task(async function() {
   const mocks = new Mocks();
   const { document, tab } = await openAboutDebugging();
 
-  info("Create a mocked unknown runtime");
-  let isUnknown = true;
-  mocks.createUSBRuntime("test_device_id", {
-    get isUnknown() {
-      return isUnknown;
-    },
-    // Here shortName would rather be Unknown Runtime from adb-runtime, but we only want
-    // to check the runtime name does not appear in the UI.
-    shortName: RUNTIME_NAME,
-  });
+  info("Create a device without a corresponding runtime");
+  mocks.addDevice(DEVICE_ID, DEVICE_NAME);
   mocks.emitUSBUpdate();
 
   info("Wait until the USB sidebar item appears");
-  await waitUntil(() => findSidebarItemByText("test device name", document));
+  await waitUntil(() => findSidebarItemByText(DEVICE_NAME, document));
 
-  const usbRuntimeSidebarItem = findSidebarItemByText("test device name", document);
+  const usbRuntimeSidebarItem = findSidebarItemByText(DEVICE_NAME, document);
 
   const itemText = usbRuntimeSidebarItem.textContent;
   ok(itemText.includes("Waiting for browser"), "Sidebar item shows Waiting for browser");
   ok(!itemText.includes(RUNTIME_NAME), "Sidebar item does not show the runtime name");
 
   const hasConnectButton = usbRuntimeSidebarItem.querySelector(".js-connect-button");
   ok(!hasConnectButton, "Connect button is not displayed");
 
   const hasLink = usbRuntimeSidebarItem.querySelector(".js-sidebar-link");
   ok(!hasLink, "Unknown runtime is not selectable");
 
-  info("Update the runtime to return false for isUnknown() and emit update event");
-  isUnknown = false;
+  info("Add a valid runtime for the same device id and emit update event");
+  mocks.createUSBRuntime(RUNTIME_ID, {
+    deviceId: DEVICE_ID,
+    deviceName: DEVICE_NAME,
+    shortName: RUNTIME_NAME,
+  });
+  mocks.removeDevice(DEVICE_ID);
   mocks.emitUSBUpdate();
 
   info("Wait until connect button appears for the USB runtime");
   let updatedSidebarItem = null;
   await waitUntil(() => {
-    updatedSidebarItem = findSidebarItemByText("test device name", document);
+    updatedSidebarItem = findSidebarItemByText(DEVICE_NAME, document);
     return updatedSidebarItem && updatedSidebarItem.querySelector(".js-connect-button");
   });
 
   const updatedText = updatedSidebarItem.textContent;
   ok(updatedText.includes(RUNTIME_NAME), "Sidebar item shows the runtime name");
 
   await removeTab(tab);
 });
--- a/devtools/client/aboutdebugging-new/test/browser/head.js
+++ b/devtools/client/aboutdebugging-new/test/browser/head.js
@@ -307,8 +307,17 @@ async function openProfilerDialog(client
  * The "This Firefox" string depends on the brandShortName, which will be different
  * depending on the channel where tests are running.
  */
 function getThisFirefoxString(aboutDebuggingWindow) {
   const loader = aboutDebuggingWindow.getBrowserLoaderForWindow();
   const { l10n } = loader.require("devtools/client/aboutdebugging-new/src/modules/l10n");
   return l10n.getString("about-debugging-this-firefox-runtime-name");
 }
+
+function waitUntilUsbDeviceIsUnplugged(deviceName, aboutDebuggingDocument) {
+  info("Wait until the USB sidebar item appears as unplugged");
+  return waitUntil(() => {
+    const sidebarItem = findSidebarItemByText(deviceName, aboutDebuggingDocument);
+    const isUnplugged = sidebarItem.textContent.includes("Unplugged");
+    return isUnplugged;
+  });
+}
--- a/devtools/client/aboutdebugging-new/test/browser/helper-mocks.js
+++ b/devtools/client/aboutdebugging-new/test/browser/helper-mocks.js
@@ -1,48 +1,54 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 /* import-globals-from ../../../shared/test/shared-head.js */
 
 const MOCKS_ROOT = CHROME_URL_ROOT + "mocks/";
+/* import-globals-from mocks/helper-adb-mock.js */
+Services.scriptloader.loadSubScript(MOCKS_ROOT + "helper-adb-mock.js", this);
 /* import-globals-from mocks/helper-client-wrapper-mock.js */
 Services.scriptloader.loadSubScript(MOCKS_ROOT + "helper-client-wrapper-mock.js", this);
 /* import-globals-from mocks/helper-runtime-client-factory-mock.js */
 Services.scriptloader.loadSubScript(MOCKS_ROOT + "helper-runtime-client-factory-mock.js",
   this);
-/* import-globals-from mocks/helper-usb-runtimes-mock.js */
-Services.scriptloader.loadSubScript(MOCKS_ROOT + "helper-usb-runtimes-mock.js", this);
 
 const { RUNTIMES } = require("devtools/client/aboutdebugging-new/src/constants");
 
 /**
  * This wrapper around the mocks used in about:debugging tests provides helpers to
  * quickly setup mocks for runtime tests involving USB, network or wifi runtimes that can
  * are difficult to setup in a test environment.
  */
 class Mocks {
   constructor() {
-    // Setup the usb-runtimes mock to rely on the internal _usbRuntimes array.
-    this.usbRuntimesMock = createUsbRuntimesMock();
+    // Setup the adb mock to rely on internal arrays.
+    this.adbMock = createAdbMock();
     this._usbRuntimes = [];
-    this.usbRuntimesMock.getUSBRuntimes = () => {
+    this._usbDevices = [];
+    this.adbMock.adb.getRuntimes = () => {
       return this._usbRuntimes;
     };
+    this.adbMock.adb.getDevices = () => {
+      const runtimeDevices = this._usbRuntimes.map(r => {
+        return { id: r.deviceId, name: r.deviceName };
+      });
+      return runtimeDevices.concat(this._usbDevices);
+    };
 
-    // refreshUSBRuntimes normally starts scan, which should ultimately fire the
-    // "runtime-list-updated" event.
-    this.usbRuntimesMock.refreshUSBRuntimes = () => {
+    // adb.updateRuntimes should ultimately fire the "runtime-list-updated" event.
+    this.adbMock.adb.updateRuntimes = () => {
       this.emitUSBUpdate();
     };
 
     // Prepare a fake observer to be able to emit events from this mock.
-    this._observerMock = addObserverMock(this.usbRuntimesMock);
+    this._observerMock = addObserverMock(this.adbMock.adb);
 
     // Setup the runtime-client-factory mock to rely on the internal _clients map.
     this.runtimeClientFactoryMock = createRuntimeClientFactoryMock();
     this._clients = {
       [RUNTIMES.NETWORK]: {},
       [RUNTIMES.THIS_FIREFOX]: {},
       [RUNTIMES.USB]: {},
     };
@@ -60,22 +66,22 @@ class Mocks {
     registerCleanupFunction(() => this.disableMocks());
   }
 
   get thisFirefoxClient() {
     return this._thisFirefoxClient;
   }
 
   enableMocks() {
-    enableUsbRuntimesMock(this.usbRuntimesMock);
+    enableAdbMock(this.adbMock);
     enableRuntimeClientFactoryMock(this.runtimeClientFactoryMock);
   }
 
   disableMocks() {
-    disableUsbRuntimesMock();
+    disableAdbMock();
     disableRuntimeClientFactoryMock();
 
     for (const host of Object.keys(this._clients[RUNTIMES.NETWORK])) {
       this.removeNetworkRuntime(host);
     }
   }
 
   createNetworkRuntime(host, runtimeInfo) {
@@ -110,37 +116,33 @@ class Mocks {
   }
 
   /**
    * 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
    *        - channel: {String} Release channel, for instance "release", "nightly"
+   *        - deviceId: {String} Device id
    *        - deviceName: {String} Device name
    *        - isUnknown: {Function} should return a boolean, true for unknown runtimes
    *        - name: {String} Application name, for instance "Firefox"
    *        - shortName: {String} Short name for the device
    *        - socketPath: {String} (should only be used for connecting, so not here)
    *        - version: {String} Version, for instance "63.0a"
    * @return {Object} Returns the mock client created for this runtime so that methods
    * can be overridden on it.
    */
   createUSBRuntime(id, runtimeInfo = {}) {
     // Add a new runtime to the list of scanned runtimes.
     this._usbRuntimes.push({
       id: id,
       socketPath: runtimeInfo.socketPath || "test/path",
+      deviceId: runtimeInfo.deviceId || "test device id",
       deviceName: runtimeInfo.deviceName || "test device name",
-      get isUnknown() {
-        return runtimeInfo.isUnknown || false;
-      },
-      get isUnplugged() {
-        return runtimeInfo.isUnplugged || false;
-      },
       shortName: runtimeInfo.shortName || "testshort",
     });
 
     // Add a valid client that can be returned for this particular runtime id.
     const mockUsbClient = createClientMock();
     mockUsbClient.getDeviceDescription = () => {
       return {
         channel: runtimeInfo.channel || "release",
@@ -153,16 +155,29 @@ class Mocks {
     return mockUsbClient;
   }
 
   removeUSBRuntime(id) {
     this._usbRuntimes = this._usbRuntimes.filter(runtime => runtime.id !== id);
     delete this._clients[RUNTIMES.USB][id];
   }
 
+  addDevice(deviceId, deviceName) {
+    this._usbDevices.push({
+      id: deviceId,
+      name: deviceName,
+    });
+  }
+
+  removeDevice(deviceId) {
+    this._usbDevices = this._usbDevices.filter(d => {
+      return d.id !== deviceId;
+    });
+  }
+
   removeRuntime(id) {
     if (this._clients[RUNTIMES.USB][id]) {
       this.removeUSBRuntime(id);
     } else if (this._clients[RUNTIMES.NETWORK][id]) {
       this.removeNetworkRuntime(id);
     }
   }
 }
rename from devtools/client/aboutdebugging-new/test/browser/mocks/helper-usb-runtimes-mock.js
rename to devtools/client/aboutdebugging-new/test/browser/mocks/helper-adb-mock.js
--- a/devtools/client/aboutdebugging-new/test/browser/mocks/helper-usb-runtimes-mock.js
+++ b/devtools/client/aboutdebugging-new/test/browser/mocks/helper-adb-mock.js
@@ -1,92 +1,85 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 /**
- * Setup the loader to return the provided mock object instead of the regular
- * usb-runtimes module.
+ * Setup the loader to return the provided mock object instead of the regular adb module.
  *
  * @param {Object}
  *        mock should implement the following methods:
- *        - addUSBRuntimesObserver(listener)
- *        - disableUSBRuntimes()
- *        - enableUSBRuntimes()
- *        - getUSBRuntimes()
- *        - removeUSBRuntimesObserver(listener)
+ *        - registerListener(listener)
+ *        - getRuntimes()
+ *        - getDevices()
+ *        - updateRuntimes()
+ *        - unregisterListener(listener)
  */
-function enableUsbRuntimesMock(mock) {
+function enableAdbMock(mock) {
   const { setMockedModule } = require("devtools/client/shared/browser-loader-mocks");
-  setMockedModule(mock,
-    "devtools/client/aboutdebugging-new/src/modules/usb-runtimes");
+  setMockedModule(mock, "devtools/shared/adb/adb");
 }
-/* exported enableUsbRuntimesMock */
+/* exported enableAdbMock */
 
 /**
- * Update the loader to clear the mock entry for the usb-runtimes module.
+ * Update the loader to clear the mock entry for the adb module.
  */
-function disableUsbRuntimesMock() {
+function disableAdbMock() {
   const { removeMockedModule } = require("devtools/client/shared/browser-loader-mocks");
-  removeMockedModule(
-    "devtools/client/aboutdebugging-new/src/modules/usb-runtimes");
+  removeMockedModule("devtools/shared/adb/adb");
 }
-/* exported disableUsbRuntimesMock */
+/* exported disableAdbMock */
 
 /**
- * Creates a simple mock version for usb-runtimes, implementing all the expected methods
+ * Creates a simple mock version for adb, implementing all the expected methods
  * with empty placeholders.
  */
-function createUsbRuntimesMock() {
-  const usbRuntimesMock = {};
-  usbRuntimesMock.addUSBRuntimesObserver = function(listener) {
-    console.log("MOCKED METHOD addUSBRuntimesObserver");
+function createAdbMock() {
+  const adbMock = {};
+  adbMock.registerListener = function(listener) {
+    console.log("MOCKED METHOD registerListener");
   };
 
-  usbRuntimesMock.disableUSBRuntimes = function() {
-    console.log("MOCKED METHOD disableUSBRuntimes");
+  adbMock.getRuntimes = function() {
+    console.log("MOCKED METHOD getRuntimes");
   };
 
-  usbRuntimesMock.enableUSBRuntimes = function() {
-    console.log("MOCKED METHOD enableUSBRuntimes");
+  adbMock.getDevices = function() {
+    console.log("MOCKED METHOD getDevices");
   };
 
-  usbRuntimesMock.getUSBRuntimes = function() {
-    console.log("MOCKED METHOD getUSBRuntimes");
-  };
-
-  usbRuntimesMock.refreshUSBRuntimes = function() {
-    console.log("MOCKED METHOD refreshUSBRuntimes");
+  adbMock.updateRuntimes = function() {
+    console.log("MOCKED METHOD updateRuntimes");
   };
 
-  usbRuntimesMock.removeUSBRuntimesObserver = function(listener) {
-    console.log("MOCKED METHOD removeUSBRuntimesObserver");
+  adbMock.unregisterListener = function(listener) {
+    console.log("MOCKED METHOD unregisterListener");
   };
 
-  return usbRuntimesMock;
+  return { adb: adbMock };
 }
-/* exported createUsbRuntimesMock */
+/* exported createAdbMock */
 
 /**
- * The usb-runtimes module allows to observer runtime updates. To simulate this behaviour
+ * The adb module allows to observe runtime updates. To simulate this behaviour
  * the easiest is to use an EventEmitter-decorated object that can accept listeners and
  * can emit events from the test.
  *
- * This method will update the addUSBRuntimesObserver method of the provided
+ * This method will update the registerListener method of the provided
  * usbRuntimesMock in order to add listeners to a mockObserver, and returns said observer
  * so that the test can emit "runtime-list-updated" when needed.
  */
-function addObserverMock(usbRuntimesMock) {
+function addObserverMock(adbMock) {
   const EventEmitter = require("devtools/shared/event-emitter");
 
   const observerMock = {};
   EventEmitter.decorate(observerMock);
-  usbRuntimesMock.addUSBRuntimesObserver = function(listener) {
-    console.log("MOCKED METHOD addUSBRuntimesObserver with mock scanner");
+  adbMock.registerListener = function(listener) {
+    console.log("MOCKED METHOD registerListener with mock scanner");
     observerMock.on("runtime-list-updated", listener);
   };
 
   // NOTE FOR REVIEW: Instead of emitting "runtime-list-updated" events in the test,
   // this mock could have a emitObservedEvent method, that would just emit the correct
   // event. This way if the event name changes, everything remains contained in this
   // method.