提交 a5d75513 编写于 作者: J Joao Moreno

smoke: better reload, better extension search

上级 30c497bd
......@@ -27,6 +27,7 @@ export interface IDriver {
_serviceBrand: any;
getWindowIds(): TPromise<number[]>;
reloadWindow(windowId: number): TPromise<void>;
dispatchKeybinding(windowId: number, keybinding: string): TPromise<void>;
click(windowId: number, selector: string, xoffset?: number | undefined, yoffset?: number | undefined): TPromise<void>;
doubleClick(windowId: number, selector: string): TPromise<void>;
......@@ -42,6 +43,7 @@ export interface IDriver {
export interface IDriverChannel extends IChannel {
call(command: 'getWindowIds'): TPromise<number[]>;
call(command: 'reloadWindow', arg: number): TPromise<void>;
call(command: 'dispatchKeybinding', arg: [number, string]): TPromise<void>;
call(command: 'click', arg: [number, string, number | undefined, number | undefined]): TPromise<void>;
call(command: 'doubleClick', arg: [number, string]): TPromise<void>;
......@@ -62,6 +64,7 @@ export class DriverChannel implements IDriverChannel {
call(command: string, arg?: any): TPromise<any> {
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<void> {
return this.channel.call('reloadWindow', windowId);
}
dispatchKeybinding(windowId: number, keybinding: string): TPromise<void> {
return this.channel.call('dispatchKeybinding', [windowId, keybinding]);
}
......
......@@ -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<void> {
await this.whenUnfrozen(windowId);
const window = this.windowsService.getWindowById(windowId);
this.reloadingWindowIds.add(windowId);
window.reload();
}
async dispatchKeybinding(windowId: number, keybinding: string): TPromise<void> {
await this.whenUnfrozen(windowId);
......
......@@ -27,7 +27,6 @@ export class Application {
private _code: Code | undefined;
private _workbench: Workbench;
private keybindings: any[];
private stopLogCollection: (() => Promise<void>) | undefined;
constructor(private options: ApplicationOptions) { }
......@@ -79,7 +78,7 @@ export class Application {
}
async reload(): Promise<any> {
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<any> {
if (this.stopLogCollection) {
await this.stopLogCollection();
this.stopLogCollection = undefined;
}
if (this._code) {
this._code.dispose();
this._code = undefined;
......
......@@ -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');
});
......
......@@ -17,17 +17,13 @@ export class Extensions extends Viewlet {
async openExtensionsViewlet(): Promise<any> {
await this.commands.runCommand('workbench.view.extensions');
await this.waitForExtensionsViewlet();
}
async waitForExtensionsViewlet(): Promise<any> {
await this.code.waitForActiveElement(SEARCH_BOX);
}
async searchForExtension(name: string): Promise<any> {
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<void> {
......
......@@ -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<any> {
async runCommand(command: string): Promise<void> {
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);
}
}
......@@ -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()));
});
......
......@@ -211,6 +211,11 @@ export class Code {
await this.driver.dispatchKeybinding(windowId, keybinding);
}
async reload(): Promise<void> {
const windowId = await this.getActiveWindowId();
await this.driver.reloadWindow(windowId);
}
async waitForTextContent(selector: string, textContent?: string, accept?: (result: string) => boolean): Promise<string> {
const windowId = await this.getActiveWindowId();
accept = accept || (result => textContent !== void 0 ? textContent === result : !!result);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册