Bug 1495381 - Create debug-target-pane test for USB runtimes;r=daisuke
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 13 Nov 2018 06:43:39 +0000
changeset 502851 a97b66cfcfd1e2a1c7277417e6a8cb3929bc1a5c
parent 502850 61d5a2b88e8106eab159e4a33fd5e458c97cee61
child 502852 ae26c60a0f50dc98534e7e2bd65ee62254cb71f6
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)
reviewersdaisuke
bugs1495381
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 1495381 - Create debug-target-pane test for USB runtimes;r=daisuke Depends on D11642 Differential Revision: https://phabricator.services.mozilla.com/D11643
devtools/client/aboutdebugging-new/src/components/RuntimeInfo.js
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js
devtools/client/aboutdebugging-new/test/browser/debug-target-pane_collapsibilities_head.js
--- a/devtools/client/aboutdebugging-new/src/components/RuntimeInfo.js
+++ b/devtools/client/aboutdebugging-new/src/components/RuntimeInfo.js
@@ -40,15 +40,20 @@ class RuntimeInfo extends PureComponent 
       Localized(
         {
           id: deviceName ? "about-debugging-runtime-info-with-model"
                           : "about-debugging-runtime-info",
           $name: name,
           $deviceName: deviceName,
           $version: version,
         },
-        dom.label({}, `${ name } on ${ deviceName } (${ version })`)
+        dom.label(
+          {
+            className: "js-runtime-info",
+          },
+          `${ name } on ${ deviceName } (${ version })`
+        )
       )
     );
   }
 }
 
 module.exports = RuntimeInfo;
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -15,16 +15,17 @@ support-files =
 
 [browser_aboutdebugging_connect_networklocations.js]
 [browser_aboutdebugging_connect_toggle_usb_devices.js]
 skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638
 [browser_aboutdebugging_connection_prompt_setting.js]
 [browser_aboutdebugging_debug-target-pane_collapsibilities_interaction.js]
 [browser_aboutdebugging_debug-target-pane_collapsibilities_preference.js]
 [browser_aboutdebugging_debug-target-pane_empty.js]
+[browser_aboutdebugging_debug-target-pane_usb_runtime.js]
 [browser_aboutdebugging_navigate.js]
 [browser_aboutdebugging_sidebar_network_runtimes.js]
 [browser_aboutdebugging_sidebar_usb_runtime.js]
 [browser_aboutdebugging_sidebar_usb_runtime_connect.js]
 [browser_aboutdebugging_sidebar_usb_status.js]
 skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638
 [browser_aboutdebugging_tab_favicons.js]
 [browser_aboutdebugging_thisfirefox.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js
@@ -0,0 +1,68 @@
+/* Any copyright is dedicated to the Public Domain.
+   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);
+
+// Test that the expected supported categories are displayed for USB runtimes.
+add_task(async function() {
+  const usbMocks = new UsbMocks();
+  usbMocks.enableMocks();
+  registerCleanupFunction(() => {
+    usbMocks.disableMocks();
+  });
+
+  const { document, tab } = await openAboutDebugging();
+
+  usbMocks.createRuntime(RUNTIME_ID, {
+    appName: RUNTIME_APP_NAME,
+    deviceName: RUNTIME_DEVICE_NAME,
+  });
+  usbMocks.emitUpdate();
+
+  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"));
+
+  usbRuntimeSidebarItem.querySelector(".js-sidebar-link").click();
+
+  await waitUntil(() => {
+    const runtimeInfo = document.querySelector(".js-runtime-info");
+    return runtimeInfo.textContent.includes(RUNTIME_APP_NAME);
+  });
+
+  const SUPPORTED_TARGET_PANES = [
+    "Extensions",
+    "Tabs",
+  ];
+
+  for (const { title } of TARGET_PANES) {
+    const debugTargetPaneEl = getDebugTargetPane(title, document);
+    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();
+
+  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/debug-target-pane_collapsibilities_head.js
+++ b/devtools/client/aboutdebugging-new/test/browser/debug-target-pane_collapsibilities_head.js
@@ -36,17 +36,17 @@ function getDebugTargetPane(title, docum
   for (const titleEl of document.querySelectorAll(".js-debug-target-pane-title")) {
     if (titleEl.textContent !== title) {
       continue;
     }
 
     return titleEl.closest(".js-debug-target-pane");
   }
 
-  throw new Error(`DebugTargetPane for [${ title }] was not found`);
+  return null;
 }
 
 // eslint-disable-next-line no-unused-vars
 function prepareCollapsibilitiesTest() {
   // Make all collapsibilities to be expanded.
   for (const { pref } of TARGET_PANES) {
     Services.prefs.setBoolPref(pref, false);
   }