workbenchTestServices.ts 41.2 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6 7
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

8
import 'vs/workbench/parts/files/electron-browser/files.contribution'; // load our contribution into the test
S
Sandeep Somavarapu 已提交
9
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
J
Johannes Rieken 已提交
10
import { Promise, TPromise } from 'vs/base/common/winjs.base';
11
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
12
import * as paths from 'vs/base/common/paths';
E
Erich Gamma 已提交
13
import URI from 'vs/base/common/uri';
14 15
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
16
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
B
Benjamin Pasero 已提交
17 18
import { ConfirmResult, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent } from 'vs/workbench/common/editor';
import { IEditorOpeningEvent, IEditorPartService, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
M
Matt Bierner 已提交
19
import { Event, Emitter } from 'vs/base/common/event';
E
Erich Gamma 已提交
20
import Severity from 'vs/base/common/severity';
21
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
22
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
J
Johannes Rieken 已提交
23
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
24
import { IPartService, Parts, Position as PartPosition, IDimension } from 'vs/workbench/services/part/common/partService';
25
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
26
import { ITextModelService } from 'vs/editor/common/services/resolverService';
B
Benjamin Pasero 已提交
27
import { IEditorOptions, IResourceInput } from 'vs/platform/editor/common/editor';
J
Johannes Rieken 已提交
28
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
S
Sandeep Somavarapu 已提交
29
import { IWorkspaceContextService, IWorkspace as IWorkbenchWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent } from 'vs/platform/workspace/common/workspace';
30
import { ILifecycleService, ShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
J
Johannes Rieken 已提交
31
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
32
import { TextFileService } from 'vs/workbench/services/textfile/common/textFileService';
33
import { FileOperationEvent, IFileService, IResolveContentOptions, FileOperationError, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, IContent, IUpdateContentOptions, IStreamContent, ICreateFileOptions, ITextSnapshot, IResourceEncodings } from 'vs/platform/files/common/files';
34
import { IModelService } from 'vs/editor/common/services/modelService';
35
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
J
Johannes Rieken 已提交
36 37 38 39 40 41
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { IRawTextContent, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { parseArgs } from 'vs/platform/environment/node/argv';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
42
import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
43
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
44
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration } from 'vs/platform/windows/common/windows';
S
Sandeep Somavarapu 已提交
45
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
46
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
B
Benjamin Pasero 已提交
47
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
48
import { IThemeService } from 'vs/platform/theme/common/themeService';
49
import { isLinux } from 'vs/base/common/platform';
B
Benjamin Pasero 已提交
50 51
import { generateUuid } from 'vs/base/common/uuid';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
52
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
B
Benjamin Pasero 已提交
53
import { IRecentlyOpened } from 'vs/platform/history/common/history';
54
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
55
import { IPosition, Position as EditorPosition } from 'vs/editor/common/core/position';
B
Benjamin Pasero 已提交
56
import { ICommandAction, IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
R
Ramya Achutha Rao 已提交
57
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
I
isidor 已提交
58
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
B
Benjamin Pasero 已提交
59
import { MockContextKeyService, MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
B
Benjamin Pasero 已提交
60
import { ITextBufferFactory, DefaultEndOfLine, EndOfLinePreference, IModelDecorationOptions, ITextModel } from 'vs/editor/common/model';
61
import { Range } from 'vs/editor/common/core/range';
62
import { IConfirmation, IConfirmationResult, IDialogService, IDialogOptions } from 'vs/platform/dialogs/common/dialogs';
63 64
import { INotificationService } from 'vs/platform/notification/common/notification';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
B
Benjamin Pasero 已提交
65 66 67 68 69
import { IExtensionService, ProfileSession, IExtensionsStatus, ExtensionPointContribution, IExtensionDescription } from '../services/extensions/common/extensions';
import { IExtensionPoint } from 'vs/workbench/services/extensions/common/extensionsRegistry';
import { IKeybindingService } from '../../platform/keybinding/common/keybinding';
import { IDecorationsService, IResourceDecorationChangeEvent, IDecoration, IDecorationData, IDecorationsProvider } from 'vs/workbench/services/decorations/browser/decorations';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
70 71
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, EditorsOrder, IFindGroupScope } from 'vs/workbench/services/group/common/editorGroupsService';
import { IEditorService, IOpenEditorOverrideHandler } from 'vs/workbench/services/editor/common/editorService';
B
Benjamin Pasero 已提交
72 73 74
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
import { IDecorationRenderOptions } from 'vs/editor/common/editorCommon';
B
Benjamin Pasero 已提交
75
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
B
Benjamin Pasero 已提交
76

S
Sandeep Somavarapu 已提交
77 78 79 80
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
	return instantiationService.createInstance(FileEditorInput, resource, void 0);
}

81
export const TestEnvironmentService = new EnvironmentService(parseArgs(process.argv), process.execPath);
82

83
export class TestContextService implements IWorkspaceContextService {
84
	public _serviceBrand: any;
E
Erich Gamma 已提交
85

86
	private workspace: IWorkbenchWorkspace;
E
Erich Gamma 已提交
87 88
	private options: any;

M
Matt Bierner 已提交
89 90 91
	private readonly _onDidChangeWorkspaceName: Emitter<void>;
	private readonly _onDidChangeWorkspaceFolders: Emitter<IWorkspaceFoldersChangeEvent>;
	private readonly _onDidChangeWorkbenchState: Emitter<WorkbenchState>;
92

93
	constructor(workspace: any = TestWorkspace, options: any = null) {
E
Erich Gamma 已提交
94
		this.workspace = workspace;
95
		this.options = options || Object.create(null);
96
		this._onDidChangeWorkspaceFolders = new Emitter<IWorkspaceFoldersChangeEvent>();
S
Sandeep Somavarapu 已提交
97
		this._onDidChangeWorkbenchState = new Emitter<WorkbenchState>();
98 99
	}

S
Sandeep Somavarapu 已提交
100 101 102 103
	public get onDidChangeWorkspaceName(): Event<void> {
		return this._onDidChangeWorkspaceName.event;
	}

104
	public get onDidChangeWorkspaceFolders(): Event<IWorkspaceFoldersChangeEvent> {
S
Sandeep Somavarapu 已提交
105
		return this._onDidChangeWorkspaceFolders.event;
106 107
	}

108 109 110 111
	public get onDidChangeWorkbenchState(): Event<WorkbenchState> {
		return this._onDidChangeWorkbenchState.event;
	}

S
Sandeep Somavarapu 已提交
112
	public getFolders(): IWorkspaceFolder[] {
S
Sandeep Somavarapu 已提交
113
		return this.workspace ? this.workspace.folders : [];
E
Erich Gamma 已提交
114 115
	}

116
	public getWorkbenchState(): WorkbenchState {
B
Benjamin Pasero 已提交
117 118 119 120 121
		if (this.workspace.configuration) {
			return WorkbenchState.WORKSPACE;
		}

		if (this.workspace.folders.length) {
122
			return WorkbenchState.FOLDER;
123
		}
B
Benjamin Pasero 已提交
124

125
		return WorkbenchState.EMPTY;
S
Sandeep Somavarapu 已提交
126 127
	}

128
	public getWorkspace(): IWorkbenchWorkspace {
B
Benjamin Pasero 已提交
129
		return this.workspace;
130 131
	}

S
Sandeep Somavarapu 已提交
132
	public getWorkspaceFolder(resource: URI): IWorkspaceFolder {
S
Sandeep Somavarapu 已提交
133
		return this.isInsideWorkspace(resource) ? this.workspace.folders[0] : null;
134 135
	}

D
Daniel Imms 已提交
136 137 138 139
	public setWorkspace(workspace: any): void {
		this.workspace = workspace;
	}

E
Erich Gamma 已提交
140 141 142 143 144 145 146 147 148 149
	public getOptions() {
		return this.options;
	}

	public updateOptions() {

	}

	public isInsideWorkspace(resource: URI): boolean {
		if (resource && this.workspace) {
150
			return paths.isEqualOrParent(resource.fsPath, this.workspace.folders[0].uri.fsPath, !isLinux /* ignorecase */);
E
Erich Gamma 已提交
151 152 153 154 155 156
		}

		return false;
	}

	public toResource(workspaceRelativePath: string): URI {
157
		return URI.file(paths.join('C:\\', workspaceRelativePath));
E
Erich Gamma 已提交
158
	}
159 160

	public isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean {
161
		return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && this.pathEquals(this.workspace.folders[0].uri.fsPath, workspaceIdentifier);
162 163 164 165 166 167 168 169 170 171
	}

	private pathEquals(path1: string, path2: string): boolean {
		if (!isLinux) {
			path1 = path1.toLowerCase();
			path2 = path2.toLowerCase();
		}

		return path1 === path2;
	}
E
Erich Gamma 已提交
172 173
}

174
export class TestTextFileService extends TextFileService {
175 176
	public cleanupBackupsBeforeShutdownCalled: boolean;

177 178
	private promptPath: string;
	private confirmResult: ConfirmResult;
179
	private resolveTextContentError: FileOperationError;
A
Alex Dima 已提交
180 181

	constructor(
182 183
		@ILifecycleService lifecycleService: ILifecycleService,
		@IWorkspaceContextService contextService: IWorkspaceContextService,
A
Alex Dima 已提交
184 185
		@IConfigurationService configurationService: IConfigurationService,
		@IFileService fileService: IFileService,
186
		@IUntitledEditorService untitledEditorService: IUntitledEditorService,
187
		@IInstantiationService instantiationService: IInstantiationService,
188
		@INotificationService notificationService: INotificationService,
189
		@IBackupFileService backupFileService: IBackupFileService,
190
		@IWindowsService windowsService: IWindowsService,
I
isidor 已提交
191
		@IHistoryService historyService: IHistoryService,
B
Benjamin Pasero 已提交
192 193
		@IContextKeyService contextKeyService: IContextKeyService,
		@IModelService modelService: IModelService
A
Alex Dima 已提交
194
	) {
195
		super(lifecycleService, contextService, configurationService, fileService, untitledEditorService, instantiationService, notificationService, TestEnvironmentService, backupFileService, windowsService, historyService, contextKeyService, modelService);
A
Alex Dima 已提交
196
	}
197

198 199 200 201 202 203 204 205
	public setPromptPath(path: string): void {
		this.promptPath = path;
	}

	public setConfirmResult(result: ConfirmResult): void {
		this.confirmResult = result;
	}

206
	public setResolveTextContentErrorOnce(error: FileOperationError): void {
207 208 209
		this.resolveTextContentError = error;
	}

210
	public resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise<IRawTextContent> {
211 212 213 214
		if (this.resolveTextContentError) {
			const error = this.resolveTextContentError;
			this.resolveTextContentError = null;

215
			return TPromise.wrapError<IRawTextContent>(error);
216 217
		}

218 219
		return this.fileService.resolveContent(resource, options).then((content): IRawTextContent => {
			return {
220
				resource: content.resource,
221 222 223 224
				name: content.name,
				mtime: content.mtime,
				etag: content.etag,
				encoding: content.encoding,
225
				value: createTextBufferFactory(content.value)
226 227 228
			};
		});
	}
229

230 231
	public promptForPath(defaultPath: string): TPromise<string> {
		return TPromise.wrap(this.promptPath);
232 233
	}

234 235
	public confirmSave(resources?: URI[]): TPromise<ConfirmResult> {
		return TPromise.wrap(this.confirmResult);
236
	}
D
Daniel Imms 已提交
237

238 239
	public onFilesConfigurationChange(configuration: any): void {
		super.onFilesConfigurationChange(configuration);
240 241 242 243 244 245
	}

	protected cleanupBackupsBeforeShutdown(): TPromise<void> {
		this.cleanupBackupsBeforeShutdownCalled = true;
		return TPromise.as(void 0);
	}
A
Alex Dima 已提交
246 247
}

248
export function workbenchInstantiationService(): IInstantiationService {
249
	let instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
I
isidor 已提交
250
	instantiationService.stub(IContextKeyService, <IContextKeyService>instantiationService.createInstance(MockContextKeyService));
251
	instantiationService.stub(IWorkspaceContextService, new TestContextService(TestWorkspace));
252 253 254
	const configService = new TestConfigurationService();
	instantiationService.stub(IConfigurationService, configService);
	instantiationService.stub(ITextResourceConfigurationService, new TestTextResourceConfigurationService(configService));
255 256 257
	instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
	instantiationService.stub(IStorageService, new TestStorageService());
	instantiationService.stub(IPartService, new TestPartService());
258
	instantiationService.stub(IModeService, ModeServiceImpl);
B
Benjamin Pasero 已提交
259
	instantiationService.stub(IHistoryService, new TestHistoryService());
S
Sandeep Somavarapu 已提交
260
	instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl));
261
	instantiationService.stub(IFileService, new TestFileService());
262
	instantiationService.stub(IBackupFileService, new TestBackupFileService());
263
	instantiationService.stub(ITelemetryService, NullTelemetryService);
264
	instantiationService.stub(INotificationService, new TestNotificationService());
B
Benjamin Pasero 已提交
265
	instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
266
	instantiationService.stub(IWindowService, new TestWindowService());
B
Benjamin Pasero 已提交
267 268 269 270
	instantiationService.stub(IMenuService, new TestMenuService());
	instantiationService.stub(IKeybindingService, new MockKeybindingService());
	instantiationService.stub(IDecorationsService, new TestDecorationsService());
	instantiationService.stub(IExtensionService, new TestExtensionService());
271
	instantiationService.stub(IWindowsService, new TestWindowsService());
272
	instantiationService.stub(ITextFileService, <ITextFileService>instantiationService.createInstance(TestTextFileService));
273
	instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
B
Benjamin Pasero 已提交
274
	instantiationService.stub(IEnvironmentService, TestEnvironmentService);
B
Benjamin Pasero 已提交
275
	instantiationService.stub(IThemeService, new TestThemeService());
R
Ramya Achutha Rao 已提交
276
	instantiationService.stub(IHashService, new TestHashService());
277
	instantiationService.stub(IEditorGroupsService, new TestEditorGroupsService([new TestEditorGroup(0)]));
B
Benjamin Pasero 已提交
278
	const editorService = new TestEditorService();
279
	instantiationService.stub(IEditorService, editorService);
B
Benjamin Pasero 已提交
280
	instantiationService.stub(ICodeEditorService, new TestCodeEditorService());
281 282 283 284

	return instantiationService;
}

B
Benjamin Pasero 已提交
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
export class TestDecorationsService implements IDecorationsService {
	_serviceBrand: any;
	onDidChangeDecorations: Event<IResourceDecorationChangeEvent> = Event.None;
	registerDecorationsProvider(provider: IDecorationsProvider): IDisposable { return toDisposable(); }
	getDecoration(uri: URI, includeChildren: boolean, overwrite?: IDecorationData): IDecoration { return void 0; }
}

export class TestExtensionService implements IExtensionService {
	_serviceBrand: any;
	onDidRegisterExtensions: Event<void> = Event.None;
	onDidChangeExtensionsStatus: Event<string[]> = Event.None;
	activateByEvent(activationEvent: string): Promise<void> { return TPromise.as(void 0); }
	whenInstalledExtensionsRegistered(): Promise<boolean> { return TPromise.as(true); }
	getExtensions(): Promise<IExtensionDescription[]> { return TPromise.as([]); }
	readExtensionPointContributions<T>(extPoint: IExtensionPoint<T>): Promise<ExtensionPointContribution<T>[]> { return TPromise.as(Object.create(null)); }
	getExtensionsStatus(): { [id: string]: IExtensionsStatus; } { return Object.create(null); }
	canProfileExtensionHost(): boolean { return false; }
	startExtensionHostProfile(): Promise<ProfileSession> { return TPromise.as(Object.create(null)); }
	restartExtensionHost(): void { }
	startExtensionHost(): void { }
	stopExtensionHost(): void { }
}

export class TestMenuService implements IMenuService {

	public _serviceBrand: any;

	createMenu(id: MenuId, scopedKeybindingService: IContextKeyService): IMenu {
		return {
			onDidChange: Event.None,
			dispose: () => void 0,
			getActions: () => []
		};
	}
}

B
Benjamin Pasero 已提交
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
export class TestHistoryService implements IHistoryService {

	public _serviceBrand: any;

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

	public forward(acrossEditors?: boolean): void {
	}

	public back(acrossEditors?: boolean): void {
	}

337 338 339
	public last(): void {
	}

B
Benjamin Pasero 已提交
340 341 342 343 344 345 346 347 348 349
	public remove(input: IEditorInput | IResourceInput): void {
	}

	public clear(): void {
	}

	public getHistory(): (IEditorInput | IResourceInput)[] {
		return [];
	}

350
	public getLastActiveWorkspaceRoot(schemeFilter?: string): URI {
B
Benjamin Pasero 已提交
351 352
		return this.root;
	}
353 354 355 356

	public getLastActiveFile(): URI {
		return void 0;
	}
B
Benjamin Pasero 已提交
357 358
}

359
export class TestDialogService implements IDialogService {
360 361

	public _serviceBrand: any;
E
Erich Gamma 已提交
362

363
	public confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
364 365
		return TPromise.as({ confirmed: false });
	}
366

367
	public show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions): Promise<number, any> {
368 369
		return TPromise.as(0);
	}
E
Erich Gamma 已提交
370 371
}

372
export class TestPartService implements IPartService {
B
Benjamin Pasero 已提交
373

374
	public _serviceBrand: any;
E
Erich Gamma 已提交
375

376
	private _onTitleBarVisibilityChange = new Emitter<void>();
377
	private _onEditorLayout = new Emitter<IDimension>();
378 379 380 381 382

	public get onTitleBarVisibilityChange(): Event<void> {
		return this._onTitleBarVisibilityChange.event;
	}

383
	public get onEditorLayout(): Event<IDimension> {
384 385 386
		return this._onEditorLayout.event;
	}

E
Erich Gamma 已提交
387 388 389 390 391 392
	public layout(): void { }

	public isCreated(): boolean {
		return true;
	}

M
Matt Bierner 已提交
393
	public hasFocus(part: Parts): boolean {
E
Erich Gamma 已提交
394 395 396
		return false;
	}

M
Matt Bierner 已提交
397
	public isVisible(part: Parts): boolean {
E
Erich Gamma 已提交
398 399 400
		return true;
	}

M
Matt Bierner 已提交
401
	public getContainer(part: Parts): HTMLElement {
402 403 404
		return null;
	}

B
Benjamin Pasero 已提交
405 406 407 408
	public isTitleBarHidden(): boolean {
		return false;
	}

409 410 411 412
	public getTitleBarOffset(): number {
		return 0;
	}

413 414 415 416
	public isStatusBarHidden(): boolean {
		return false;
	}

S
Sanders Lauture 已提交
417 418 419 420 421 422
	public isActivityBarHidden(): boolean {
		return false;
	}

	public setActivityBarHidden(hidden: boolean): void { }

E
Erich Gamma 已提交
423 424 425 426
	public isSideBarHidden(): boolean {
		return false;
	}

427
	public setSideBarHidden(hidden: boolean): TPromise<void> { return TPromise.as(null); }
E
Erich Gamma 已提交
428

I
isidor 已提交
429
	public isPanelHidden(): boolean {
I
isidor 已提交
430 431 432
		return false;
	}

433
	public setPanelHidden(hidden: boolean): TPromise<void> { return TPromise.as(null); }
I
isidor 已提交
434

I
isidor 已提交
435 436
	public toggleMaximizedPanel(): void { }

B
Benjamin Pasero 已提交
437 438 439 440
	public isPanelMaximized(): boolean {
		return false;
	}

E
Erich Gamma 已提交
441 442 443 444
	public getSideBarPosition() {
		return 0;
	}

I
isidor 已提交
445 446 447 448
	public getPanelPosition() {
		return 0;
	}

I
isidor 已提交
449 450 451 452
	public setPanelPosition(position: PartPosition): TPromise<void> {
		return TPromise.as(null);
	}

E
Erich Gamma 已提交
453 454
	public addClass(clazz: string): void { }
	public removeClass(clazz: string): void { }
455
	public getWorkbenchElementId(): string { return ''; }
B
Benjamin Pasero 已提交
456

I
isidor 已提交
457
	public toggleZenMode(): void { }
458

B
Benjamin Pasero 已提交
459
	public isEditorLayoutCentered(): boolean { return false; }
460
	public centerEditorLayout(active: boolean): void { }
S
SrTobi 已提交
461 462


463
	public resizePart(part: Parts, sizeChange: number): void { }
E
Erich Gamma 已提交
464 465
}

466
export class TestStorageService implements IStorageService {
467
	public _serviceBrand: any;
E
Erich Gamma 已提交
468

B
Benjamin Pasero 已提交
469
	private storage: StorageService;
E
Erich Gamma 已提交
470 471 472

	constructor() {
		let context = new TestContextService();
473
		this.storage = new StorageService(new InMemoryLocalStorage(), null, context.getWorkspace().id);
E
Erich Gamma 已提交
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
	}

	store(key: string, value: any, scope: StorageScope = StorageScope.GLOBAL): void {
		this.storage.store(key, value, scope);
	}

	remove(key: string, scope: StorageScope = StorageScope.GLOBAL): void {
		this.storage.remove(key, scope);
	}

	get(key: string, scope: StorageScope = StorageScope.GLOBAL, defaultValue?: string): string {
		return this.storage.get(key, scope, defaultValue);
	}

	getInteger(key: string, scope: StorageScope = StorageScope.GLOBAL, defaultValue?: number): number {
		return this.storage.getInteger(key, scope, defaultValue);
	}

	getBoolean(key: string, scope: StorageScope = StorageScope.GLOBAL, defaultValue?: boolean): boolean {
		return this.storage.getBoolean(key, scope, defaultValue);
	}
}

497
export class TestEditorGroupsService implements IEditorGroupsService {
498 499
	_serviceBrand: ServiceIdentifier<any>;

B
Benjamin Pasero 已提交
500
	constructor(public groups: TestEditorGroup[] = []) { }
501

502 503 504 505
	onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
	onDidAddGroup: Event<IEditorGroup> = Event.None;
	onDidRemoveGroup: Event<IEditorGroup> = Event.None;
	onDidMoveGroup: Event<IEditorGroup> = Event.None;
506 507

	orientation: any;
508
	whenRestored: TPromise<void> = TPromise.as(void 0);
509

510
	get activeGroup(): IEditorGroup {
511 512 513 514 515 516 517
		return this.groups[0];
	}

	get count(): number {
		return this.groups.length;
	}

518
	getGroups(order?: GroupsOrder): ReadonlyArray<IEditorGroup> {
519 520 521
		return this.groups;
	}

522
	getGroup(identifier: number): IEditorGroup {
523 524 525 526 527 528 529 530 531
		for (let i = 0; i < this.groups.length; i++) {
			if (this.groups[i].id === identifier) {
				return this.groups[i];
			}
		}

		return void 0;
	}

532 533 534 535
	getLabel(identifier: number): string {
		return 'Group 1';
	}

536
	findGroup(scope: IFindGroupScope, source?: number | IEditorGroup): IEditorGroup {
537 538 539
		return null;
	}

540
	activateGroup(group: number | IEditorGroup): IEditorGroup {
541 542 543
		return null;
	}

544 545
	getSize(group: number | IEditorGroup): number {
		return 100;
546 547
	}

548 549
	setSize(group: number | IEditorGroup, size: number): void { }

550 551 552 553
	arrangeGroups(arrangement: GroupsArrangement): void { }

	setGroupOrientation(orientation: any): void { }

554
	addGroup(location: number | IEditorGroup, direction: GroupDirection, options?: IAddGroupOptions): IEditorGroup {
555 556 557
		return null;
	}

558
	removeGroup(group: number | IEditorGroup): void { }
559

560
	moveGroup(group: number | IEditorGroup, location: number | IEditorGroup, direction: GroupDirection): IEditorGroup {
561 562 563
		return null;
	}

564
	mergeGroup(group: number | IEditorGroup, target: number | IEditorGroup, options?: IMergeGroupOptions): IEditorGroup {
565 566 567
		return null;
	}

568
	copyGroup(group: number | IEditorGroup, location: number | IEditorGroup, direction: GroupDirection): IEditorGroup {
569 570 571 572
		return null;
	}
}

B
Benjamin Pasero 已提交
573
export class TestEditorGroup implements IEditorGroupView {
574 575 576

	constructor(public id: number) { }

B
Benjamin Pasero 已提交
577
	group: EditorGroup = void 0;
578 579 580 581
	activeControl: IEditor;
	activeEditor: IEditorInput;
	previewEditor: IEditorInput;
	count: number;
B
Benjamin Pasero 已提交
582
	disposed: boolean;
B
Benjamin Pasero 已提交
583
	editors: ReadonlyArray<IEditorInput> = [];
584
	label: string;
B
Benjamin Pasero 已提交
585 586 587 588 589 590
	whenRestored: Promise<void, any> = TPromise.as(void 0);
	element: HTMLElement;
	minimumWidth: number;
	maximumWidth: number;
	minimumHeight: number;
	maximumHeight: number;
591 592

	onWillDispose: Event<void> = Event.None;
593
	onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
B
Benjamin Pasero 已提交
594 595
	onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
596 597
	onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
	onDidOpenEditorFail: Event<IEditorInput> = Event.None;
B
Benjamin Pasero 已提交
598 599
	onDidFocus: Event<void> = Event.None;
	onDidChange: Event<{ width: number; height: number; }> = Event.None;
600

B
Benjamin Pasero 已提交
601 602 603 604
	getEditors(order?: EditorsOrder): ReadonlyArray<IEditorInput> {
		return [];
	}

605 606 607 608 609 610 611 612
	getEditor(index: number): IEditorInput {
		return null;
	}

	getIndexOfEditor(editor: IEditorInput): number {
		return -1;
	}

613
	openEditor(editor: IEditorInput, options?: IEditorOptions): TPromise<void> {
614 615 616
		return TPromise.as(void 0);
	}

617
	openEditors(editors: IEditorInputWithOptions[]): TPromise<void> {
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
		return TPromise.as(void 0);
	}

	isOpened(editor: IEditorInput): boolean {
		return false;
	}

	isPinned(editor: IEditorInput): boolean {
		return false;
	}

	isActive(editor: IEditorInput): boolean {
		return false;
	}

633
	moveEditor(editor: IEditorInput, target: IEditorGroup, options?: IMoveEditorOptions): void { }
634

635
	copyEditor(editor: IEditorInput, target: IEditorGroup, options?: ICopyEditorOptions): void { }
636

637
	closeEditor(editor?: IEditorInput): TPromise<void> {
638 639 640
		return TPromise.as(void 0);
	}

641
	closeEditors(editors: IEditorInput[] | { except?: IEditorInput; direction?: CloseDirection; savedOnly?: boolean; }): TPromise<void> {
642 643 644
		return TPromise.as(void 0);
	}

645
	closeAllEditors(): TPromise<void> {
646 647 648
		return TPromise.as(void 0);
	}

649
	replaceEditors(editors: IEditorReplacement[]): TPromise<void> {
650 651 652 653 654 655 656 657 658 659
		return TPromise.as(void 0);
	}

	pinEditor(editor?: IEditorInput): void { }

	focus(): void { }

	invokeWithinContext<T>(fn: (accessor: ServicesAccessor) => T): T {
		return fn(null);
	}
B
Benjamin Pasero 已提交
660 661 662 663 664 665 666 667

	isEmpty(): boolean { return true; }
	setActive(isActive: boolean): void { }
	setLabel(label: string): void { }
	shutdown(): void { }
	dispose(): void { }
	toJSON(): object { return Object.create(null); }
	layout(width: number, height: number): void { }
668 669
}

B
Benjamin Pasero 已提交
670
export class TestEditorService implements IEditorPartService {
671 672 673 674 675

	_serviceBrand: ServiceIdentifier<any>;

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
676
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
677 678 679
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

	activeControl: IEditor;
680
	activeTextEditorWidget: any;
681
	activeEditor: IEditorInput;
682
	editors: ReadonlyArray<IEditorInput> = [];
B
Benjamin Pasero 已提交
683
	visibleControls: ReadonlyArray<IEditor> = [];
684
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
685
	visibleEditors: ReadonlyArray<IEditorInput> = [];
686

687 688 689 690
	overrideOpenEditor(handler: IOpenEditorOverrideHandler): IDisposable {
		return toDisposable(() => void 0);
	}

691 692 693 694 695 696 697 698 699 700 701 702
	openEditor(editor: any, options?: any, group?: any) {
		return TPromise.as(null);
	}

	openEditors(editors: any, group?: any) {
		return TPromise.as(null);
	}

	isOpen(editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
		return false;
	}

703 704 705 706
	replaceEditors(editors: any, group: any) {
		return TPromise.as(void 0);
	}

707 708 709 710 711 712 713 714 715
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
		return fn(null);
	}

	createInput(input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
		return null;
	}
}

716 717 718 719
export class TestFileService implements IFileService {

	public _serviceBrand: any;

720 721
	public encoding: IResourceEncodings;

M
Matt Bierner 已提交
722 723
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
724

725 726
	private content = 'Hello Html';

727 728 729 730 731
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

732 733 734 735 736 737 738 739
	public setContent(content: string): void {
		this.content = content;
	}

	public getContent(): string {
		return this.content;
	}

740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756
	public get onFileChanges(): Event<FileChangesEvent> {
		return this._onFileChanges.event;
	}

	public fireFileChanges(event: FileChangesEvent): void {
		this._onFileChanges.fire(event);
	}

	public get onAfterOperation(): Event<FileOperationEvent> {
		return this._onAfterOperation.event;
	}

	public fireAfterOperation(event: FileOperationEvent): void {
		this._onAfterOperation.fire(event);
	}

	resolveFile(resource: URI, options?: IResolveFileOptions): TPromise<IFileStat> {
A
Alex Dima 已提交
757
		return TPromise.as({
758 759
			resource,
			etag: Date.now().toString(),
B
Benjamin Pasero 已提交
760
			encoding: 'utf8',
B
Benjamin Pasero 已提交
761
			mtime: Date.now(),
762
			isDirectory: false,
B
Benjamin Pasero 已提交
763 764
			name: paths.basename(resource.fsPath)
		});
765
	}
B
Benjamin Pasero 已提交
766

I
isidor 已提交
767 768
	resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): TPromise<IResolveFileResult[]> {
		return TPromise.join(toResolve.map(resourceAndOption => this.resolveFile(resourceAndOption.resource, resourceAndOption.options))).then(stats => stats.map(stat => ({ stat, success: true })));
I
isidor 已提交
769 770
	}

771 772 773
	existsFile(resource: URI): TPromise<boolean> {
		return TPromise.as(null);
	}
B
Benjamin Pasero 已提交
774

775
	resolveContent(resource: URI, options?: IResolveContentOptions): TPromise<IContent> {
B
Benjamin Pasero 已提交
776 777
		return TPromise.as({
			resource: resource,
778
			value: this.content,
779
			etag: 'index.txt',
B
Benjamin Pasero 已提交
780 781
			encoding: 'utf8',
			mtime: Date.now(),
782
			name: paths.basename(resource.fsPath)
E
Erich Gamma 已提交
783
		});
784
	}
E
Erich Gamma 已提交
785

786
	resolveStreamContent(resource: URI, options?: IResolveContentOptions): TPromise<IStreamContent> {
A
Alex Dima 已提交
787 788 789
		return TPromise.as({
			resource: resource,
			value: {
790
				on: (event: string, callback: Function): void => {
A
Alex Dima 已提交
791
					if (event === 'data') {
792
						callback(this.content);
A
Alex Dima 已提交
793 794 795 796 797 798 799 800
					}
					if (event === 'end') {
						callback();
					}
				}
			},
			etag: 'index.txt',
			encoding: 'utf8',
B
Benjamin Pasero 已提交
801
			mtime: Date.now(),
802
			name: paths.basename(resource.fsPath)
A
Alex Dima 已提交
803
		});
804 805
	}

806
	updateContent(resource: URI, value: string | ITextSnapshot, options?: IUpdateContentOptions): TPromise<IFileStat> {
807
		return TPromise.timeout(1).then(() => {
E
Erich Gamma 已提交
808
			return {
809
				resource,
E
Erich Gamma 已提交
810
				etag: 'index.txt',
B
Benjamin Pasero 已提交
811
				encoding: 'utf8',
B
Benjamin Pasero 已提交
812
				mtime: Date.now(),
813 814
				isDirectory: false,
				name: paths.basename(resource.fsPath)
E
Erich Gamma 已提交
815 816
			};
		});
817
	}
D
Daniel Imms 已提交
818

819 820 821
	moveFile(source: URI, target: URI, overwrite?: boolean): TPromise<IFileStat> {
		return TPromise.as(null);
	}
D
Daniel Imms 已提交
822

823 824 825
	copyFile(source: URI, target: URI, overwrite?: boolean): TPromise<IFileStat> {
		return TPromise.as(null);
	}
D
Daniel Imms 已提交
826

827
	createFile(resource: URI, content?: string, options?: ICreateFileOptions): TPromise<IFileStat> {
828
		return TPromise.as(null);
E
Erich Gamma 已提交
829
	}
830 831 832 833 834 835 836 837

	createFolder(resource: URI): TPromise<IFileStat> {
		return TPromise.as(null);
	}

	rename(resource: URI, newName: string): TPromise<IFileStat> {
		return TPromise.as(null);
	}
D
Daniel Imms 已提交
838

839 840 841 842 843 844
	onDidChangeFileSystemProviderRegistrations = Event.None;

	registerProvider(scheme: string, provider) {
		return { dispose() { } };
	}

845 846 847 848
	canHandleResource(resource: URI): boolean {
		return resource.scheme === 'file';
	}

849 850 851 852 853 854 855
	del(resource: URI, useTrash?: boolean): TPromise<void> {
		return TPromise.as(null);
	}

	watchFileChanges(resource: URI): void {
	}

J
Johannes Rieken 已提交
856
	unwatchFileChanges(resource: URI): void {
857 858
	}

859
	getWriteEncoding(resource: URI): string {
860 861
		return 'utf8';
	}
D
Daniel Imms 已提交
862

863
	dispose(): void {
E
Erich Gamma 已提交
864
	}
865
}
866

867 868
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
869

870 871
	public backupEnabled: boolean;

872 873 874 875
	public hasBackups(): TPromise<boolean> {
		return TPromise.as(false);
	}

876
	public hasBackup(resource: URI): TPromise<boolean> {
877 878 879
		return TPromise.as(false);
	}

B
Benjamin Pasero 已提交
880 881 882
	public loadBackupResource(resource: URI): TPromise<URI> {
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
883
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
884 885 886 887 888 889
			}

			return void 0;
		});
	}

D
Daniel Imms 已提交
890 891 892 893 894 895 896 897
	public registerResourceForBackup(resource: URI): TPromise<void> {
		return TPromise.as(void 0);
	}

	public deregisterResourceForBackup(resource: URI): TPromise<void> {
		return TPromise.as(void 0);
	}

898
	public toBackupResource(resource: URI): URI {
D
Daniel Imms 已提交
899 900
		return null;
	}
901

902
	public backupResource(resource: URI, content: ITextSnapshot): TPromise<void> {
903 904 905
		return TPromise.as(void 0);
	}

906
	public getWorkspaceFileBackups(): TPromise<URI[]> {
907 908 909
		return TPromise.as([]);
	}

910 911 912 913 914
	public parseBackupContent(textBufferFactory: ITextBufferFactory): string {
		const textBuffer = textBufferFactory.create(DefaultEndOfLine.LF);
		const lineCount = textBuffer.getLineCount();
		const range = new Range(1, 1, lineCount, textBuffer.getLineLength(lineCount) + 1);
		return textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);
915 916
	}

917 918 919 920
	public resolveBackupContent(backup: URI): TPromise<ITextBufferFactory> {
		return TPromise.as(null);
	}

921
	public discardResourceBackup(resource: URI): TPromise<void> {
922 923 924
		return TPromise.as(void 0);
	}

925
	public discardAllWorkspaceBackups(): TPromise<void> {
926 927
		return TPromise.as(void 0);
	}
928
}
D
Daniel Imms 已提交
929

B
Benjamin Pasero 已提交
930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949
export class TestCodeEditorService implements ICodeEditorService {
	_serviceBrand: any;

	onCodeEditorAdd: Event<ICodeEditor> = Event.None;
	onCodeEditorRemove: Event<ICodeEditor> = Event.None;
	onDiffEditorAdd: Event<IDiffEditor> = Event.None;
	onDiffEditorRemove: Event<IDiffEditor> = Event.None;

	addCodeEditor(editor: ICodeEditor): void { }
	removeCodeEditor(editor: ICodeEditor): void { }
	listCodeEditors(): ICodeEditor[] { return []; }
	addDiffEditor(editor: IDiffEditor): void { }
	removeDiffEditor(editor: IDiffEditor): void { }
	listDiffEditors(): IDiffEditor[] { return []; }
	getFocusedCodeEditor(): ICodeEditor { return null; }
	registerDecorationType(key: string, options: IDecorationRenderOptions, parentTypeKey?: string): void { }
	removeDecorationType(key: string): void { }
	resolveDecorationOptions(typeKey: string, writable: boolean): IModelDecorationOptions { return Object.create(null); }
	setTransientModelProperty(model: ITextModel, key: string, value: any): void { }
	getTransientModelProperty(model: ITextModel, key: string) { }
950
	getActiveCodeEditor(): ICodeEditor { return null; }
951
	openCodeEditor(input: IResourceInput, source: ICodeEditor, sideBySide?: boolean): TPromise<ICodeEditor> { return TPromise.as(null); }
B
Benjamin Pasero 已提交
952 953
}

954 955 956 957
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

958
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
959

960 961 962 963
	isFocused(): TPromise<boolean> {
		return TPromise.as(false);
	}

964 965 966 967
	getConfiguration(): IWindowConfiguration {
		return Object.create(null);
	}

968 969 970 971
	getCurrentWindowId(): number {
		return 0;
	}

B
Benjamin Pasero 已提交
972
	pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
973 974 975
		return TPromise.as(void 0);
	}

B
Benjamin Pasero 已提交
976
	pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
977 978 979
		return TPromise.as(void 0);
	}

B
Benjamin Pasero 已提交
980
	pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
981 982 983
		return TPromise.as(void 0);
	}

984 985 986 987
	pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
		return TPromise.as(void 0);
	}

988 989 990 991 992 993 994 995 996 997 998 999
	reloadWindow(): TPromise<void> {
		return TPromise.as(void 0);
	}

	openDevTools(): TPromise<void> {
		return TPromise.as(void 0);
	}

	toggleDevTools(): TPromise<void> {
		return TPromise.as(void 0);
	}

1000
	closeWorkspace(): TPromise<void> {
1001 1002 1003
		return TPromise.as(void 0);
	}

1004
	createAndEnterWorkspace(folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult> {
1005 1006 1007
		return TPromise.as(void 0);
	}

1008
	saveAndEnterWorkspace(path: string): TPromise<IEnterWorkspaceResult> {
1009 1010 1011
		return TPromise.as(void 0);
	}

1012 1013 1014 1015 1016 1017 1018 1019
	toggleFullScreen(): TPromise<void> {
		return TPromise.as(void 0);
	}

	setRepresentedFilename(fileName: string): TPromise<void> {
		return TPromise.as(void 0);
	}

1020
	getRecentlyOpened(): TPromise<IRecentlyOpened> {
1021 1022 1023 1024 1025 1026 1027
		return TPromise.as(void 0);
	}

	focusWindow(): TPromise<void> {
		return TPromise.as(void 0);
	}

1028 1029 1030 1031
	closeWindow(): TPromise<void> {
		return TPromise.as(void 0);
	}

1032 1033 1034 1035
	setDocumentEdited(flag: boolean): TPromise<void> {
		return TPromise.as(void 0);
	}

1036 1037 1038
	onWindowTitleDoubleClick(): TPromise<void> {
		return TPromise.as(void 0);
	}
1039

J
Joao 已提交
1040 1041 1042 1043
	show(): TPromise<void> {
		return TPromise.as(void 0);
	}

1044 1045
	showMessageBox(options: Electron.MessageBoxOptions): TPromise<IMessageBoxResult> {
		return TPromise.wrap({ button: 0 });
1046 1047
	}

1048 1049
	showSaveDialog(options: Electron.SaveDialogOptions): TPromise<string> {
		return TPromise.wrap(void 0);
1050
	}
1051

1052 1053
	showOpenDialog(options: Electron.OpenDialogOptions): TPromise<string[]> {
		return TPromise.wrap(void 0);
1054
	}
1055 1056 1057 1058

	updateTouchBar(items: ICommandAction[][]): Promise<void> {
		return TPromise.as(void 0);
	}
1059 1060
}

1061 1062
export class TestLifecycleService implements ILifecycleService {

1063
	public _serviceBrand: any;
1064

1065
	public phase: LifecyclePhase;
1066
	public startupKind: StartupKind;
1067

1068
	private _onWillShutdown = new Emitter<ShutdownEvent>();
1069
	private _onShutdown = new Emitter<ShutdownReason>();
1070

1071
	when(): TPromise<void> {
1072
		return TPromise.as(void 0);
B
Benjamin Pasero 已提交
1073
	}
1074

1075 1076
	public fireShutdown(reason = ShutdownReason.QUIT): void {
		this._onShutdown.fire(reason);
1077 1078
	}

1079 1080 1081 1082
	public fireWillShutdown(event: ShutdownEvent): void {
		this._onWillShutdown.fire(event);
	}

1083 1084 1085 1086
	public get onWillShutdown(): Event<ShutdownEvent> {
		return this._onWillShutdown.event;
	}

1087
	public get onShutdown(): Event<ShutdownReason> {
1088 1089
		return this._onShutdown.event;
	}
1090 1091
}

1092 1093 1094 1095
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1096 1097
	public windowCount = 1;

1098 1099
	onWindowOpen: Event<number>;
	onWindowFocus: Event<number>;
1100
	onWindowBlur: Event<number>;
1101

1102 1103 1104 1105
	isFocused(windowId: number): TPromise<boolean> {
		return TPromise.as(false);
	}

B
Benjamin Pasero 已提交
1106
	pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
1107 1108
		return TPromise.as(void 0);
	}
1109

B
Benjamin Pasero 已提交
1110
	pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
1111 1112
		return TPromise.as(void 0);
	}
1113

B
Benjamin Pasero 已提交
1114
	pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
1115 1116
		return TPromise.as(void 0);
	}
1117

1118 1119 1120 1121
	pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
		return TPromise.as(void 0);
	}

1122 1123 1124
	reloadWindow(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1125

1126 1127 1128
	openDevTools(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1129

1130 1131 1132
	toggleDevTools(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1133

1134
	closeWorkspace(windowId: number): TPromise<void> {
1135 1136
		return TPromise.as(void 0);
	}
1137

1138
	createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult> {
1139 1140 1141
		return TPromise.as(void 0);
	}

1142
	saveAndEnterWorkspace(windowId: number, path: string): TPromise<IEnterWorkspaceResult> {
1143 1144 1145
		return TPromise.as(void 0);
	}

1146 1147 1148
	toggleFullScreen(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1149

1150 1151 1152
	setRepresentedFilename(windowId: number, fileName: string): TPromise<void> {
		return TPromise.as(void 0);
	}
1153

1154
	addRecentlyOpened(files: string[]): TPromise<void> {
1155 1156
		return TPromise.as(void 0);
	}
1157

1158
	removeFromRecentlyOpened(paths: string[]): TPromise<void> {
1159 1160
		return TPromise.as(void 0);
	}
1161

B
Benjamin Pasero 已提交
1162
	clearRecentlyOpened(): TPromise<void> {
C
22768  
Cristian 已提交
1163 1164
		return TPromise.as(void 0);
	}
1165

1166
	getRecentlyOpened(windowId: number): TPromise<IRecentlyOpened> {
1167 1168
		return TPromise.as(void 0);
	}
1169

1170 1171 1172
	focusWindow(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1173

1174 1175 1176 1177
	closeWindow(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}

1178 1179 1180
	isMaximized(windowId: number): TPromise<boolean> {
		return TPromise.as(void 0);
	}
1181

1182 1183 1184
	maximizeWindow(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1185

1186 1187 1188
	unmaximizeWindow(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1189

1190 1191 1192
	onWindowTitleDoubleClick(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1193

1194 1195 1196
	setDocumentEdited(windowId: number, flag: boolean): TPromise<void> {
		return TPromise.as(void 0);
	}
1197

1198 1199 1200
	quit(): TPromise<void> {
		return TPromise.as(void 0);
	}
1201

J
Johannes Rieken 已提交
1202 1203 1204
	relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise<void> {
		return TPromise.as(void 0);
	}
1205

1206 1207 1208
	whenSharedProcessReady(): TPromise<void> {
		return TPromise.as(void 0);
	}
1209

1210 1211 1212
	toggleSharedProcess(): TPromise<void> {
		return TPromise.as(void 0);
	}
1213

1214
	// Global methods
1215
	openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
1216 1217
		return TPromise.as(void 0);
	}
1218

1219 1220 1221
	openNewWindow(): TPromise<void> {
		return TPromise.as(void 0);
	}
1222

1223 1224 1225
	showWindow(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1226

1227
	getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderPath?: string; title: string; filename?: string; }[]> {
1228 1229
		return TPromise.as(void 0);
	}
1230

1231
	getWindowCount(): TPromise<number> {
1232
		return TPromise.as(this.windowCount);
1233
	}
1234

1235 1236 1237
	log(severity: string, ...messages: string[]): TPromise<void> {
		return TPromise.as(void 0);
	}
1238

1239 1240 1241 1242
	showItemInFolder(path: string): TPromise<void> {
		return TPromise.as(void 0);
	}

1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
	showPreviousWindowTab(): Promise<void> {
		return TPromise.as(void 0);
	}

	showNextWindowTab(): Promise<void> {
		return TPromise.as(void 0);
	}

	moveWindowTabToNewWindow(): Promise<void> {
		return TPromise.as(void 0);
	}

	mergeAllWindowTabs(): Promise<void> {
		return TPromise.as(void 0);
	}

	toggleWindowTabsBar(): Promise<void> {
		return TPromise.as(void 0);
1261 1262 1263 1264
	}

	updateTouchBar(windowId: number, items: ICommandAction[][]): Promise<void> {
		return TPromise.as(void 0);
1265 1266
	}

1267 1268
	// This needs to be handled from browser process to prevent
	// foreground ordering issues on Windows
1269 1270
	openExternal(url: string): TPromise<boolean> {
		return TPromise.as(true);
1271 1272 1273 1274 1275 1276
	}

	// TODO: this is a bit backwards
	startCrashReporter(config: Electron.CrashReporterStartOptions): TPromise<void> {
		return TPromise.as(void 0);
	}
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288

	showMessageBox(windowId: number, options: Electron.MessageBoxOptions): TPromise<IMessageBoxResult> {
		return TPromise.as(void 0);
	}

	showSaveDialog(windowId: number, options: Electron.SaveDialogOptions): TPromise<string> {
		return TPromise.as(void 0);
	}

	showOpenDialog(windowId: number, options: Electron.OpenDialogOptions): TPromise<string[]> {
		return TPromise.as(void 0);
	}
J
Joao Moreno 已提交
1289 1290 1291 1292

	openAboutDialog(): TPromise<void> {
		return TPromise.as(void 0);
	}
1293
}
B
Benjamin Pasero 已提交
1294

1295 1296 1297 1298 1299 1300 1301
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

	constructor(private configurationService = new TestConfigurationService()) {
	}

1302
	public onDidChangeConfiguration() {
1303 1304 1305
		return { dispose() { } };
	}

1306 1307 1308 1309
	getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
		const position: IPosition = EditorPosition.isIPosition(arg2) ? arg2 : null;
		const section: string = position ? (typeof arg3 === 'string' ? arg3 : void 0) : (typeof arg2 === 'string' ? arg2 : void 0);
		return this.configurationService.getValue(section, { resource });
1310
	}
B
Benjamin Pasero 已提交
1311 1312
}

R
Ramya Achutha Rao 已提交
1313 1314 1315 1316 1317 1318 1319 1320
export class TestHashService implements IHashService {
	_serviceBrand: any;

	createSHA1(content: string): string {
		return content;
	}
}

B
Benjamin Pasero 已提交
1321 1322
export function getRandomTestPath(tmpdir: string, ...segments: string[]): string {
	return paths.join(tmpdir, ...segments, generateUuid());
1323
}