mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 17:19:01 +01:00
@@ -3,24 +3,24 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// import { Application } from '../../application';
|
||||
import { Application } from '../../application';
|
||||
|
||||
export function setup() {
|
||||
describe('Terminal', () => {
|
||||
// it(`opens terminal, runs 'echo' and verifies the output`, async function () {
|
||||
// const app = this.app as Application;
|
||||
it(`opens terminal, runs 'echo' and verifies the output`, async function () {
|
||||
const app = this.app as Application;
|
||||
|
||||
// const expected = new Date().getTime().toString();
|
||||
// await app.workbench.terminal.showTerminal();
|
||||
// await app.workbench.terminal.runCommand(`echo ${expected}`);
|
||||
// await app.workbench.terminal.waitForTerminalText(terminalText => {
|
||||
// for (let index = terminalText.length - 2; index >= 0; index--) {
|
||||
// if (!!terminalText[index] && terminalText[index].trim() === expected) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// });
|
||||
// });
|
||||
const expected = new Date().getTime().toString();
|
||||
await app.workbench.terminal.showTerminal();
|
||||
await app.workbench.terminal.runCommand(`echo ${expected}`);
|
||||
await app.workbench.terminal.waitForTerminalText(terminalText => {
|
||||
for (let index = terminalText.length - 2; index >= 0; index--) {
|
||||
if (!!terminalText[index] && terminalText[index].trim() === expected) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class Terminal {
|
||||
}
|
||||
|
||||
async runCommand(commandText: string): Promise<void> {
|
||||
await this.code.waitForPaste(XTERM_TEXTAREA, commandText);
|
||||
await this.code.writeInTerminal(XTERM_SELECTOR, commandText);
|
||||
await this.code.dispatchKeybinding('enter');
|
||||
}
|
||||
|
||||
|
||||
@@ -245,11 +245,6 @@ export class Code {
|
||||
await poll(() => this.driver.setValue(windowId, selector, value), () => true, `set value '${selector}'`);
|
||||
}
|
||||
|
||||
async waitForPaste(selector: string, value: string): Promise<void> {
|
||||
const windowId = await this.getActiveWindowId();
|
||||
await poll(() => this.driver.paste(windowId, selector, value), () => true, `paste '${selector}'`);
|
||||
}
|
||||
|
||||
async waitForElements(selector: string, recursive: boolean, accept: (result: IElement[]) => boolean = result => result.length > 0): Promise<IElement[]> {
|
||||
const windowId = await this.getActiveWindowId();
|
||||
return await poll(() => this.driver.getElements(windowId, selector, recursive), accept, `get elements '${selector}'`);
|
||||
@@ -280,6 +275,11 @@ export class Code {
|
||||
await poll(() => this.driver.getTerminalBuffer(windowId, selector), accept, `get terminal buffer '${selector}'`);
|
||||
}
|
||||
|
||||
async writeInTerminal(selector: string, value: string): Promise<void> {
|
||||
const windowId = await this.getActiveWindowId();
|
||||
await poll(() => this.driver.writeInTerminal(windowId, selector, value), () => true, `writeInTerminal '${selector}'`);
|
||||
}
|
||||
|
||||
private async getActiveWindowId(): Promise<number> {
|
||||
if (typeof this._activeWindowId !== 'number') {
|
||||
const windows = await this.driver.getWindowIds();
|
||||
|
||||
Reference in New Issue
Block a user