workbenchTestServices.ts 40.7 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
import { ConfirmResult, IEditorOpeningEvent, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent } from 'vs/workbench/common/editor';
M
Matt Bierner 已提交
18
import { Event, Emitter } from 'vs/base/common/event';
E
Erich Gamma 已提交
19
import Severity from 'vs/base/common/severity';
20
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
21
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
J
Johannes Rieken 已提交
22
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
23
import { IPartService, Parts, Position as PartPosition, IDimension } from 'vs/workbench/services/part/common/partService';
24
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
25
import { ITextModelService } from 'vs/editor/common/services/resolverService';
B
Benjamin Pasero 已提交
26
import { IEditorOptions, IResourceInput } from 'vs/platform/editor/common/editor';
J
Johannes Rieken 已提交
27
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
S
Sandeep Somavarapu 已提交
28
import { IWorkspaceContextService, IWorkspace as IWorkbenchWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent } from 'vs/platform/workspace/common/workspace';
29
import { ILifecycleService, ShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
J
Johannes Rieken 已提交
30
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
31
import { TextFileService } from 'vs/workbench/services/textfile/common/textFileService';
32
import { FileOperationEvent, IFileService, IResolveContentOptions, FileOperationError, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, IContent, IUpdateContentOptions, IStreamContent, ICreateFileOptions, ITextSnapshot, IResourceEncodings } from 'vs/platform/files/common/files';
33
import { IModelService } from 'vs/editor/common/services/modelService';
34
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
J
Johannes Rieken 已提交
35 36 37 38 39
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';
B
Benjamin Pasero 已提交
40
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
J
Johannes Rieken 已提交
41
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
import { INextEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, EditorsOrder, IFindGroupScope } from 'vs/workbench/services/group/common/nextEditorGroupsService';
71
import { INextEditorService, IOpenEditorOverrideHandler } from 'vs/workbench/services/editor/common/nextEditorService';
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	public updateOptions() {

	}

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

		return false;
	}

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

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

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

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

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

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

	constructor(
181 182
		@ILifecycleService lifecycleService: ILifecycleService,
		@IWorkspaceContextService contextService: IWorkspaceContextService,
A
Alex Dima 已提交
183
		@IConfigurationService configurationService: IConfigurationService,
184
		@IWorkbenchEditorService editorService: IWorkbenchEditorService,
A
Alex Dima 已提交
185
		@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());
B
Benjamin Pasero 已提交
277 278
	instantiationService.stub(INextEditorGroupsService, new TestEditorGroupsService([new TestEditorGroup(0)]));
	const editorService = new TestEditorService();
279
	instantiationService.stub(INextEditorService, 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);
	}
}

B
Benjamin Pasero 已提交
497
export class TestEditorGroupsService implements INextEditorGroupsService {
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
	focusGroup(group: number | IEditorGroup): IEditorGroup {
537 538 539
		return null;
	}

540
	findGroup(scope: IFindGroupScope, source?: number | IEditorGroup): IEditorGroup {
541 542 543
		return null;
	}

544
	activateGroup(group: number | IEditorGroup): IEditorGroup {
545 546 547
		return null;
	}

548
	resizeGroup(group: number | IEditorGroup, sizeDelta: number): IEditorGroup {
549 550 551 552 553 554 555
		return null;
	}

	arrangeGroups(arrangement: GroupsArrangement): void { }

	setGroupOrientation(orientation: any): void { }

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

560
	removeGroup(group: number | IEditorGroup): void { }
561

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

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

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

B
Benjamin Pasero 已提交
575
export class TestEditorGroup implements IEditorGroup {
576 577 578 579 580 581 582

	constructor(public id: number) { }

	activeControl: IEditor;
	activeEditor: IEditorInput;
	previewEditor: IEditorInput;
	count: number;
B
Benjamin Pasero 已提交
583
	editors: ReadonlyArray<IEditorInput> = [];
584
	label: string;
585 586

	onWillDispose: Event<void> = Event.None;
587
	onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
B
Benjamin Pasero 已提交
588 589
	onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
590 591 592
	onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
	onDidOpenEditorFail: Event<IEditorInput> = Event.None;

B
Benjamin Pasero 已提交
593 594 595 596
	getEditors(order?: EditorsOrder): ReadonlyArray<IEditorInput> {
		return [];
	}

597 598 599 600 601 602 603 604
	getEditor(index: number): IEditorInput {
		return null;
	}

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

605
	openEditor(editor: IEditorInput, options?: IEditorOptions): TPromise<void> {
606 607 608
		return TPromise.as(void 0);
	}

609
	openEditors(editors: IEditorInputWithOptions[]): TPromise<void> {
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
		return TPromise.as(void 0);
	}

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

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

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

625
	moveEditor(editor: IEditorInput, target: IEditorGroup, options?: IMoveEditorOptions): void { }
626

627
	copyEditor(editor: IEditorInput, target: IEditorGroup, options?: ICopyEditorOptions): void { }
628

629
	closeEditor(editor?: IEditorInput): TPromise<void> {
630 631 632
		return TPromise.as(void 0);
	}

633
	closeEditors(editors: IEditorInput[] | { except?: IEditorInput; direction?: CloseDirection; savedOnly?: boolean; }): TPromise<void> {
634 635 636
		return TPromise.as(void 0);
	}

637
	closeAllEditors(): TPromise<void> {
638 639 640
		return TPromise.as(void 0);
	}

641
	replaceEditors(editors: IEditorReplacement[]): TPromise<void> {
642 643 644 645 646 647 648 649 650 651 652 653
		return TPromise.as(void 0);
	}

	pinEditor(editor?: IEditorInput): void { }

	focus(): void { }

	invokeWithinContext<T>(fn: (accessor: ServicesAccessor) => T): T {
		return fn(null);
	}
}

B
Benjamin Pasero 已提交
654
export class TestEditorService implements INextEditorService {
655 656 657 658 659

	_serviceBrand: ServiceIdentifier<any>;

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
660
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
661 662 663
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

	activeControl: IEditor;
664
	activeTextEditorWidget: any;
665
	activeEditor: IEditorInput;
666
	editors: ReadonlyArray<IEditorInput> = [];
B
Benjamin Pasero 已提交
667
	visibleControls: ReadonlyArray<IEditor> = [];
668
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
669
	visibleEditors: ReadonlyArray<IEditorInput> = [];
670

671 672 673 674
	overrideOpenEditor(handler: IOpenEditorOverrideHandler): IDisposable {
		return toDisposable(() => void 0);
	}

675 676 677 678 679 680 681 682 683 684 685 686
	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;
	}

687 688 689 690
	replaceEditors(editors: any, group: any) {
		return TPromise.as(void 0);
	}

691 692 693 694 695 696 697 698 699
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
		return fn(null);
	}

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

700 701 702 703
export class TestFileService implements IFileService {

	public _serviceBrand: any;

704 705
	public encoding: IResourceEncodings;

M
Matt Bierner 已提交
706 707
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
708

709 710
	private content = 'Hello Html';

711 712 713 714 715
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

716 717 718 719 720 721 722 723
	public setContent(content: string): void {
		this.content = content;
	}

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

724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
	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 已提交
741
		return TPromise.as({
742 743
			resource,
			etag: Date.now().toString(),
B
Benjamin Pasero 已提交
744
			encoding: 'utf8',
B
Benjamin Pasero 已提交
745
			mtime: Date.now(),
746
			isDirectory: false,
B
Benjamin Pasero 已提交
747 748
			name: paths.basename(resource.fsPath)
		});
749
	}
B
Benjamin Pasero 已提交
750

I
isidor 已提交
751 752
	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 已提交
753 754
	}

755 756 757
	existsFile(resource: URI): TPromise<boolean> {
		return TPromise.as(null);
	}
B
Benjamin Pasero 已提交
758

759
	resolveContent(resource: URI, options?: IResolveContentOptions): TPromise<IContent> {
B
Benjamin Pasero 已提交
760 761
		return TPromise.as({
			resource: resource,
762
			value: this.content,
763
			etag: 'index.txt',
B
Benjamin Pasero 已提交
764 765
			encoding: 'utf8',
			mtime: Date.now(),
766
			name: paths.basename(resource.fsPath)
E
Erich Gamma 已提交
767
		});
768
	}
E
Erich Gamma 已提交
769

770
	resolveStreamContent(resource: URI, options?: IResolveContentOptions): TPromise<IStreamContent> {
A
Alex Dima 已提交
771 772 773
		return TPromise.as({
			resource: resource,
			value: {
774
				on: (event: string, callback: Function): void => {
A
Alex Dima 已提交
775
					if (event === 'data') {
776
						callback(this.content);
A
Alex Dima 已提交
777 778 779 780 781 782 783 784
					}
					if (event === 'end') {
						callback();
					}
				}
			},
			etag: 'index.txt',
			encoding: 'utf8',
B
Benjamin Pasero 已提交
785
			mtime: Date.now(),
786
			name: paths.basename(resource.fsPath)
A
Alex Dima 已提交
787
		});
788 789
	}

790
	updateContent(resource: URI, value: string | ITextSnapshot, options?: IUpdateContentOptions): TPromise<IFileStat> {
791
		return TPromise.timeout(1).then(() => {
E
Erich Gamma 已提交
792
			return {
793
				resource,
E
Erich Gamma 已提交
794
				etag: 'index.txt',
B
Benjamin Pasero 已提交
795
				encoding: 'utf8',
B
Benjamin Pasero 已提交
796
				mtime: Date.now(),
797 798
				isDirectory: false,
				name: paths.basename(resource.fsPath)
E
Erich Gamma 已提交
799 800
			};
		});
801
	}
D
Daniel Imms 已提交
802

803 804 805
	moveFile(source: URI, target: URI, overwrite?: boolean): TPromise<IFileStat> {
		return TPromise.as(null);
	}
D
Daniel Imms 已提交
806

807 808 809
	copyFile(source: URI, target: URI, overwrite?: boolean): TPromise<IFileStat> {
		return TPromise.as(null);
	}
D
Daniel Imms 已提交
810

811
	createFile(resource: URI, content?: string, options?: ICreateFileOptions): TPromise<IFileStat> {
812
		return TPromise.as(null);
E
Erich Gamma 已提交
813
	}
814 815 816 817 818 819 820 821

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

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

823 824 825 826 827 828
	onDidChangeFileSystemProviderRegistrations = Event.None;

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

829 830 831 832
	canHandleResource(resource: URI): boolean {
		return resource.scheme === 'file';
	}

833 834 835 836 837 838 839
	del(resource: URI, useTrash?: boolean): TPromise<void> {
		return TPromise.as(null);
	}

	watchFileChanges(resource: URI): void {
	}

J
Johannes Rieken 已提交
840
	unwatchFileChanges(resource: URI): void {
841 842
	}

843
	getWriteEncoding(resource: URI): string {
844 845
		return 'utf8';
	}
D
Daniel Imms 已提交
846

847
	dispose(): void {
E
Erich Gamma 已提交
848
	}
849
}
850

851 852
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
853

854 855
	public backupEnabled: boolean;

856 857 858 859
	public hasBackups(): TPromise<boolean> {
		return TPromise.as(false);
	}

860
	public hasBackup(resource: URI): TPromise<boolean> {
861 862 863
		return TPromise.as(false);
	}

B
Benjamin Pasero 已提交
864 865 866
	public loadBackupResource(resource: URI): TPromise<URI> {
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
867
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
868 869 870 871 872 873
			}

			return void 0;
		});
	}

D
Daniel Imms 已提交
874 875 876 877 878 879 880 881
	public registerResourceForBackup(resource: URI): TPromise<void> {
		return TPromise.as(void 0);
	}

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

882
	public toBackupResource(resource: URI): URI {
D
Daniel Imms 已提交
883 884
		return null;
	}
885

886
	public backupResource(resource: URI, content: ITextSnapshot): TPromise<void> {
887 888 889
		return TPromise.as(void 0);
	}

890
	public getWorkspaceFileBackups(): TPromise<URI[]> {
891 892 893
		return TPromise.as([]);
	}

894 895 896 897 898
	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);
899 900
	}

901 902 903 904
	public resolveBackupContent(backup: URI): TPromise<ITextBufferFactory> {
		return TPromise.as(null);
	}

905
	public discardResourceBackup(resource: URI): TPromise<void> {
906 907 908
		return TPromise.as(void 0);
	}

909
	public discardAllWorkspaceBackups(): TPromise<void> {
910 911
		return TPromise.as(void 0);
	}
912
}
D
Daniel Imms 已提交
913

B
Benjamin Pasero 已提交
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933
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) { }
934
	getActiveCodeEditor(): ICodeEditor { return null; }
935
	openCodeEditor(input: IResourceInput, source: ICodeEditor, sideBySide?: boolean): TPromise<ICodeEditor> { return TPromise.as(null); }
B
Benjamin Pasero 已提交
936 937
}

938 939 940 941
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

942
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
943

944 945 946 947
	isFocused(): TPromise<boolean> {
		return TPromise.as(false);
	}

948 949 950 951
	getConfiguration(): IWindowConfiguration {
		return Object.create(null);
	}

952 953 954 955
	getCurrentWindowId(): number {
		return 0;
	}

B
Benjamin Pasero 已提交
956
	pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
957 958 959
		return TPromise.as(void 0);
	}

B
Benjamin Pasero 已提交
960
	pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
961 962 963
		return TPromise.as(void 0);
	}

B
Benjamin Pasero 已提交
964
	pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
965 966 967
		return TPromise.as(void 0);
	}

968 969 970 971
	pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
		return TPromise.as(void 0);
	}

972 973 974 975 976 977 978 979 980 981 982 983
	reloadWindow(): TPromise<void> {
		return TPromise.as(void 0);
	}

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

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

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

988
	createAndEnterWorkspace(folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult> {
989 990 991
		return TPromise.as(void 0);
	}

992
	saveAndEnterWorkspace(path: string): TPromise<IEnterWorkspaceResult> {
993 994 995
		return TPromise.as(void 0);
	}

996 997 998 999 1000 1001 1002 1003
	toggleFullScreen(): TPromise<void> {
		return TPromise.as(void 0);
	}

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

1004
	getRecentlyOpened(): TPromise<IRecentlyOpened> {
1005 1006 1007 1008 1009 1010 1011
		return TPromise.as(void 0);
	}

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

1012 1013 1014 1015
	closeWindow(): TPromise<void> {
		return TPromise.as(void 0);
	}

1016 1017 1018 1019
	setDocumentEdited(flag: boolean): TPromise<void> {
		return TPromise.as(void 0);
	}

1020 1021 1022
	onWindowTitleDoubleClick(): TPromise<void> {
		return TPromise.as(void 0);
	}
1023

J
Joao 已提交
1024 1025 1026 1027
	show(): TPromise<void> {
		return TPromise.as(void 0);
	}

1028 1029
	showMessageBox(options: Electron.MessageBoxOptions): TPromise<IMessageBoxResult> {
		return TPromise.wrap({ button: 0 });
1030 1031
	}

1032 1033
	showSaveDialog(options: Electron.SaveDialogOptions): TPromise<string> {
		return TPromise.wrap(void 0);
1034
	}
1035

1036 1037
	showOpenDialog(options: Electron.OpenDialogOptions): TPromise<string[]> {
		return TPromise.wrap(void 0);
1038
	}
1039 1040 1041 1042

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

1045 1046
export class TestLifecycleService implements ILifecycleService {

1047
	public _serviceBrand: any;
1048

1049
	public phase: LifecyclePhase;
1050
	public startupKind: StartupKind;
1051

1052
	private _onWillShutdown = new Emitter<ShutdownEvent>();
1053
	private _onShutdown = new Emitter<ShutdownReason>();
1054

1055
	when(): TPromise<void> {
1056
		return TPromise.as(void 0);
B
Benjamin Pasero 已提交
1057
	}
1058

1059 1060
	public fireShutdown(reason = ShutdownReason.QUIT): void {
		this._onShutdown.fire(reason);
1061 1062
	}

1063 1064 1065 1066
	public fireWillShutdown(event: ShutdownEvent): void {
		this._onWillShutdown.fire(event);
	}

1067 1068 1069 1070
	public get onWillShutdown(): Event<ShutdownEvent> {
		return this._onWillShutdown.event;
	}

1071
	public get onShutdown(): Event<ShutdownReason> {
1072 1073
		return this._onShutdown.event;
	}
1074 1075
}

1076 1077 1078 1079
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1080 1081
	public windowCount = 1;

1082 1083
	onWindowOpen: Event<number>;
	onWindowFocus: Event<number>;
1084
	onWindowBlur: Event<number>;
1085

1086 1087 1088 1089
	isFocused(windowId: number): TPromise<boolean> {
		return TPromise.as(false);
	}

B
Benjamin Pasero 已提交
1090
	pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
1091 1092
		return TPromise.as(void 0);
	}
1093

B
Benjamin Pasero 已提交
1094
	pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
1095 1096
		return TPromise.as(void 0);
	}
1097

B
Benjamin Pasero 已提交
1098
	pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
1099 1100
		return TPromise.as(void 0);
	}
1101

1102 1103 1104 1105
	pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
		return TPromise.as(void 0);
	}

1106 1107 1108
	reloadWindow(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1109

1110 1111 1112
	openDevTools(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1113

1114 1115 1116
	toggleDevTools(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1117

1118
	closeWorkspace(windowId: number): TPromise<void> {
1119 1120
		return TPromise.as(void 0);
	}
1121

1122
	createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult> {
1123 1124 1125
		return TPromise.as(void 0);
	}

1126
	saveAndEnterWorkspace(windowId: number, path: string): TPromise<IEnterWorkspaceResult> {
1127 1128 1129
		return TPromise.as(void 0);
	}

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

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

1138
	addRecentlyOpened(files: string[]): TPromise<void> {
1139 1140
		return TPromise.as(void 0);
	}
1141

1142
	removeFromRecentlyOpened(paths: string[]): TPromise<void> {
1143 1144
		return TPromise.as(void 0);
	}
1145

B
Benjamin Pasero 已提交
1146
	clearRecentlyOpened(): TPromise<void> {
C
22768  
Cristian 已提交
1147 1148
		return TPromise.as(void 0);
	}
1149

1150
	getRecentlyOpened(windowId: number): TPromise<IRecentlyOpened> {
1151 1152
		return TPromise.as(void 0);
	}
1153

1154 1155 1156
	focusWindow(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1157

1158 1159 1160 1161
	closeWindow(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}

1162 1163 1164
	isMaximized(windowId: number): TPromise<boolean> {
		return TPromise.as(void 0);
	}
1165

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

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

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

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

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

J
Johannes Rieken 已提交
1186 1187 1188
	relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise<void> {
		return TPromise.as(void 0);
	}
1189

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

1194 1195 1196
	toggleSharedProcess(): TPromise<void> {
		return TPromise.as(void 0);
	}
1197

1198
	// Global methods
1199
	openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
1200 1201
		return TPromise.as(void 0);
	}
1202

1203 1204 1205
	openNewWindow(): TPromise<void> {
		return TPromise.as(void 0);
	}
1206

1207 1208 1209
	showWindow(windowId: number): TPromise<void> {
		return TPromise.as(void 0);
	}
1210

1211
	getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderPath?: string; title: string; filename?: string; }[]> {
1212 1213
		return TPromise.as(void 0);
	}
1214

1215
	getWindowCount(): TPromise<number> {
1216
		return TPromise.as(this.windowCount);
1217
	}
1218

1219 1220 1221
	log(severity: string, ...messages: string[]): TPromise<void> {
		return TPromise.as(void 0);
	}
1222

1223 1224 1225 1226
	showItemInFolder(path: string): TPromise<void> {
		return TPromise.as(void 0);
	}

1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244
	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);
1245 1246 1247 1248
	}

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

1251 1252
	// This needs to be handled from browser process to prevent
	// foreground ordering issues on Windows
1253 1254
	openExternal(url: string): TPromise<boolean> {
		return TPromise.as(true);
1255 1256 1257 1258 1259 1260
	}

	// TODO: this is a bit backwards
	startCrashReporter(config: Electron.CrashReporterStartOptions): TPromise<void> {
		return TPromise.as(void 0);
	}
1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272

	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 已提交
1273 1274 1275 1276

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

1279 1280 1281 1282 1283 1284 1285
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1286
	public onDidChangeConfiguration() {
1287 1288 1289
		return { dispose() { } };
	}

1290 1291 1292 1293
	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 });
1294
	}
B
Benjamin Pasero 已提交
1295 1296
}

R
Ramya Achutha Rao 已提交
1297 1298 1299 1300 1301 1302 1303 1304
export class TestHashService implements IHashService {
	_serviceBrand: any;

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

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