From 26ed89df8a1f5c01a1c9e75a18a0e1fbfc069bcb Mon Sep 17 00:00:00 2001 From: Kai Maetzel Date: Wed, 2 Jan 2019 17:28:38 -0800 Subject: [PATCH] offer exit on driver --- src/vs/platform/driver/electron-main/driver.ts | 4 ++++ src/vs/platform/driver/node/driver.ts | 6 ++++++ test/smoke/src/application.ts | 1 + test/smoke/src/vscode/code.ts | 8 +++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/vs/platform/driver/electron-main/driver.ts b/src/vs/platform/driver/electron-main/driver.ts index e51d82d1ab4..d9da862faaa 100644 --- a/src/vs/platform/driver/electron-main/driver.ts +++ b/src/vs/platform/driver/electron-main/driver.ts @@ -71,6 +71,10 @@ export class Driver implements IDriver, IWindowDriverRegistry { this.windowsService.reload(window); } + async exitApplication(): Promise { + return this.windowsService.quit(); + } + async dispatchKeybinding(windowId: number, keybinding: string): Promise { await this.whenUnfrozen(windowId); diff --git a/src/vs/platform/driver/node/driver.ts b/src/vs/platform/driver/node/driver.ts index ef5c686b3a5..e861984ca42 100644 --- a/src/vs/platform/driver/node/driver.ts +++ b/src/vs/platform/driver/node/driver.ts @@ -30,6 +30,7 @@ export interface IDriver { getWindowIds(): Promise; capturePage(windowId: number): Promise; reloadWindow(windowId: number): Promise; + exitApplication(): Promise; dispatchKeybinding(windowId: number, keybinding: string): Promise; click(windowId: number, selector: string, xoffset?: number | undefined, yoffset?: number | undefined): Promise; doubleClick(windowId: number, selector: string): Promise; @@ -56,6 +57,7 @@ export class DriverChannel implements IServerChannel { case 'getWindowIds': return this.driver.getWindowIds(); case 'capturePage': return this.driver.capturePage(arg); case 'reloadWindow': return this.driver.reloadWindow(arg); + case 'exitApplication': return this.driver.exitApplication(); 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]); @@ -90,6 +92,10 @@ export class DriverChannelClient implements IDriver { return this.channel.call('reloadWindow', windowId); } + exitApplication(): Promise { + return this.channel.call('exitApplication'); + } + dispatchKeybinding(windowId: number, keybinding: string): Promise { return this.channel.call('dispatchKeybinding', [windowId, keybinding]); } diff --git a/test/smoke/src/application.ts b/test/smoke/src/application.ts index 62d18b8319e..63001eb5fc8 100644 --- a/test/smoke/src/application.ts +++ b/test/smoke/src/application.ts @@ -89,6 +89,7 @@ export class Application { async stop(): Promise { if (this._code) { + await this._code.exit(); this._code.dispose(); this._code = undefined; } diff --git a/test/smoke/src/vscode/code.ts b/test/smoke/src/vscode/code.ts index 18b5a85dd51..7e84bc3949a 100644 --- a/test/smoke/src/vscode/code.ts +++ b/test/smoke/src/vscode/code.ts @@ -64,7 +64,7 @@ async function connect(child: cp.ChildProcess, outPath: string, handlePath: stri while (true) { try { const { client, driver } = await connectDriver(outPath, handlePath); - return new Code(child, client, driver, logger); + return new Code(client, driver, logger); } catch (err) { if (++errCount > 50) { child.kill(); @@ -188,7 +188,6 @@ export class Code { private driver: IDriver; constructor( - private process: cp.ChildProcess, private client: IDisposable, driver: IDriver, readonly logger: Logger @@ -230,6 +229,10 @@ export class Code { await this.driver.reloadWindow(windowId); } + async exit(): Promise { + await this.driver.exitApplication(); + } + 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); @@ -302,7 +305,6 @@ export class Code { dispose(): void { this.client.dispose(); - this.process.kill(); } }