From a5d755138c22fd709c4d211468e0a5b775925b05 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 13 Apr 2018 10:31:56 +0200 Subject: [PATCH] smoke: better reload, better extension search --- src/vs/platform/driver/common/driver.ts | 7 +++++++ src/vs/platform/driver/electron-main/driver.ts | 8 ++++++++ test/smoke/src/application.ts | 8 +------- test/smoke/src/areas/extensions/extensions.test.ts | 2 +- test/smoke/src/areas/extensions/extensions.ts | 6 +----- test/smoke/src/areas/workbench/workbench.ts | 10 +++++----- test/smoke/src/main.ts | 1 + test/smoke/src/vscode/code.ts | 5 +++++ 8 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/vs/platform/driver/common/driver.ts b/src/vs/platform/driver/common/driver.ts index 6abbc5d59ad..e3084f34aa8 100644 --- a/src/vs/platform/driver/common/driver.ts +++ b/src/vs/platform/driver/common/driver.ts @@ -27,6 +27,7 @@ export interface IDriver { _serviceBrand: any; getWindowIds(): TPromise; + reloadWindow(windowId: number): TPromise; dispatchKeybinding(windowId: number, keybinding: string): TPromise; click(windowId: number, selector: string, xoffset?: number | undefined, yoffset?: number | undefined): TPromise; doubleClick(windowId: number, selector: string): TPromise; @@ -42,6 +43,7 @@ export interface IDriver { export interface IDriverChannel extends IChannel { call(command: 'getWindowIds'): TPromise; + call(command: 'reloadWindow', arg: number): TPromise; call(command: 'dispatchKeybinding', arg: [number, string]): TPromise; call(command: 'click', arg: [number, string, number | undefined, number | undefined]): TPromise; call(command: 'doubleClick', arg: [number, string]): TPromise; @@ -62,6 +64,7 @@ export class DriverChannel implements IDriverChannel { call(command: string, arg?: any): TPromise { switch (command) { case 'getWindowIds': return this.driver.getWindowIds(); + case 'reloadWindow': return this.driver.reloadWindow(arg); case 'dispatchKeybinding': return this.driver.dispatchKeybinding(arg[0], arg[1]); case 'click': return this.driver.click(arg[0], arg[1], arg[2], arg[3]); case 'doubleClick': return this.driver.doubleClick(arg[0], arg[1]); @@ -88,6 +91,10 @@ export class DriverChannelClient implements IDriver { return this.channel.call('getWindowIds'); } + reloadWindow(windowId: number): TPromise { + return this.channel.call('reloadWindow', windowId); + } + dispatchKeybinding(windowId: number, keybinding: string): TPromise { return this.channel.call('dispatchKeybinding', [windowId, keybinding]); } diff --git a/src/vs/platform/driver/electron-main/driver.ts b/src/vs/platform/driver/electron-main/driver.ts index aa8ad7ed625..1f055e46285 100644 --- a/src/vs/platform/driver/electron-main/driver.ts +++ b/src/vs/platform/driver/electron-main/driver.ts @@ -63,6 +63,14 @@ export class Driver implements IDriver, IWindowDriverRegistry { .filter(id => this.registeredWindowIds.has(id) && !this.reloadingWindowIds.has(id)); } + async reloadWindow(windowId: number): TPromise { + await this.whenUnfrozen(windowId); + + const window = this.windowsService.getWindowById(windowId); + this.reloadingWindowIds.add(windowId); + window.reload(); + } + async dispatchKeybinding(windowId: number, keybinding: string): TPromise { await this.whenUnfrozen(windowId); diff --git a/test/smoke/src/application.ts b/test/smoke/src/application.ts index 16f174b899c..76e7dd417f4 100644 --- a/test/smoke/src/application.ts +++ b/test/smoke/src/application.ts @@ -27,7 +27,6 @@ export class Application { private _code: Code | undefined; private _workbench: Workbench; private keybindings: any[]; - private stopLogCollection: (() => Promise) | undefined; constructor(private options: ApplicationOptions) { } @@ -79,7 +78,7 @@ export class Application { } async reload(): Promise { - this.workbench.runCommand('Reload Window') + this.code.reload() .catch(err => null); // ignore the connection drop errors // needs to be enough to propagate the 'Reload Window' command @@ -88,11 +87,6 @@ export class Application { } async stop(): Promise { - if (this.stopLogCollection) { - await this.stopLogCollection(); - this.stopLogCollection = undefined; - } - if (this._code) { this._code.dispose(); this._code = undefined; diff --git a/test/smoke/src/areas/extensions/extensions.test.ts b/test/smoke/src/areas/extensions/extensions.test.ts index ca3cbc1774f..2b51741cd52 100644 --- a/test/smoke/src/areas/extensions/extensions.test.ts +++ b/test/smoke/src/areas/extensions/extensions.test.ts @@ -21,7 +21,7 @@ export function setup() { await app.workbench.extensions.installExtension(extensionName); await app.reload(); - await app.workbench.extensions.waitForExtensionsViewlet(); + await app.workbench.extensions.openExtensionsViewlet(); await app.workbench.runCommand('Smoke Test Check'); await app.workbench.statusbar.waitForStatusbarText('smoke test', 'VS Code Smoke Test Check'); }); diff --git a/test/smoke/src/areas/extensions/extensions.ts b/test/smoke/src/areas/extensions/extensions.ts index 64bfb07dd3d..a523250e928 100644 --- a/test/smoke/src/areas/extensions/extensions.ts +++ b/test/smoke/src/areas/extensions/extensions.ts @@ -17,17 +17,13 @@ export class Extensions extends Viewlet { async openExtensionsViewlet(): Promise { await this.commands.runCommand('workbench.view.extensions'); - await this.waitForExtensionsViewlet(); - } - - async waitForExtensionsViewlet(): Promise { await this.code.waitForActiveElement(SEARCH_BOX); } async searchForExtension(name: string): Promise { await this.code.waitAndClick(SEARCH_BOX); await this.code.waitForActiveElement(SEARCH_BOX); - await this.code.waitForSetValue(SEARCH_BOX, name); + await this.code.waitForSetValue(SEARCH_BOX, `name:"${name}"`); } async installExtension(name: string): Promise { diff --git a/test/smoke/src/areas/workbench/workbench.ts b/test/smoke/src/areas/workbench/workbench.ts index d81733bb58b..7d1e2fa0182 100644 --- a/test/smoke/src/areas/workbench/workbench.ts +++ b/test/smoke/src/areas/workbench/workbench.ts @@ -58,14 +58,14 @@ export class Workbench implements Commands { * Retrieves the command from keybindings file and executes it with WebdriverIO client API * @param command command (e.g. 'workbench.action.files.newUntitledFile') */ - async runCommand(command: string): Promise { + async runCommand(command: string): Promise { const binding = this.keybindings.find(x => x['command'] === command); - if (!binding) { + + if (binding) { + await this.code.dispatchKeybinding(binding.key); + } else { await this.quickopen.runCommand(command); - return; } - - return this.code.dispatchKeybinding(binding.key); } } diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index 63149f3e522..c73fd841400 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -248,6 +248,7 @@ before(async function () { }); after(async function () { + await new Promise(c => setTimeout(c, 500)); // wait for shutdown await new Promise((c, e) => rimraf(testDataPath, { maxBusyTries: 10 }, err => err ? e(err) : c())); }); diff --git a/test/smoke/src/vscode/code.ts b/test/smoke/src/vscode/code.ts index 0626082151e..14ee5c4a51b 100644 --- a/test/smoke/src/vscode/code.ts +++ b/test/smoke/src/vscode/code.ts @@ -211,6 +211,11 @@ export class Code { await this.driver.dispatchKeybinding(windowId, keybinding); } + async reload(): Promise { + const windowId = await this.getActiveWindowId(); + await this.driver.reloadWindow(windowId); + } + async waitForTextContent(selector: string, textContent?: string, accept?: (result: string) => boolean): Promise { const windowId = await this.getActiveWindowId(); accept = accept || (result => textContent !== void 0 ? textContent === result : !!result); -- GitLab