提交 68e36ecb 编写于 作者: J Joao Moreno

more wait calls

上级 5d48d471
...@@ -14,7 +14,7 @@ export class ActivityBar { ...@@ -14,7 +14,7 @@ export class ActivityBar {
constructor(private code: Code) { } constructor(private code: Code) { }
async getActivityBar(position: ActivityBarPosition): Promise<void> { async waitForActivityBar(position: ActivityBarPosition): Promise<void> {
let positionClass: string; let positionClass: string;
if (position === ActivityBarPosition.LEFT) { if (position === ActivityBarPosition.LEFT) {
......
...@@ -21,8 +21,8 @@ export class Explorer extends Viewlet { ...@@ -21,8 +21,8 @@ export class Explorer extends Viewlet {
return this.commands.runCommand('workbench.view.explorer'); return this.commands.runCommand('workbench.view.explorer');
} }
getOpenEditorsViewTitle(): Promise<string> { async waitForOpenEditorsViewTitle(fn: (title: string) => boolean): Promise<void> {
return this.code.waitForTextContent(Explorer.OPEN_EDITORS_VIEW); await this.code.waitForTextContent(Explorer.OPEN_EDITORS_VIEW, undefined, fn);
} }
async openFile(fileName: string): Promise<any> { async openFile(fileName: string): Promise<any> {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { Application, Quality } from '../../application'; import { Application, Quality } from '../../application';
export function setup() { export function setup() {
...@@ -19,15 +18,12 @@ export function setup() { ...@@ -19,15 +18,12 @@ export function setup() {
const extensionName = 'vscode-smoketest-check'; const extensionName = 'vscode-smoketest-check';
await app.workbench.extensions.openExtensionsViewlet(); await app.workbench.extensions.openExtensionsViewlet();
const installed = await app.workbench.extensions.installExtension(extensionName); await app.workbench.extensions.installExtension(extensionName);
assert.ok(installed);
await app.reload(); await app.reload();
await app.workbench.extensions.waitForExtensionsViewlet(); await app.workbench.extensions.waitForExtensionsViewlet();
await app.workbench.runCommand('Smoke Test Check'); await app.workbench.runCommand('Smoke Test Check');
await app.workbench.statusbar.waitForStatusbarText('smoke test', 'VS Code Smoke Test Check');
const statusbarText = await app.workbench.statusbar.getStatusbarTextByTitle('smoke test');
assert.equal(statusbarText, 'VS Code Smoke Test Check');
}); });
}); });
} }
\ No newline at end of file
...@@ -32,7 +32,6 @@ export class Extensions extends Viewlet { ...@@ -32,7 +32,6 @@ export class Extensions extends Viewlet {
async installExtension(name: string): Promise<void> { async installExtension(name: string): Promise<void> {
await this.searchForExtension(name); await this.searchForExtension(name);
await this.code.waitAndClick(`div.extensions-viewlet[id="workbench.view.extensions"] .monaco-list-row[aria-label="${name}"] .extension li[class='action-item'] .extension-action.install`); await this.code.waitAndClick(`div.extensions-viewlet[id="workbench.view.extensions"] .monaco-list-row[aria-label="${name}"] .extension li[class='action-item'] .extension-action.install`);
await this.code.waitForElement(`div.extensions-viewlet[id="workbench.view.extensions"] .monaco-list-row[aria-label="${name}"] .extension li[class='action-item'] .extension-action.reload`); await this.code.waitForElement(`div.extensions-viewlet[id="workbench.view.extensions"] .monaco-list-row[aria-label="${name}"] .extension li[class='action-item'] .extension-action.reload`);
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { Application } from '../../application'; import { Application } from '../../application';
export function setup() { export function setup() {
...@@ -27,8 +26,7 @@ export function setup() { ...@@ -27,8 +26,7 @@ export function setup() {
it('shows workspace name in title', async function () { it('shows workspace name in title', async function () {
const app = this.app as Application; const app = this.app as Application;
const title = await app.code.getTitle(); await app.code.waitForTitle(title => /smoketest \(Workspace\)/i.test(title));
assert.ok(title.indexOf('smoketest (Workspace)') >= 0);
}); });
}); });
} }
\ No newline at end of file
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { Application } from '../../application'; import { Application } from '../../application';
import { ActivityBarPosition } from '../activitybar/activityBar'; import { ActivityBarPosition } from '../activitybar/activityBar';
...@@ -23,12 +21,12 @@ export function setup() { ...@@ -23,12 +21,12 @@ export function setup() {
it(`changes 'workbench.action.toggleSidebarPosition' command key binding and verifies it`, async function () { it(`changes 'workbench.action.toggleSidebarPosition' command key binding and verifies it`, async function () {
const app = this.app as Application; const app = this.app as Application;
assert.ok(await app.workbench.activitybar.getActivityBar(ActivityBarPosition.LEFT), 'Activity bar should be positioned on the left.'); await app.workbench.activitybar.waitForActivityBar(ActivityBarPosition.LEFT);
await app.workbench.keybindingsEditor.updateKeybinding('workbench.action.toggleSidebarPosition', 'ctrl+u', 'Control+U'); await app.workbench.keybindingsEditor.updateKeybinding('workbench.action.toggleSidebarPosition', 'ctrl+u', 'Control+U');
await app.code.dispatchKeybinding('ctrl+u'); await app.code.dispatchKeybinding('ctrl+u');
assert.ok(await app.workbench.activitybar.getActivityBar(ActivityBarPosition.RIGHT), 'Activity bar was not moved to right after toggling its position.'); await app.workbench.activitybar.waitForActivityBar(ActivityBarPosition.RIGHT);
}); });
after(async function () { after(async function () {
......
...@@ -37,8 +37,8 @@ export class StatusBar { ...@@ -37,8 +37,8 @@ export class StatusBar {
return this.code.waitForTextContent(this.getSelector(StatusBarElement.EOL_STATUS), eol); return this.code.waitForTextContent(this.getSelector(StatusBarElement.EOL_STATUS), eol);
} }
async getStatusbarTextByTitle(title: string): Promise<string> { async waitForStatusbarText(title: string, text: string): Promise<void> {
return await this.code.waitForTextContent(`${this.mainSelector} span[title="smoke test"]`); await this.code.waitForTextContent(`${this.mainSelector} span[title="${title}"]`, text);
} }
private getSelector(element: StatusBarElement): string { private getSelector(element: StatusBarElement): string {
......
...@@ -3,13 +3,11 @@ ...@@ -3,13 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { Application, Quality } from '../../application'; import { Application, Quality } from '../../application';
import * as rimraf from 'rimraf'; import * as rimraf from 'rimraf';
export interface ICreateAppFn { export interface ICreateAppFn {
(quality: Quality): Application | null; (quality: Quality): Application;
} }
export function setup(userDataDir: string, createApp: ICreateAppFn) { export function setup(userDataDir: string, createApp: ICreateAppFn) {
...@@ -40,14 +38,9 @@ export function setup(userDataDir: string, createApp: ICreateAppFn) { ...@@ -40,14 +38,9 @@ export function setup(userDataDir: string, createApp: ICreateAppFn) {
// Checking latest version for the restored state // Checking latest version for the restored state
const app = createApp(Quality.Insiders); const app = createApp(Quality.Insiders);
if (!app) {
return assert(false);
}
await app.start(false); await app.start(false);
assert.ok(await app.workbench.editors.waitForActiveTab('Untitled-1', true), `Untitled-1 tab is not present after migration.`); await app.workbench.editors.waitForActiveTab('Untitled-1', true);
await app.workbench.editor.waitForEditorContents('Untitled-1', c => c.indexOf(textToType) > -1); await app.workbench.editor.waitForEditorContents('Untitled-1', c => c.indexOf(textToType) > -1);
await app.stop(); await app.stop();
...@@ -76,13 +69,9 @@ export function setup(userDataDir: string, createApp: ICreateAppFn) { ...@@ -76,13 +69,9 @@ export function setup(userDataDir: string, createApp: ICreateAppFn) {
// Checking latest version for the restored state // Checking latest version for the restored state
const app = createApp(Quality.Insiders); const app = createApp(Quality.Insiders);
if (!app) {
return assert(false);
}
await app.start(false); await app.start(false);
assert.ok(await app.workbench.editors.waitForActiveTab(fileName), `dirty file tab is not present after migration.`); await app.workbench.editors.waitForActiveTab(fileName);
await app.workbench.editor.waitForEditorContents(fileName, c => c.indexOf(textPart) > -1); await app.workbench.editor.waitForEditorContents(fileName, c => c.indexOf(textPart) > -1);
await app.stop(); await app.stop();
...@@ -109,15 +98,11 @@ export function setup(userDataDir: string, createApp: ICreateAppFn) { ...@@ -109,15 +98,11 @@ export function setup(userDataDir: string, createApp: ICreateAppFn) {
const app = createApp(Quality.Insiders); const app = createApp(Quality.Insiders);
if (!app) {
return assert(false);
}
await app.start(false); await app.start(false);
assert.ok(await app.workbench.editors.waitForTab(fileName1), `${fileName1} tab was not restored after migration.`); await app.workbench.editors.waitForTab(fileName1);
assert.ok(await app.workbench.editors.waitForTab(fileName2), `${fileName2} tab was not restored after migration.`); await app.workbench.editors.waitForTab(fileName2);
assert.ok(await app.workbench.editors.waitForTab(fileName3), `${fileName3} tab was not restored after migration.`); await app.workbench.editors.waitForTab(fileName3);
await app.stop(); await app.stop();
}); });
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { Application, Quality } from '../../application'; import { Application, Quality } from '../../application';
export function setup() { export function setup() {
...@@ -27,24 +25,19 @@ export function setup() { ...@@ -27,24 +25,19 @@ export function setup() {
return; return;
} }
let text = await app.workbench.explorer.getOpenEditorsViewTitle(); await app.workbench.explorer.waitForOpenEditorsViewTitle(title => /geöffnete editoren/i.test(title));
assert(/geöffnete editoren/i.test(text));
await app.workbench.search.openSearchViewlet(); await app.workbench.search.openSearchViewlet();
text = await app.workbench.search.getTitle(); await app.workbench.search.waitForTitle(title => /suchen/i.test(title));
assert(/suchen/i.test(text));
await app.workbench.scm.openSCMViewlet(); await app.workbench.scm.openSCMViewlet();
text = await app.workbench.scm.getTitle(); await app.workbench.scm.waitForTitle(title => /quellcodeverwaltung/i.test(title));
assert(/quellcodeverwaltung/i.test(text));
await app.workbench.debug.openDebugViewlet(); await app.workbench.debug.openDebugViewlet();
text = await app.workbench.debug.getTitle(); await app.workbench.debug.waitForTitle(title => /debuggen/i.test(title));
assert(/debuggen/i.test(text));
await app.workbench.extensions.openExtensionsViewlet(); await app.workbench.extensions.openExtensionsViewlet();
text = await app.workbench.extensions.getTitle(); await app.workbench.extensions.waitForTitle(title => /erweiterungen/i.test(title));
assert(/erweiterungen/i.test(text));
}); });
}); });
} }
\ No newline at end of file
...@@ -9,11 +9,9 @@ import { Code } from '../../vscode/code'; ...@@ -9,11 +9,9 @@ import { Code } from '../../vscode/code';
export abstract class Viewlet { export abstract class Viewlet {
constructor(protected code: Code) { constructor(protected code: Code) { }
// noop
}
async getTitle(): Promise<string> { async waitForTitle(fn: (title: string) => boolean): Promise<void> {
return this.code.waitForTextContent('.monaco-workbench-container .part.sidebar > .title > .title-label > span'); await this.code.waitForTextContent('.monaco-workbench-container .part.sidebar > .title > .title-label > span', undefined, fn);
} }
} }
\ No newline at end of file
...@@ -100,16 +100,16 @@ function getBuildElectronPath(root: string): string { ...@@ -100,16 +100,16 @@ function getBuildElectronPath(root: string): string {
} }
let testCodePath = opts.build; let testCodePath = opts.build;
let stableCodePath = opts['stable-build']; // let stableCodePath = opts['stable-build'];
let electronPath: string; let electronPath: string;
let stablePath: string; // let stablePath: string;
if (testCodePath) { if (testCodePath) {
electronPath = getBuildElectronPath(testCodePath); electronPath = getBuildElectronPath(testCodePath);
if (stableCodePath) { // if (stableCodePath) {
stablePath = getBuildElectronPath(stableCodePath); // stablePath = getBuildElectronPath(stableCodePath);
} // }
} else { } else {
testCodePath = getDevElectronPath(); testCodePath = getDevElectronPath();
electronPath = testCodePath; electronPath = testCodePath;
...@@ -228,13 +228,7 @@ async function setup(): Promise<void> { ...@@ -228,13 +228,7 @@ async function setup(): Promise<void> {
console.log('*** Smoketest setup done!\n'); console.log('*** Smoketest setup done!\n');
} }
function createApp(quality: Quality): Application | null { function createApp(quality: Quality): Application {
const path = quality === Quality.Stable ? stablePath : electronPath;
if (!path) {
return null;
}
return new Application({ return new Application({
quality, quality,
codePath: opts.build, codePath: opts.build,
...@@ -246,6 +240,7 @@ function createApp(quality: Quality): Application | null { ...@@ -246,6 +240,7 @@ function createApp(quality: Quality): Application | null {
verbose: opts.verbose verbose: opts.verbose
}); });
} }
before(async function () { before(async function () {
// allow two minutes for setup // allow two minutes for setup
this.timeout(2 * 60 * 1000); this.timeout(2 * 60 * 1000);
......
...@@ -246,23 +246,22 @@ export class Code { ...@@ -246,23 +246,22 @@ export class Code {
return await this.waitFor<IElement>(() => this.driver.getElements(windowId, selector).then(els => els[0]), accept, `element with selector ${selector}`); return await this.waitFor<IElement>(() => this.driver.getElements(windowId, selector).then(els => els[0]), accept, `element with selector ${selector}`);
} }
async waitForActiveElement(selector: string): Promise<any> { async waitForActiveElement(selector: string): Promise<void> {
if (this.verbose) { if (this.verbose) {
console.log('- waitForActiveElement:', selector); console.log('- waitForActiveElement:', selector);
} }
const windowId = await this.getActiveWindowId(); const windowId = await this.getActiveWindowId();
return await this.waitFor(() => this.driver.isActiveElement(windowId, selector), undefined, `wait for active element: ${selector}`); await this.waitFor(() => this.driver.isActiveElement(windowId, selector), undefined, `wait for active element: ${selector}`);
} }
// TODO make into waitForTitle async waitForTitle(fn: (title: string) => boolean): Promise<void> {
async getTitle(): Promise<string> {
if (this.verbose) { if (this.verbose) {
console.log('- getTitle'); console.log('- getTitle');
} }
const windowId = await this.getActiveWindowId(); const windowId = await this.getActiveWindowId();
return await this.driver.getTitle(windowId); await this.waitFor(() => this.driver.getTitle(windowId), fn, 'wait for title: ${}');
} }
// TODO make into waitForTypeInEditor // TODO make into waitForTypeInEditor
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册