Bug 1495380 - Add test to check that we can select network runtimes;r=ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 30 Nov 2018 16:02:47 +0000
changeset 505414 add6ce065c17774c038c6e5762cd2996c28060fe
parent 505413 1e6a6598ffed79bd9c90870ea153108c7988aba5
child 505415 dc482031a974d1794c5cd4933b985865d38fcac2
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 - Add test to check that we can select network runtimes;r=ladybenko Depends on D12947 Differential Revision: https://phabricator.services.mozilla.com/D13514
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_remote_runtime.js
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_routes.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_select_network_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
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -26,16 +26,17 @@ skip-if = (os == 'linux' && bits == 32) 
 [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_devtools.js]
 [browser_aboutdebugging_navigate.js]
 [browser_aboutdebugging_persist_connection.js]
 [browser_aboutdebugging_routes.js]
+[browser_aboutdebugging_select_network_runtime.js]
 [browser_aboutdebugging_sidebar_network_runtimes.js]
 [browser_aboutdebugging_sidebar_usb_runtime.js]
 [browser_aboutdebugging_sidebar_usb_runtime_connect.js]
 [browser_aboutdebugging_sidebar_usb_runtime_refresh.js]
 [browser_aboutdebugging_sidebar_usb_status.js]
 skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638
 [browser_aboutdebugging_system_addons.js]
 [browser_aboutdebugging_tab_favicons.js]
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_remote_runtime.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_remote_runtime.js
@@ -10,18 +10,16 @@ const USB_RUNTIME_DEVICE_NAME = "test de
 const USB_RUNTIME_APP_NAME = "TestUsbApp";
 
 /* 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 mocks = new Mocks();
-  mocks.enableMocks();
-  registerCleanupFunction(() => mocks.disableMocks());
 
   const { document, tab } = await openAboutDebugging();
 
   info("Prepare USB client mock");
   const usbClient = mocks.createUSBRuntime(USB_RUNTIME_ID, {
     deviceName: USB_RUNTIME_DEVICE_NAME,
     name: USB_RUNTIME_APP_NAME,
   });
--- 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
@@ -8,20 +8,16 @@ const RUNTIME_DEVICE_NAME = "test device
 const RUNTIME_APP_NAME = "TestApp";
 
 /* 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 mocks = new Mocks();
-  mocks.enableMocks();
-  registerCleanupFunction(() => {
-    mocks.disableMocks();
-  });
 
   const { document, tab } = await openAboutDebugging();
 
   mocks.createUSBRuntime(RUNTIME_ID, {
     deviceName: RUNTIME_DEVICE_NAME,
     name: RUNTIME_APP_NAME,
   });
   mocks.emitUSBUpdate();
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_persist_connection.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_persist_connection.js
@@ -8,18 +8,16 @@ const RUNTIME_DEVICE_NAME = "test device
 const RUNTIME_APP_NAME = "TestApp";
 
 /* import-globals-from head-mocks.js */
 Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
 
 // Test that remote runtime connections are persisted across about:debugging reloads.
 add_task(async function() {
   const mocks = new Mocks();
-  mocks.enableMocks();
-  registerCleanupFunction(() => mocks.disableMocks());
 
   let { document, tab } = await openAboutDebugging();
 
   const usbClient = mocks.createUSBRuntime(RUNTIME_ID, {
     name: RUNTIME_APP_NAME,
     deviceName: RUNTIME_DEVICE_NAME,
   });
   mocks.emitUSBUpdate();
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_routes.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_routes.js
@@ -18,18 +18,16 @@ add_task(async function() {
 });
 
 /**
  * Test that the routes in about:debugging show the proper views
  */
 add_task(async function() {
   // enable USB devices mocks
   const mocks = new Mocks();
-  mocks.enableMocks();
-  registerCleanupFunction(() => mocks.disableMocks());
 
   const { document, tab } = await openAboutDebugging();
 
   info("Check 'This Firefox' route");
   document.location.hash = "#/runtime/this-firefox";
   await waitUntil(() => document.querySelector(".js-runtime-page"));
   const infoLabel = document.querySelector(".js-runtime-info").textContent;
   // NOTE: when using USB Mocks, we see only "Firefox" as the device name
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_select_network_runtime.js
@@ -0,0 +1,47 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const NETWORK_RUNTIME_HOST = "localhost:6080";
+const NETWORK_RUNTIME_APP_NAME = "TestNetworkApp";
+const NETWORK_RUNTIME_CHANNEL = "SomeChannel";
+const NETWORK_RUNTIME_VERSION = "12.3";
+
+/* import-globals-from head-mocks.js */
+Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
+
+// Test that network runtimes can be selected.
+add_task(async function() {
+  const mocks = new Mocks();
+
+  const { document, tab } = await openAboutDebugging();
+
+  info("Prepare Network client mock");
+  const networkClient = mocks.createNetworkRuntime(NETWORK_RUNTIME_HOST, {
+    name: NETWORK_RUNTIME_APP_NAME,
+  });
+  networkClient.getDeviceDescription = () => {
+    return {
+      name: NETWORK_RUNTIME_APP_NAME,
+      channel: NETWORK_RUNTIME_CHANNEL,
+      version: NETWORK_RUNTIME_VERSION,
+    };
+  };
+
+  info("Test addons in runtime page for Network client");
+  await connectToRuntime(NETWORK_RUNTIME_HOST, document);
+  await selectRuntime(NETWORK_RUNTIME_HOST, NETWORK_RUNTIME_APP_NAME, document);
+
+  info("Check that the network runtime mock is properly displayed");
+  const thisFirefoxRuntimeInfo = document.querySelector(".js-runtime-info");
+  ok(thisFirefoxRuntimeInfo, "Runtime info for this-firefox runtime is displayed");
+  const runtimeInfoText = thisFirefoxRuntimeInfo.textContent;
+
+  ok(runtimeInfoText.includes(NETWORK_RUNTIME_APP_NAME),
+    "network runtime info shows the correct runtime name: " + runtimeInfoText);
+  ok(runtimeInfoText.includes(NETWORK_RUNTIME_VERSION),
+    "network runtime info shows the correct version number: " + runtimeInfoText);
+
+  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
@@ -7,20 +7,16 @@
 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 mocks = new Mocks();
-  mocks.enableMocks();
-  registerCleanupFunction(() => {
-    mocks.disableMocks();
-  });
 
   const { document, tab } = await openAboutDebugging();
 
   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));
--- 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
@@ -11,18 +11,16 @@ const OTHER_RUNTIME_ID = "other-runtime-
 const OTHER_RUNTIME_APP_NAME = "OtherApp";
 
 /* 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 mocks = new Mocks();
-  mocks.enableMocks();
-  registerCleanupFunction(() => mocks.disableMocks());
 
   const { document, tab } = await openAboutDebugging();
 
   info("Create a first runtime and connect to it");
   mocks.createUSBRuntime(RUNTIME_ID, {
     deviceName: RUNTIME_DEVICE_NAME,
     name: RUNTIME_APP_NAME,
   });
--- a/devtools/client/aboutdebugging-new/test/browser/head-mocks.js
+++ b/devtools/client/aboutdebugging-new/test/browser/head-mocks.js
@@ -48,16 +48,20 @@ class Mocks {
     this.runtimeClientFactoryMock.createClientForRuntime = runtime => {
       return this._clients[runtime.type][runtime.id];
     };
 
     // Add a client for THIS_FIREFOX, since about:debugging will start on the This Firefox
     // page.
     this._thisFirefoxClient = createThisFirefoxClientMock();
     this._clients[RUNTIMES.THIS_FIREFOX][RUNTIMES.THIS_FIREFOX] = this._thisFirefoxClient;
+
+    // Enable mocks and remove them after the test.
+    this.enableMocks();
+    registerCleanupFunction(() => this.disableMocks());
   }
 
   get thisFirefoxClient() {
     return this._thisFirefoxClient;
   }
 
   enableMocks() {
     enableUsbRuntimesMock(this.usbRuntimesMock);