mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from master
This commit is contained in:
@@ -3,17 +3,16 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDisposable, toDisposable, combinedDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IWindowDriver, IElement, WindowDriverChannel, WindowDriverRegistryChannelClient } from 'vs/platform/driver/common/driver';
|
||||
import { IPCClient } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IWindowDriver, IElement, WindowDriverChannel, WindowDriverRegistryChannelClient } from 'vs/platform/driver/node/driver';
|
||||
import { IPCClient } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { getTopLeftOffset, getClientArea } from 'vs/base/browser/dom';
|
||||
import * as electron from 'electron';
|
||||
import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { Terminal } from 'vscode-xterm';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
|
||||
function serializeElement(element: Element, recursive: boolean): IElement {
|
||||
const attributes = Object.create(null);
|
||||
@@ -23,7 +22,7 @@ function serializeElement(element: Element, recursive: boolean): IElement {
|
||||
attributes[attr.name] = attr.value;
|
||||
}
|
||||
|
||||
const children = [];
|
||||
const children: IElement[] = [];
|
||||
|
||||
if (recursive) {
|
||||
for (let i = 0; i < element.children.length; i++) {
|
||||
@@ -62,7 +61,7 @@ class WindowDriver implements IWindowDriver {
|
||||
const element = document.querySelector(selector);
|
||||
|
||||
if (!element) {
|
||||
return TPromise.wrapError(new Error('Element not found'));
|
||||
return TPromise.wrapError(new Error(`Element not found: ${selector}`));
|
||||
}
|
||||
|
||||
const { left, top } = getTopLeftOffset(element as HTMLElement);
|
||||
@@ -86,12 +85,12 @@ class WindowDriver implements IWindowDriver {
|
||||
private _click(selector: string, clickCount: number, xoffset?: number, yoffset?: number): TPromise<void> {
|
||||
return this._getElementXY(selector, xoffset, yoffset).then(({ x, y }) => {
|
||||
|
||||
const webContents = electron.remote.getCurrentWebContents();
|
||||
const webContents: electron.WebContents = (electron as any).remote.getCurrentWebContents();
|
||||
webContents.sendInputEvent({ type: 'mouseDown', x, y, button: 'left', clickCount } as any);
|
||||
|
||||
return TPromise.timeout(10).then(() => {
|
||||
return TPromise.wrap(timeout(10)).then(() => {
|
||||
webContents.sendInputEvent({ type: 'mouseUp', x, y, button: 'left', clickCount } as any);
|
||||
return TPromise.timeout(100);
|
||||
return TPromise.wrap(timeout(100));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -100,7 +99,7 @@ class WindowDriver implements IWindowDriver {
|
||||
const element = document.querySelector(selector);
|
||||
|
||||
if (!element) {
|
||||
return TPromise.wrapError(new Error('Element not found'));
|
||||
return TPromise.wrapError(new Error(`Element not found: ${selector}`));
|
||||
}
|
||||
|
||||
const inputElement = element as HTMLInputElement;
|
||||
@@ -120,7 +119,7 @@ class WindowDriver implements IWindowDriver {
|
||||
const element = document.querySelector(selector);
|
||||
|
||||
if (element !== document.activeElement) {
|
||||
const chain = [];
|
||||
const chain: string[] = [];
|
||||
let el = document.activeElement;
|
||||
|
||||
while (el) {
|
||||
@@ -132,7 +131,7 @@ class WindowDriver implements IWindowDriver {
|
||||
el = el.parentElement;
|
||||
}
|
||||
|
||||
return TPromise.wrapError(new Error(`Active element not found. Current active element is '${chain.join(' > ')}'`));
|
||||
return TPromise.wrapError(new Error(`Active element not found. Current active element is '${chain.join(' > ')}'. Looking for ${selector}`));
|
||||
}
|
||||
|
||||
return TPromise.as(true);
|
||||
@@ -154,7 +153,7 @@ class WindowDriver implements IWindowDriver {
|
||||
const element = document.querySelector(selector);
|
||||
|
||||
if (!element) {
|
||||
return TPromise.wrapError(new Error('Editor not found: ' + selector));
|
||||
return TPromise.wrapError(new Error(`Editor not found: ${selector}`));
|
||||
}
|
||||
|
||||
const textarea = element as HTMLTextAreaElement;
|
||||
@@ -176,13 +175,13 @@ class WindowDriver implements IWindowDriver {
|
||||
const element = document.querySelector(selector);
|
||||
|
||||
if (!element) {
|
||||
return TPromise.wrapError(new Error('Terminal not found: ' + selector));
|
||||
return TPromise.wrapError(new Error(`Terminal not found: ${selector}`));
|
||||
}
|
||||
|
||||
const xterm: Terminal = (element as any).xterm;
|
||||
|
||||
if (!xterm) {
|
||||
return TPromise.wrapError(new Error('Xterm not found: ' + selector));
|
||||
return TPromise.wrapError(new Error(`Xterm not found: ${selector}`));
|
||||
}
|
||||
|
||||
const lines: string[] = [];
|
||||
@@ -198,16 +197,16 @@ class WindowDriver implements IWindowDriver {
|
||||
const element = document.querySelector(selector);
|
||||
|
||||
if (!element) {
|
||||
return TPromise.wrapError(new Error('Element not found'));
|
||||
return TPromise.wrapError(new Error(`Element not found: ${selector}`));
|
||||
}
|
||||
|
||||
const xterm: Terminal = (element as any).xterm;
|
||||
|
||||
if (!xterm) {
|
||||
return TPromise.wrapError(new Error('Xterm not found'));
|
||||
return TPromise.wrapError(new Error(`Xterm not found: ${selector}`));
|
||||
}
|
||||
|
||||
xterm._core.send(text);
|
||||
xterm._core.handler(text);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
@@ -229,11 +228,12 @@ export async function registerWindowDriver(
|
||||
const windowDriverRegistryChannel = client.getChannel('windowDriverRegistry');
|
||||
const windowDriverRegistry = new WindowDriverRegistryChannelClient(windowDriverRegistryChannel);
|
||||
|
||||
const options = await windowDriverRegistry.registerWindowDriver(windowId);
|
||||
await windowDriverRegistry.registerWindowDriver(windowId);
|
||||
// const options = await windowDriverRegistry.registerWindowDriver(windowId);
|
||||
|
||||
if (options.verbose) {
|
||||
windowDriver.openDevTools();
|
||||
}
|
||||
// if (options.verbose) {
|
||||
// windowDriver.openDevTools();
|
||||
// }
|
||||
|
||||
const disposable = toDisposable(() => windowDriverRegistry.reloadWindowDriver(windowId));
|
||||
return combinedDisposable([disposable, client]);
|
||||
|
||||
Reference in New Issue
Block a user