mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
smoke - better exit application handling
This commit is contained in:
parent
801bbff282
commit
6c3bb99c63
|
@ -42,7 +42,7 @@ export interface IDriver {
|
|||
getWindowIds(): Promise<number[]>;
|
||||
capturePage(windowId: number): Promise<string>;
|
||||
reloadWindow(windowId: number): Promise<void>;
|
||||
exitApplication(): Promise<void>;
|
||||
exitApplication(): Promise<boolean>;
|
||||
dispatchKeybinding(windowId: number, keybinding: string): Promise<void>;
|
||||
click(windowId: number, selector: string, xoffset?: number | undefined, yoffset?: number | undefined): Promise<void>;
|
||||
doubleClick(windowId: number, selector: string): Promise<void>;
|
||||
|
|
|
@ -20,7 +20,6 @@ import { KeybindingParser } from 'vs/base/common/keybindingParser';
|
|||
import { timeout } from 'vs/base/common/async';
|
||||
import { IDriver, IDriverOptions, IElement, ILocaleInfo, ILocalizedStrings, IWindowDriver, IWindowDriverRegistry } from 'vs/platform/driver/common/driver';
|
||||
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
||||
import { INativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService';
|
||||
|
||||
function isSilentKeyCode(keyCode: KeyCode) {
|
||||
return keyCode < KeyCode.KEY_0;
|
||||
|
@ -38,8 +37,7 @@ export class Driver implements IDriver, IWindowDriverRegistry {
|
|||
private windowServer: IPCServer,
|
||||
private options: IDriverOptions,
|
||||
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
|
||||
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
|
||||
@INativeHostMainService private readonly nativeHostMainService: INativeHostMainService
|
||||
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService
|
||||
) { }
|
||||
|
||||
async registerWindowDriver(windowId: number): Promise<IDriverOptions> {
|
||||
|
@ -82,8 +80,8 @@ export class Driver implements IDriver, IWindowDriverRegistry {
|
|||
this.lifecycleMainService.reload(window);
|
||||
}
|
||||
|
||||
async exitApplication(): Promise<void> {
|
||||
return this.nativeHostMainService.quit(undefined);
|
||||
exitApplication(): Promise<boolean> {
|
||||
return this.lifecycleMainService.quit();
|
||||
}
|
||||
|
||||
async dispatchKeybinding(windowId: number, keybinding: string): Promise<void> {
|
||||
|
|
|
@ -60,7 +60,7 @@ export class DriverChannelClient implements IDriver {
|
|||
return this.channel.call('reloadWindow', windowId);
|
||||
}
|
||||
|
||||
exitApplication(): Promise<void> {
|
||||
exitApplication(): Promise<boolean> {
|
||||
return this.channel.call('exitApplication');
|
||||
}
|
||||
|
||||
|
|
|
@ -294,7 +294,10 @@ export class Code {
|
|||
}
|
||||
|
||||
async exit(): Promise<void> {
|
||||
await this.driver.exitApplication();
|
||||
const success = await this.driver.exitApplication();
|
||||
if (success === false) {
|
||||
throw new Error('Code exit was blocked by a veto.');
|
||||
}
|
||||
}
|
||||
|
||||
async waitForTextContent(selector: string, textContent?: string, accept?: (result: string) => boolean, retryCount?: number): Promise<string> {
|
||||
|
|
|
@ -50,6 +50,8 @@ function buildDriver(browser: playwright.Browser, context: playwright.BrowserCon
|
|||
console.error(error); // do not fail the build when this fails
|
||||
}
|
||||
await teardown();
|
||||
|
||||
return true;
|
||||
},
|
||||
dispatchKeybinding: async (windowId, keybinding) => {
|
||||
const chords = keybinding.split(' ');
|
||||
|
@ -202,7 +204,12 @@ export function connect(options: Options = {}): Promise<{ client: IDisposable, d
|
|||
const payloadParam = `[["enableProposedApi",""],["skipWelcome","true"]]`;
|
||||
await page.goto(`${endpoint}&folder=vscode-remote://localhost:9888${URI.file(workspacePath!).path}&payload=${payloadParam}`);
|
||||
const result = {
|
||||
client: { dispose: () => browser.close() && teardown() },
|
||||
client: {
|
||||
dispose: () => {
|
||||
browser.close();
|
||||
teardown();
|
||||
}
|
||||
},
|
||||
driver: buildDriver(browser, context, page)
|
||||
};
|
||||
c(result);
|
||||
|
|
Loading…
Reference in a new issue