зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1615418 - Use a real client in disconnect aboutdebugging test r=daisuke
Depends on D62894 Using a real local client allows to cover more codepaths than using a complete mock here. Differential Revision: https://phabricator.services.mozilla.com/D62891 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
79f1be551e
Коммит
41fcd60375
|
@ -77,17 +77,9 @@ add_task(async function() {
|
|||
// about:devtools-toolbox on a real target.
|
||||
const clientWrapper = await createLocalClientWrapper();
|
||||
|
||||
// Mock getDeviceDescription() to force the local client to return "nightly" as the
|
||||
// channel. Otherwise the value of the icon source would depend on the current channel.
|
||||
const deviceDescription = await clientWrapper.getDeviceDescription();
|
||||
clientWrapper.getDeviceDescription = function() {
|
||||
return Object.assign({}, deviceDescription, {
|
||||
channel: "nightly",
|
||||
});
|
||||
};
|
||||
|
||||
const mocks = new Mocks();
|
||||
mocks.createUSBRuntime(RUNTIME_ID, {
|
||||
channel: "nightly",
|
||||
clientWrapper: clientWrapper,
|
||||
deviceName: DEVICE_NAME,
|
||||
isFenix: true,
|
||||
|
@ -106,7 +98,6 @@ add_task(async function() {
|
|||
const onRequestSuccess = waitForRequestsSuccess(window.AboutDebugging.store);
|
||||
await connectToRuntime(DEVICE_NAME, document);
|
||||
await selectRuntime(DEVICE_NAME, ADB_RUNTIME_NAME, document);
|
||||
|
||||
info(
|
||||
"Wait for requests to finish the USB runtime is backed by a real local client"
|
||||
);
|
||||
|
@ -148,19 +139,3 @@ add_task(async function() {
|
|||
await removeTab(tab);
|
||||
await clientWrapper.close();
|
||||
});
|
||||
|
||||
async function createLocalClientWrapper() {
|
||||
info("Create a local DevToolsClient");
|
||||
const { DevToolsServer } = require("devtools/server/devtools-server");
|
||||
const { DevToolsClient } = require("devtools/shared/client/devtools-client");
|
||||
const {
|
||||
ClientWrapper,
|
||||
} = require("devtools/client/aboutdebugging/src/modules/client-wrapper");
|
||||
|
||||
DevToolsServer.init();
|
||||
DevToolsServer.registerAllActors();
|
||||
const client = new DevToolsClient(DevToolsServer.connectPipe());
|
||||
|
||||
await client.connect();
|
||||
return new ClientWrapper(client);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,14 @@ const DEFAULT_PAGE = "#/runtime/this-firefox";
|
|||
* and redirects to the default page.
|
||||
*/
|
||||
add_task(async function() {
|
||||
// Create a real local client and use it as the remote USB client for this
|
||||
// test.
|
||||
const clientWrapper = await createLocalClientWrapper();
|
||||
|
||||
// enable USB devices mocks
|
||||
const mocks = new Mocks();
|
||||
mocks.createUSBRuntime(USB_RUNTIME_ID, {
|
||||
clientWrapper,
|
||||
deviceName: USB_DEVICE_NAME,
|
||||
name: USB_APP_NAME,
|
||||
});
|
||||
|
@ -25,8 +30,11 @@ add_task(async function() {
|
|||
await selectThisFirefoxPage(document, window.AboutDebugging.store);
|
||||
|
||||
mocks.emitUSBUpdate();
|
||||
|
||||
const onRequestSuccess = waitForRequestsSuccess(window.AboutDebugging.store);
|
||||
await connectToRuntime(USB_DEVICE_NAME, document);
|
||||
await selectRuntime(USB_DEVICE_NAME, USB_APP_NAME, document);
|
||||
await onRequestSuccess;
|
||||
|
||||
const disconnectRemoteRuntimeButton = document.querySelector(
|
||||
".qa-runtime-info__action"
|
||||
|
@ -47,5 +55,11 @@ add_task(async function() {
|
|||
"Redirection to the default page (this-firefox)"
|
||||
);
|
||||
|
||||
info("Wait until the Runtime name is displayed");
|
||||
await waitUntil(() => {
|
||||
const runtimeInfo = document.querySelector(".qa-runtime-name");
|
||||
return runtimeInfo && runtimeInfo.textContent.includes("Firefox");
|
||||
});
|
||||
|
||||
await removeTab(tab);
|
||||
});
|
||||
|
|
|
@ -161,7 +161,19 @@ class Mocks {
|
|||
|
||||
// Add a valid client that can be returned for this particular runtime id.
|
||||
let mockUsbClient = runtimeInfo.clientWrapper;
|
||||
if (!mockUsbClient) {
|
||||
if (mockUsbClient) {
|
||||
const originalGetDeviceDescription = mockUsbClient.getDeviceDescription.bind(
|
||||
mockUsbClient
|
||||
);
|
||||
mockUsbClient.getDeviceDescription = async () => {
|
||||
const deviceDescription = await originalGetDeviceDescription();
|
||||
return {
|
||||
channel: runtimeInfo.channel || deviceDescription.channel,
|
||||
name: runtimeInfo.name || deviceDescription.name,
|
||||
version: runtimeInfo.version || deviceDescription.version,
|
||||
};
|
||||
};
|
||||
} else {
|
||||
// If no clientWrapper was provided, create a mock client here.
|
||||
mockUsbClient = createClientMock();
|
||||
mockUsbClient.getDeviceDescription = () => {
|
||||
|
@ -227,3 +239,20 @@ const silenceWorkerUpdates = function() {
|
|||
});
|
||||
};
|
||||
/* exported silenceWorkerUpdates */
|
||||
|
||||
async function createLocalClientWrapper() {
|
||||
info("Create a local DevToolsClient");
|
||||
const { DevToolsServer } = require("devtools/server/devtools-server");
|
||||
const { DevToolsClient } = require("devtools/shared/client/devtools-client");
|
||||
const {
|
||||
ClientWrapper,
|
||||
} = require("devtools/client/aboutdebugging/src/modules/client-wrapper");
|
||||
|
||||
DevToolsServer.init();
|
||||
DevToolsServer.registerAllActors();
|
||||
const client = new DevToolsClient(DevToolsServer.connectPipe());
|
||||
|
||||
await client.connect();
|
||||
return new ClientWrapper(client);
|
||||
}
|
||||
/* exported createLocalClientWrapper */
|
||||
|
|
Загрузка…
Ссылка в новой задаче