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

more wait calls

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