提交 5dc5b4a9 编写于 作者: J Joao Moreno

smoketest: show devtools when using --verbose

上级 5ba105e0
...@@ -289,7 +289,7 @@ export class CodeApplication { ...@@ -289,7 +289,7 @@ export class CodeApplication {
// Create driver // Create driver
if (this.environmentService.driverHandle) { if (this.environmentService.driverHandle) {
serveDriver(this.electronIpcServer, this.environmentService.driverHandle, appInstantiationService).then(server => { serveDriver(this.electronIpcServer, this.environmentService.driverHandle, this.environmentService, appInstantiationService).then(server => {
this.logService.info('Driver started at:', this.environmentService.driverHandle); this.logService.info('Driver started at:', this.environmentService.driverHandle);
this.toDispose.push(server); this.toDispose.push(server);
}); });
......
...@@ -150,13 +150,17 @@ export class DriverChannelClient implements IDriver { ...@@ -150,13 +150,17 @@ export class DriverChannelClient implements IDriver {
} }
} }
export interface IDriverOptions {
verbose: boolean;
}
export interface IWindowDriverRegistry { export interface IWindowDriverRegistry {
registerWindowDriver(windowId: number): TPromise<void>; registerWindowDriver(windowId: number): TPromise<IDriverOptions>;
reloadWindowDriver(windowId: number): TPromise<void>; reloadWindowDriver(windowId: number): TPromise<void>;
} }
export interface IWindowDriverRegistryChannel extends IChannel { export interface IWindowDriverRegistryChannel extends IChannel {
call(command: 'registerWindowDriver', arg: number): TPromise<void>; call(command: 'registerWindowDriver', arg: number): TPromise<IDriverOptions>;
call(command: 'reloadWindowDriver', arg: number): TPromise<void>; call(command: 'reloadWindowDriver', arg: number): TPromise<void>;
call(command: string, arg: any): TPromise<any>; call(command: string, arg: any): TPromise<any>;
} }
...@@ -181,7 +185,7 @@ export class WindowDriverRegistryChannelClient implements IWindowDriverRegistry ...@@ -181,7 +185,7 @@ export class WindowDriverRegistryChannelClient implements IWindowDriverRegistry
constructor(private channel: IWindowDriverRegistryChannel) { } constructor(private channel: IWindowDriverRegistryChannel) { }
registerWindowDriver(windowId: number): TPromise<void> { registerWindowDriver(windowId: number): TPromise<IDriverOptions> {
return this.channel.call('registerWindowDriver', windowId); return this.channel.call('registerWindowDriver', windowId);
} }
......
...@@ -12,6 +12,7 @@ import { IPCClient } from 'vs/base/parts/ipc/common/ipc'; ...@@ -12,6 +12,7 @@ import { IPCClient } from 'vs/base/parts/ipc/common/ipc';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { getTopLeftOffset, getClientArea } from 'vs/base/browser/dom'; import { getTopLeftOffset, getClientArea } from 'vs/base/browser/dom';
import * as electron from 'electron'; import * as electron from 'electron';
import { IWindowService } from 'vs/platform/windows/common/windows';
function serializeElement(element: Element, recursive: boolean): IElement { function serializeElement(element: Element, recursive: boolean): IElement {
const attributes = Object.create(null); const attributes = Object.create(null);
...@@ -40,7 +41,9 @@ function serializeElement(element: Element, recursive: boolean): IElement { ...@@ -40,7 +41,9 @@ function serializeElement(element: Element, recursive: boolean): IElement {
class WindowDriver implements IWindowDriver { class WindowDriver implements IWindowDriver {
constructor() { } constructor(
@IWindowService private windowService: IWindowService
) { }
async click(selector: string, xoffset?: number, yoffset?: number): TPromise<void> { async click(selector: string, xoffset?: number, yoffset?: number): TPromise<void> {
return this._click(selector, 1, xoffset, yoffset); return this._click(selector, 1, xoffset, yoffset);
...@@ -183,6 +186,10 @@ class WindowDriver implements IWindowDriver { ...@@ -183,6 +186,10 @@ class WindowDriver implements IWindowDriver {
return lines; return lines;
} }
async openDevTools(): TPromise<void> {
await this.windowService.openDevTools({ mode: 'detach' });
}
} }
export async function registerWindowDriver( export async function registerWindowDriver(
...@@ -197,7 +204,11 @@ export async function registerWindowDriver( ...@@ -197,7 +204,11 @@ export async function registerWindowDriver(
const windowDriverRegistryChannel = client.getChannel('windowDriverRegistry'); const windowDriverRegistryChannel = client.getChannel('windowDriverRegistry');
const windowDriverRegistry = new WindowDriverRegistryChannelClient(windowDriverRegistryChannel); const windowDriverRegistry = new WindowDriverRegistryChannelClient(windowDriverRegistryChannel);
await windowDriverRegistry.registerWindowDriver(windowId); const options = await windowDriverRegistry.registerWindowDriver(windowId);
if (options.verbose) {
windowDriver.openDevTools();
}
const disposable = toDisposable(() => windowDriverRegistry.reloadWindowDriver(windowId)); const disposable = toDisposable(() => windowDriverRegistry.reloadWindowDriver(windowId));
return combinedDisposable([disposable, client]); return combinedDisposable([disposable, client]);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
'use strict'; 'use strict';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { IDriver, DriverChannel, IElement, IWindowDriverChannel, WindowDriverChannelClient, IWindowDriverRegistry, WindowDriverRegistryChannel, IWindowDriver } from 'vs/platform/driver/common/driver'; import { IDriver, DriverChannel, IElement, IWindowDriverChannel, WindowDriverChannelClient, IWindowDriverRegistry, WindowDriverRegistryChannel, IWindowDriver, IDriverOptions } from 'vs/platform/driver/common/driver';
import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows'; import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';
import { serve as serveNet } from 'vs/base/parts/ipc/node/ipc.net'; import { serve as serveNet } from 'vs/base/parts/ipc/node/ipc.net';
import { combinedDisposable, IDisposable } from 'vs/base/common/lifecycle'; import { combinedDisposable, IDisposable } from 'vs/base/common/lifecycle';
...@@ -16,6 +16,7 @@ import { SimpleKeybinding, KeyCode } from 'vs/base/common/keyCodes'; ...@@ -16,6 +16,7 @@ import { SimpleKeybinding, KeyCode } from 'vs/base/common/keyCodes';
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding'; import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
import { OS } from 'vs/base/common/platform'; import { OS } from 'vs/base/common/platform';
import { Emitter, toPromise } from 'vs/base/common/event'; import { Emitter, toPromise } from 'vs/base/common/event';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
// TODO@joao: bad layering! // TODO@joao: bad layering!
import { KeybindingIO } from 'vs/workbench/services/keybinding/common/keybindingIO'; import { KeybindingIO } from 'vs/workbench/services/keybinding/common/keybindingIO';
...@@ -45,13 +46,15 @@ export class Driver implements IDriver, IWindowDriverRegistry { ...@@ -45,13 +46,15 @@ export class Driver implements IDriver, IWindowDriverRegistry {
constructor( constructor(
private windowServer: IPCServer, private windowServer: IPCServer,
private options: IDriverOptions,
@IWindowsMainService private windowsService: IWindowsMainService @IWindowsMainService private windowsService: IWindowsMainService
) { } ) { }
async registerWindowDriver(windowId: number): TPromise<void> { async registerWindowDriver(windowId: number): TPromise<IDriverOptions> {
this.registeredWindowIds.add(windowId); this.registeredWindowIds.add(windowId);
this.reloadingWindowIds.delete(windowId); this.reloadingWindowIds.delete(windowId);
this.onDidReloadingChange.fire(); this.onDidReloadingChange.fire();
return this.options;
} }
async reloadWindowDriver(windowId: number): TPromise<void> { async reloadWindowDriver(windowId: number): TPromise<void> {
...@@ -203,9 +206,11 @@ export class Driver implements IDriver, IWindowDriverRegistry { ...@@ -203,9 +206,11 @@ export class Driver implements IDriver, IWindowDriverRegistry {
export async function serve( export async function serve(
windowServer: IPCServer, windowServer: IPCServer,
handle: string, handle: string,
environmentService: IEnvironmentService,
instantiationService: IInstantiationService instantiationService: IInstantiationService
): TPromise<IDisposable> { ): TPromise<IDisposable> {
const driver = instantiationService.createInstance(Driver, windowServer); const verbose = environmentService.driverVerbose;
const driver = instantiationService.createInstance(Driver, windowServer, { verbose });
const windowDriverRegistryChannel = new WindowDriverRegistryChannel(driver); const windowDriverRegistryChannel = new WindowDriverRegistryChannel(driver);
windowServer.registerChannel('windowDriverRegistry', windowDriverRegistryChannel); windowServer.registerChannel('windowDriverRegistry', windowDriverRegistryChannel);
......
...@@ -58,6 +58,7 @@ export interface ParsedArgs { ...@@ -58,6 +58,7 @@ export interface ParsedArgs {
'file-chmod'?: boolean; 'file-chmod'?: boolean;
'upload-logs'?: string; 'upload-logs'?: string;
'driver'?: string; 'driver'?: string;
'driver-verbose'?: boolean;
} }
export const IEnvironmentService = createDecorator<IEnvironmentService>('environmentService'); export const IEnvironmentService = createDecorator<IEnvironmentService>('environmentService');
...@@ -133,4 +134,5 @@ export interface IEnvironmentService { ...@@ -133,4 +134,5 @@ export interface IEnvironmentService {
disableCrashReporter: boolean; disableCrashReporter: boolean;
driverHandle: string; driverHandle: string;
driverVerbose: boolean;
} }
...@@ -62,7 +62,8 @@ const options: minimist.Opts = { ...@@ -62,7 +62,8 @@ const options: minimist.Opts = {
'skip-add-to-recently-opened', 'skip-add-to-recently-opened',
'status', 'status',
'file-write', 'file-write',
'file-chmod' 'file-chmod',
'driver-verbose'
], ],
alias: { alias: {
add: 'a', add: 'a',
......
...@@ -171,6 +171,7 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -171,6 +171,7 @@ export class EnvironmentService implements IEnvironmentService {
get disableCrashReporter(): boolean { return !!this._args['disable-crash-reporter']; } get disableCrashReporter(): boolean { return !!this._args['disable-crash-reporter']; }
get driverHandle(): string { return this._args['driver']; } get driverHandle(): string { return this._args['driver']; }
get driverVerbose(): boolean { return this._args['driver-verbose']; }
constructor(private _args: ParsedArgs, private _execPath: string) { constructor(private _args: ParsedArgs, private _execPath: string) {
if (!process.env['VSCODE_LOGS']) { if (!process.env['VSCODE_LOGS']) {
......
...@@ -92,6 +92,10 @@ export interface OpenDialogOptions { ...@@ -92,6 +92,10 @@ export interface OpenDialogOptions {
message?: string; message?: string;
} }
export interface IDevToolsOptions {
mode: 'right' | 'bottom' | 'undocked' | 'detach';
}
export interface IWindowsService { export interface IWindowsService {
_serviceBrand: any; _serviceBrand: any;
...@@ -110,7 +114,7 @@ export interface IWindowsService { ...@@ -110,7 +114,7 @@ export interface IWindowsService {
showOpenDialog(windowId: number, options: OpenDialogOptions): TPromise<string[]>; showOpenDialog(windowId: number, options: OpenDialogOptions): TPromise<string[]>;
reloadWindow(windowId: number, args?: ParsedArgs): TPromise<void>; reloadWindow(windowId: number, args?: ParsedArgs): TPromise<void>;
openDevTools(windowId: number): TPromise<void>; openDevTools(windowId: number, options?: IDevToolsOptions): TPromise<void>;
toggleDevTools(windowId: number): TPromise<void>; toggleDevTools(windowId: number): TPromise<void>;
closeWorkspace(windowId: number): TPromise<void>; closeWorkspace(windowId: number): TPromise<void>;
createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult>; createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult>;
...@@ -185,7 +189,7 @@ export interface IWindowService { ...@@ -185,7 +189,7 @@ export interface IWindowService {
pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void>; pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void>; pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
reloadWindow(args?: ParsedArgs): TPromise<void>; reloadWindow(args?: ParsedArgs): TPromise<void>;
openDevTools(): TPromise<void>; openDevTools(options?: IDevToolsOptions): TPromise<void>;
toggleDevTools(): TPromise<void>; toggleDevTools(): TPromise<void>;
closeWorkspace(): TPromise<void>; closeWorkspace(): TPromise<void>;
updateTouchBar(items: ICommandAction[][]): TPromise<void>; updateTouchBar(items: ICommandAction[][]): TPromise<void>;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { Event, buffer } from 'vs/base/common/event'; import { Event, buffer } from 'vs/base/common/event';
import { IChannel, eventToCall, eventFromCall } from 'vs/base/parts/ipc/common/ipc'; import { IChannel, eventToCall, eventFromCall } from 'vs/base/parts/ipc/common/ipc';
import { IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, CrashReporterStartOptions, IMessageBoxResult, MessageBoxOptions, SaveDialogOptions, OpenDialogOptions } from 'vs/platform/windows/common/windows'; import { IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, CrashReporterStartOptions, IMessageBoxResult, MessageBoxOptions, SaveDialogOptions, OpenDialogOptions, IDevToolsOptions } from 'vs/platform/windows/common/windows';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
import { IRecentlyOpened } from 'vs/platform/history/common/history'; import { IRecentlyOpened } from 'vs/platform/history/common/history';
import { ICommandAction } from 'vs/platform/actions/common/actions'; import { ICommandAction } from 'vs/platform/actions/common/actions';
...@@ -93,7 +93,7 @@ export class WindowsChannel implements IWindowsChannel { ...@@ -93,7 +93,7 @@ export class WindowsChannel implements IWindowsChannel {
case 'showSaveDialog': return this.service.showSaveDialog(arg[0], arg[1]); case 'showSaveDialog': return this.service.showSaveDialog(arg[0], arg[1]);
case 'showOpenDialog': return this.service.showOpenDialog(arg[0], arg[1]); case 'showOpenDialog': return this.service.showOpenDialog(arg[0], arg[1]);
case 'reloadWindow': return this.service.reloadWindow(arg[0], arg[1]); case 'reloadWindow': return this.service.reloadWindow(arg[0], arg[1]);
case 'openDevTools': return this.service.openDevTools(arg); case 'openDevTools': return this.service.openDevTools(arg[0], arg[1]);
case 'toggleDevTools': return this.service.toggleDevTools(arg); case 'toggleDevTools': return this.service.toggleDevTools(arg);
case 'closeWorkspace': return this.service.closeWorkspace(arg); case 'closeWorkspace': return this.service.closeWorkspace(arg);
case 'createAndEnterWorkspace': { case 'createAndEnterWorkspace': {
...@@ -197,8 +197,8 @@ export class WindowsChannelClient implements IWindowsService { ...@@ -197,8 +197,8 @@ export class WindowsChannelClient implements IWindowsService {
return this.channel.call('reloadWindow', [windowId, args]); return this.channel.call('reloadWindow', [windowId, args]);
} }
openDevTools(windowId: number): TPromise<void> { openDevTools(windowId: number, options?: IDevToolsOptions): TPromise<void> {
return this.channel.call('openDevTools', windowId); return this.channel.call('openDevTools', [windowId, options]);
} }
toggleDevTools(windowId: number): TPromise<void> { toggleDevTools(windowId: number): TPromise<void> {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import { Event, filterEvent, mapEvent, anyEvent } from 'vs/base/common/event'; import { Event, filterEvent, mapEvent, anyEvent } from 'vs/base/common/event';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration } from 'vs/platform/windows/common/windows'; import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, IDevToolsOptions } from 'vs/platform/windows/common/windows';
import { IRecentlyOpened } from 'vs/platform/history/common/history'; import { IRecentlyOpened } from 'vs/platform/history/common/history';
import { ICommandAction } from 'vs/platform/actions/common/actions'; import { ICommandAction } from 'vs/platform/actions/common/actions';
import { IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
...@@ -65,8 +65,8 @@ export class WindowService implements IWindowService { ...@@ -65,8 +65,8 @@ export class WindowService implements IWindowService {
return this.windowsService.reloadWindow(this.windowId, args); return this.windowsService.reloadWindow(this.windowId, args);
} }
openDevTools(): TPromise<void> { openDevTools(options?: IDevToolsOptions): TPromise<void> {
return this.windowsService.openDevTools(this.windowId); return this.windowsService.openDevTools(this.windowId, options);
} }
toggleDevTools(): TPromise<void> { toggleDevTools(): TPromise<void> {
......
...@@ -11,7 +11,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; ...@@ -11,7 +11,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { assign } from 'vs/base/common/objects'; import { assign } from 'vs/base/common/objects';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import product from 'vs/platform/node/product'; import product from 'vs/platform/node/product';
import { IWindowsService, OpenContext, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult } from 'vs/platform/windows/common/windows'; import { IWindowsService, OpenContext, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IDevToolsOptions } from 'vs/platform/windows/common/windows';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment'; import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { shell, crashReporter, app, Menu, clipboard } from 'electron'; import { shell, crashReporter, app, Menu, clipboard } from 'electron';
import { Event, fromNodeEventEmitter, mapEvent, filterEvent, anyEvent } from 'vs/base/common/event'; import { Event, fromNodeEventEmitter, mapEvent, filterEvent, anyEvent } from 'vs/base/common/event';
...@@ -112,12 +112,12 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable ...@@ -112,12 +112,12 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
return TPromise.as(null); return TPromise.as(null);
} }
openDevTools(windowId: number): TPromise<void> { openDevTools(windowId: number, options?: IDevToolsOptions): TPromise<void> {
this.logService.trace('windowsService#openDevTools', windowId); this.logService.trace('windowsService#openDevTools', windowId);
const codeWindow = this.windowsMainService.getWindowById(windowId); const codeWindow = this.windowsMainService.getWindowById(windowId);
if (codeWindow) { if (codeWindow) {
codeWindow.win.webContents.openDevTools(); codeWindow.win.webContents.openDevTools(options);
} }
return TPromise.as(null); return TPromise.as(null);
......
...@@ -108,7 +108,8 @@ export class Application { ...@@ -108,7 +108,8 @@ export class Application {
userDataDir: this.options.userDataDir, userDataDir: this.options.userDataDir,
extensionsPath: this.options.extensionsPath, extensionsPath: this.options.extensionsPath,
logger: this.options.logger, logger: this.options.logger,
extraArgs verbose: this.options.verbose,
extraArgs,
}); });
this._workbench = new Workbench(this._code, this.keybindings, this.userDataPath); this._workbench = new Workbench(this._code, this.keybindings, this.userDataPath);
......
...@@ -257,7 +257,8 @@ function createApp(quality: Quality): Application { ...@@ -257,7 +257,8 @@ function createApp(quality: Quality): Application {
extensionsPath, extensionsPath,
workspaceFilePath, workspaceFilePath,
waitTime: parseInt(opts['wait-time'] || '0') || 20, waitTime: parseInt(opts['wait-time'] || '0') || 20,
logger: new MultiLogger(loggers) logger: new MultiLogger(loggers),
verbose: opts.verbose
}); });
} }
......
...@@ -87,6 +87,7 @@ export interface SpawnOptions { ...@@ -87,6 +87,7 @@ export interface SpawnOptions {
userDataDir: string; userDataDir: string;
extensionsPath: string; extensionsPath: string;
logger: Logger; logger: Logger;
verbose?: boolean;
extraArgs?: string[]; extraArgs?: string[];
} }
...@@ -122,6 +123,10 @@ export async function spawn(options: SpawnOptions): Promise<Code> { ...@@ -122,6 +123,10 @@ export async function spawn(options: SpawnOptions): Promise<Code> {
args.unshift(repoPath); args.unshift(repoPath);
} }
if (options.verbose) {
args.push('--driver-verbose');
}
if (options.extraArgs) { if (options.extraArgs) {
args.push(...options.extraArgs); args.push(...options.extraArgs);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册