未验证 提交 9bdcd610 编写于 作者: J João Moreno 提交者: GitHub

Merge pull request #65941 from Microsoft/kieferrm/smoke-test-shutdown

Gentle shutdown of application in smoke test
......@@ -71,6 +71,10 @@ export class Driver implements IDriver, IWindowDriverRegistry {
this.windowsService.reload(window);
}
async exitApplication(): Promise<void> {
return this.windowsService.quit();
}
async dispatchKeybinding(windowId: number, keybinding: string): Promise<void> {
await this.whenUnfrozen(windowId);
......
......@@ -30,6 +30,7 @@ export interface IDriver {
getWindowIds(): Promise<number[]>;
capturePage(windowId: number): Promise<string>;
reloadWindow(windowId: number): Promise<void>;
exitApplication(): Promise<void>;
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>;
......@@ -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<void> {
return this.channel.call('exitApplication');
}
dispatchKeybinding(windowId: number, keybinding: string): Promise<void> {
return this.channel.call('dispatchKeybinding', [windowId, keybinding]);
}
......
......@@ -89,6 +89,7 @@ export class Application {
async stop(): Promise<any> {
if (this._code) {
await this._code.exit();
this._code.dispose();
this._code = undefined;
}
......
......@@ -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<void> {
await this.driver.exitApplication();
}
async waitForTextContent(selector: string, textContent?: string, accept?: (result: string) => boolean): Promise<string> {
const windowId = await this.getActiveWindowId();
accept = accept || (result => textContent !== undefined ? textContent === result : !!result);
......@@ -302,7 +305,6 @@ export class Code {
dispose(): void {
this.client.dispose();
this.process.kill();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册