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

6
import 'vs/workbench/contrib/files/browser/files.contribution'; // load our contribution into the test
7
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
8
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
9
import { join } from 'vs/base/common/path';
10
import * as resources from 'vs/base/common/resources';
11
import { URI } from 'vs/base/common/uri';
12 13
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
14 15
import { ConfirmResult, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent, IEditorPartOptions } from 'vs/workbench/common/editor';
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
M
Matt Bierner 已提交
16
import { Event, Emitter } from 'vs/base/common/event';
E
Erich Gamma 已提交
17
import Severity from 'vs/base/common/severity';
18
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
19
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
B
Benjamin Pasero 已提交
20
import { IWorkbenchLayoutService, Parts, Position as PartPosition } from 'vs/workbench/services/layout/browser/layoutService';
21
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
22
import { ITextModelService } from 'vs/editor/common/services/resolverService';
B
Benjamin Pasero 已提交
23
import { IEditorOptions, IResourceInput } from 'vs/platform/editor/common/editor';
J
Johannes Rieken 已提交
24
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
S
Sandeep Somavarapu 已提交
25
import { IWorkspaceContextService, IWorkspace as IWorkbenchWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, Workspace } from 'vs/platform/workspace/common/workspace';
26
import { ILifecycleService, BeforeShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase, WillShutdownEvent } from 'vs/platform/lifecycle/common/lifecycle';
J
Johannes Rieken 已提交
27
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
28
import { TextFileService } from 'vs/workbench/services/textfile/common/textFileService';
29
import { FileOperationEvent, IFileService, IResolveContentOptions, FileOperationError, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, IContent, IUpdateContentOptions, IStreamContent, ICreateFileOptions, ITextSnapshot, IResourceEncodings } from 'vs/platform/files/common/files';
30
import { IModelService } from 'vs/editor/common/services/modelService';
31
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
J
Johannes Rieken 已提交
32 33 34 35 36 37
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';
38
import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
39
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
40
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, MenuBarVisibility, IURIToOpen } from 'vs/platform/windows/common/windows';
S
Sandeep Somavarapu 已提交
41
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
42
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
B
Benjamin Pasero 已提交
43
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
44
import { IThemeService } from 'vs/platform/theme/common/themeService';
B
Benjamin Pasero 已提交
45
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
46
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
B
Benjamin Pasero 已提交
47
import { IRecentlyOpened } from 'vs/platform/history/common/history';
S
Sandeep Somavarapu 已提交
48
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
49
import { IPosition, Position as EditorPosition } from 'vs/editor/common/core/position';
B
Benjamin Pasero 已提交
50
import { IMenuService, MenuId, IMenu, ISerializableCommandAction } from 'vs/platform/actions/common/actions';
R
Ramya Achutha Rao 已提交
51
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
I
isidor 已提交
52
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
B
Benjamin Pasero 已提交
53
import { MockContextKeyService, MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
B
Benjamin Pasero 已提交
54
import { ITextBufferFactory, DefaultEndOfLine, EndOfLinePreference, IModelDecorationOptions, ITextModel } from 'vs/editor/common/model';
55
import { Range } from 'vs/editor/common/core/range';
M
Martin Aeschlimann 已提交
56
import { IConfirmation, IConfirmationResult, IDialogService, IDialogOptions, IPickAndOpenOptions, ISaveDialogOptions, IOpenDialogOptions, IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
57 58
import { INotificationService } from 'vs/platform/notification/common/notification';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
59
import { IExtensionService, NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
B
Benjamin Pasero 已提交
60
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
B
Benjamin Pasero 已提交
61
import { IDecorationsService, IResourceDecorationChangeEvent, IDecoration, IDecorationData, IDecorationsProvider } from 'vs/workbench/services/decorations/browser/decorations';
J
Joao Moreno 已提交
62
import { IDisposable, toDisposable, Disposable } from 'vs/base/common/lifecycle';
63
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, EditorsOrder, IFindGroupScope, EditorGroupLayout, ICloseEditorOptions } from 'vs/workbench/services/editor/common/editorGroupsService';
M
Matt Bierner 已提交
64
import { IEditorService, IOpenEditorOverrideHandler, IActiveEditor } from 'vs/workbench/services/editor/common/editorService';
B
Benjamin Pasero 已提交
65 66 67
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 已提交
68
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
69
import { Dimension } from 'vs/base/browser/dom';
70
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
I
isidor 已提交
71
import { ILabelService } from 'vs/platform/label/common/label';
72
import { timeout } from 'vs/base/common/async';
73
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
74
import { ViewletDescriptor, Viewlet } from 'vs/workbench/browser/viewlet';
75
import { IViewlet } from 'vs/workbench/common/viewlet';
76
import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/common/storage';
S
Sandeep Somavarapu 已提交
77
import { isLinux, isMacintosh } from 'vs/base/common/platform';
I
isidor 已提交
78
import { LabelService } from 'vs/workbench/services/label/common/labelService';
B
Benjamin Pasero 已提交
79
import { IDimension } from 'vs/platform/layout/browser/layoutService';
80
import { Part } from 'vs/workbench/browser/part';
81 82 83
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IPanel } from 'vs/workbench/common/panel';
import { IBadge } from 'vs/workbench/services/activity/common/activity';
B
Benjamin Pasero 已提交
84

S
Sandeep Somavarapu 已提交
85
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
R
Rob Lourens 已提交
86
	return instantiationService.createInstance(FileEditorInput, resource, undefined);
S
Sandeep Somavarapu 已提交
87 88
}

89
export const TestEnvironmentService = new EnvironmentService(parseArgs(process.argv), process.execPath);
90

91
export class TestContextService implements IWorkspaceContextService {
92
	public _serviceBrand: any;
E
Erich Gamma 已提交
93

S
Sandeep Somavarapu 已提交
94
	private workspace: Workspace;
E
Erich Gamma 已提交
95 96
	private options: any;

M
Matt Bierner 已提交
97 98 99
	private readonly _onDidChangeWorkspaceName: Emitter<void>;
	private readonly _onDidChangeWorkspaceFolders: Emitter<IWorkspaceFoldersChangeEvent>;
	private readonly _onDidChangeWorkbenchState: Emitter<WorkbenchState>;
100

101
	constructor(workspace: any = TestWorkspace, options: any = null) {
E
Erich Gamma 已提交
102
		this.workspace = workspace;
103
		this.options = options || Object.create(null);
104
		this._onDidChangeWorkspaceFolders = new Emitter<IWorkspaceFoldersChangeEvent>();
S
Sandeep Somavarapu 已提交
105
		this._onDidChangeWorkbenchState = new Emitter<WorkbenchState>();
106 107
	}

S
Sandeep Somavarapu 已提交
108 109 110 111
	public get onDidChangeWorkspaceName(): Event<void> {
		return this._onDidChangeWorkspaceName.event;
	}

112
	public get onDidChangeWorkspaceFolders(): Event<IWorkspaceFoldersChangeEvent> {
S
Sandeep Somavarapu 已提交
113
		return this._onDidChangeWorkspaceFolders.event;
114 115
	}

116 117 118 119
	public get onDidChangeWorkbenchState(): Event<WorkbenchState> {
		return this._onDidChangeWorkbenchState.event;
	}

S
Sandeep Somavarapu 已提交
120
	public getFolders(): IWorkspaceFolder[] {
S
Sandeep Somavarapu 已提交
121
		return this.workspace ? this.workspace.folders : [];
E
Erich Gamma 已提交
122 123
	}

124
	public getWorkbenchState(): WorkbenchState {
B
Benjamin Pasero 已提交
125 126 127 128 129
		if (this.workspace.configuration) {
			return WorkbenchState.WORKSPACE;
		}

		if (this.workspace.folders.length) {
130
			return WorkbenchState.FOLDER;
131
		}
B
Benjamin Pasero 已提交
132

133
		return WorkbenchState.EMPTY;
S
Sandeep Somavarapu 已提交
134 135
	}

136 137 138 139
	getCompleteWorkspace(): Promise<IWorkbenchWorkspace> {
		return Promise.resolve(this.getWorkspace());
	}

140
	public getWorkspace(): IWorkbenchWorkspace {
B
Benjamin Pasero 已提交
141
		return this.workspace;
142 143
	}

144
	public getWorkspaceFolder(resource: URI): IWorkspaceFolder | null {
S
Sandeep Somavarapu 已提交
145
		return this.workspace.getFolder(resource);
146 147
	}

D
Daniel Imms 已提交
148 149 150 151
	public setWorkspace(workspace: any): void {
		this.workspace = workspace;
	}

E
Erich Gamma 已提交
152 153 154 155 156 157 158 159 160 161
	public getOptions() {
		return this.options;
	}

	public updateOptions() {

	}

	public isInsideWorkspace(resource: URI): boolean {
		if (resource && this.workspace) {
162
			return resources.isEqualOrParent(resource, this.workspace.folders[0].uri);
E
Erich Gamma 已提交
163 164 165 166 167 168
		}

		return false;
	}

	public toResource(workspaceRelativePath: string): URI {
169
		return URI.file(join('C:\\', workspaceRelativePath));
E
Erich Gamma 已提交
170
	}
171

172
	public isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean {
173
		return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && resources.isEqual(this.workspace.folders[0].uri, workspaceIdentifier);
174
	}
E
Erich Gamma 已提交
175 176
}

177
export class TestTextFileService extends TextFileService {
178 179
	public cleanupBackupsBeforeShutdownCalled: boolean;

M
Martin Aeschlimann 已提交
180
	private promptPath: URI;
181
	private confirmResult: ConfirmResult;
182
	private resolveTextContentError: FileOperationError | null;
A
Alex Dima 已提交
183 184

	constructor(
185
		@IWorkspaceContextService contextService: IWorkspaceContextService,
186
		@IFileService protected fileService: IFileService,
187
		@IUntitledEditorService untitledEditorService: IUntitledEditorService,
188
		@ILifecycleService lifecycleService: ILifecycleService,
189
		@IInstantiationService instantiationService: IInstantiationService,
190 191 192 193 194
		@IConfigurationService configurationService: IConfigurationService,
		@IModeService modeService: IModeService,
		@IModelService modelService: IModelService,
		@IWindowService windowService: IWindowService,
		@IEnvironmentService environmentService: IEnvironmentService,
195
		@INotificationService notificationService: INotificationService,
196
		@IBackupFileService backupFileService: IBackupFileService,
197
		@IWindowsService windowsService: IWindowsService,
I
isidor 已提交
198
		@IHistoryService historyService: IHistoryService,
B
Benjamin Pasero 已提交
199
		@IContextKeyService contextKeyService: IContextKeyService,
200 201 202
		@IDialogService dialogService: IDialogService,
		@IFileDialogService fileDialogService: IFileDialogService,
		@IEditorService editorService: IEditorService
A
Alex Dima 已提交
203
	) {
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
		super(
			contextService,
			fileService,
			untitledEditorService,
			lifecycleService,
			instantiationService,
			configurationService,
			modeService,
			modelService,
			windowService,
			environmentService,
			notificationService,
			backupFileService,
			windowsService,
			historyService,
			contextKeyService,
			dialogService,
			fileDialogService,
			editorService
		);
A
Alex Dima 已提交
224
	}
225

M
Martin Aeschlimann 已提交
226
	public setPromptPath(path: URI): void {
227 228 229 230 231 232 233
		this.promptPath = path;
	}

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

234
	public setResolveTextContentErrorOnce(error: FileOperationError): void {
235 236 237
		this.resolveTextContentError = error;
	}

J
Johannes Rieken 已提交
238
	public resolveTextContent(resource: URI, options?: IResolveContentOptions): Promise<IRawTextContent> {
239 240 241 242
		if (this.resolveTextContentError) {
			const error = this.resolveTextContentError;
			this.resolveTextContentError = null;

B
Benjamin Pasero 已提交
243
			return Promise.reject(error);
244 245
		}

246 247
		return this.fileService.resolveContent(resource, options).then((content): IRawTextContent => {
			return {
248
				resource: content.resource,
249 250 251 252
				name: content.name,
				mtime: content.mtime,
				etag: content.etag,
				encoding: content.encoding,
253
				value: createTextBufferFactory(content.value)
254 255 256
			};
		});
	}
257

J
Johannes Rieken 已提交
258
	public promptForPath(_resource: URI, _defaultPath: URI): Promise<URI> {
B
Benjamin Pasero 已提交
259
		return Promise.resolve(this.promptPath);
260 261
	}

J
Johannes Rieken 已提交
262
	public confirmSave(_resources?: URI[]): Promise<ConfirmResult> {
B
Benjamin Pasero 已提交
263
		return Promise.resolve(this.confirmResult);
264
	}
D
Daniel Imms 已提交
265

B
Benjamin Pasero 已提交
266 267 268 269
	public confirmOverwrite(_resource: URI): Promise<boolean> {
		return Promise.resolve(true);
	}

270 271
	public onFilesConfigurationChange(configuration: any): void {
		super.onFilesConfigurationChange(configuration);
272 273
	}

J
Johannes Rieken 已提交
274
	protected cleanupBackupsBeforeShutdown(): Promise<void> {
275
		this.cleanupBackupsBeforeShutdownCalled = true;
B
Benjamin Pasero 已提交
276
		return Promise.resolve();
277
	}
A
Alex Dima 已提交
278 279
}

280
export function workbenchInstantiationService(): IInstantiationService {
281
	let instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
282
	instantiationService.stub(IEnvironmentService, TestEnvironmentService);
I
isidor 已提交
283
	instantiationService.stub(IContextKeyService, <IContextKeyService>instantiationService.createInstance(MockContextKeyService));
I
isidor 已提交
284 285
	const workspaceContextService = new TestContextService(TestWorkspace);
	instantiationService.stub(IWorkspaceContextService, workspaceContextService);
286 287 288
	const configService = new TestConfigurationService();
	instantiationService.stub(IConfigurationService, configService);
	instantiationService.stub(ITextResourceConfigurationService, new TestTextResourceConfigurationService(configService));
289
	instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
290
	instantiationService.stub(IStorageService, new TestStorageService());
291
	instantiationService.stub(IWorkbenchLayoutService, new TestLayoutService());
J
Johannes Rieken 已提交
292
	instantiationService.stub(IModeService, instantiationService.createInstance(ModeServiceImpl));
B
Benjamin Pasero 已提交
293
	instantiationService.stub(IHistoryService, new TestHistoryService());
S
Sandeep Somavarapu 已提交
294
	instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(configService));
S
Sandeep Somavarapu 已提交
295
	instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl));
296
	instantiationService.stub(IFileService, new TestFileService());
297
	instantiationService.stub(IBackupFileService, new TestBackupFileService());
298
	instantiationService.stub(ITelemetryService, NullTelemetryService);
299
	instantiationService.stub(INotificationService, new TestNotificationService());
B
Benjamin Pasero 已提交
300
	instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
301
	instantiationService.stub(IWindowService, new TestWindowService());
B
Benjamin Pasero 已提交
302 303 304 305
	instantiationService.stub(IMenuService, new TestMenuService());
	instantiationService.stub(IKeybindingService, new MockKeybindingService());
	instantiationService.stub(IDecorationsService, new TestDecorationsService());
	instantiationService.stub(IExtensionService, new TestExtensionService());
306
	instantiationService.stub(IWindowsService, new TestWindowsService());
307
	instantiationService.stub(ITextFileService, <ITextFileService>instantiationService.createInstance(TestTextFileService));
308
	instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
B
Benjamin Pasero 已提交
309
	instantiationService.stub(IThemeService, new TestThemeService());
R
Ramya Achutha Rao 已提交
310
	instantiationService.stub(IHashService, new TestHashService());
I
isidor 已提交
311
	instantiationService.stub(ILogService, new TestLogService());
312
	instantiationService.stub(IEditorGroupsService, new TestEditorGroupsService([new TestEditorGroup(0)]));
M
Martin Aeschlimann 已提交
313
	instantiationService.stub(ILabelService, <ILabelService>instantiationService.createInstance(LabelService));
B
Benjamin Pasero 已提交
314
	const editorService = new TestEditorService();
315
	instantiationService.stub(IEditorService, editorService);
B
Benjamin Pasero 已提交
316
	instantiationService.stub(ICodeEditorService, new TestCodeEditorService());
317
	instantiationService.stub(IViewletService, new TestViewletService());
318 319 320 321

	return instantiationService;
}

I
isidor 已提交
322 323 324
export class TestLogService implements ILogService {
	_serviceBrand: any; onDidChangeLogLevel: Event<LogLevel>;
	getLevel(): LogLevel { return LogLevel.Info; }
325 326 327 328 329 330 331
	setLevel(_level: LogLevel): void { }
	trace(_message: string, ..._args: any[]): void { }
	debug(_message: string, ..._args: any[]): void { }
	info(_message: string, ..._args: any[]): void { }
	warn(_message: string, ..._args: any[]): void { }
	error(_message: string | Error, ..._args: any[]): void { }
	critical(_message: string | Error, ..._args: any[]): void { }
I
isidor 已提交
332 333 334
	dispose(): void { }
}

B
Benjamin Pasero 已提交
335 336 337
export class TestDecorationsService implements IDecorationsService {
	_serviceBrand: any;
	onDidChangeDecorations: Event<IResourceDecorationChangeEvent> = Event.None;
338
	registerDecorationsProvider(_provider: IDecorationsProvider): IDisposable { return Disposable.None; }
339
	getDecoration(_uri: URI, _includeChildren: boolean, _overwrite?: IDecorationData): IDecoration | undefined { return undefined; }
B
Benjamin Pasero 已提交
340 341
}

342
export class TestExtensionService extends NullExtensionService { }
B
Benjamin Pasero 已提交
343 344 345 346 347

export class TestMenuService implements IMenuService {

	public _serviceBrand: any;

348
	createMenu(_id: MenuId, _scopedKeybindingService: IContextKeyService): IMenu {
B
Benjamin Pasero 已提交
349 350
		return {
			onDidChange: Event.None,
R
Rob Lourens 已提交
351
			dispose: () => undefined,
B
Benjamin Pasero 已提交
352 353 354 355 356
			getActions: () => []
		};
	}
}

B
Benjamin Pasero 已提交
357 358 359 360 361 362 363 364 365 366
export class TestHistoryService implements IHistoryService {

	public _serviceBrand: any;

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

367
	public forward(_acrossEditors?: boolean): void {
B
Benjamin Pasero 已提交
368 369
	}

370
	public back(_acrossEditors?: boolean): void {
B
Benjamin Pasero 已提交
371 372
	}

373 374 375
	public last(): void {
	}

376
	public remove(_input: IEditorInput | IResourceInput): void {
B
Benjamin Pasero 已提交
377 378 379 380 381
	}

	public clear(): void {
	}

B
Benjamin Pasero 已提交
382 383 384
	public clearRecentlyOpened(): void {
	}

385
	public getHistory(): Array<IEditorInput | IResourceInput> {
B
Benjamin Pasero 已提交
386 387 388
		return [];
	}

389
	public getLastActiveWorkspaceRoot(_schemeFilter: string): URI | undefined {
B
Benjamin Pasero 已提交
390 391
		return this.root;
	}
392

393
	public getLastActiveFile(_schemeFilter: string): URI | undefined {
R
Rob Lourens 已提交
394
		return undefined;
395
	}
B
Benjamin Pasero 已提交
396 397 398

	public openLastEditLocation(): void {
	}
B
Benjamin Pasero 已提交
399 400
}

401
export class TestDialogService implements IDialogService {
402 403

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

J
Johannes Rieken 已提交
405
	public confirm(_confirmation: IConfirmation): Promise<IConfirmationResult> {
B
Benjamin Pasero 已提交
406
		return Promise.resolve({ confirmed: false });
407
	}
408

J
Johannes Rieken 已提交
409
	public show(_severity: Severity, _message: string, _buttons: string[], _options?: IDialogOptions): Promise<number> {
B
Benjamin Pasero 已提交
410
		return Promise.resolve(0);
411
	}
E
Erich Gamma 已提交
412 413
}

M
Martin Aeschlimann 已提交
414 415 416 417
export class TestFileDialogService implements IFileDialogService {

	public _serviceBrand: any;

418
	public defaultFilePath(_schemeFilter?: string): URI | undefined {
R
Rob Lourens 已提交
419
		return undefined;
M
Martin Aeschlimann 已提交
420
	}
421
	public defaultFolderPath(_schemeFilter?: string): URI | undefined {
R
Rob Lourens 已提交
422
		return undefined;
M
Martin Aeschlimann 已提交
423
	}
424
	public defaultWorkspacePath(_schemeFilter?: string): URI | undefined {
R
Rob Lourens 已提交
425
		return undefined;
M
Martin Aeschlimann 已提交
426
	}
J
Johannes Rieken 已提交
427
	public pickFileFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
428
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
429
	}
J
Johannes Rieken 已提交
430
	public pickFileAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
431
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
432
	}
J
Johannes Rieken 已提交
433
	public pickFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
434
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
435
	}
J
Johannes Rieken 已提交
436
	public pickWorkspaceAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
437
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
438
	}
439
	public showSaveDialog(_options: ISaveDialogOptions): Promise<URI | undefined> {
J
Johannes Rieken 已提交
440
		return Promise.resolve(undefined);
M
Martin Aeschlimann 已提交
441
	}
442
	public showOpenDialog(_options: IOpenDialogOptions): Promise<URI[] | undefined> {
J
Johannes Rieken 已提交
443
		return Promise.resolve(undefined);
M
Martin Aeschlimann 已提交
444 445 446
	}
}

447
export class TestLayoutService implements IWorkbenchLayoutService {
B
Benjamin Pasero 已提交
448

449
	public _serviceBrand: any;
E
Erich Gamma 已提交
450

451 452
	dimension: IDimension = { width: 800, height: 600 };

453 454
	container: HTMLElement = window.document.body;

B
Benjamin Pasero 已提交
455
	onZenModeChange: Event<boolean> = Event.None;
456
	onLayout = Event.None;
B
Benjamin Pasero 已提交
457

458
	private _onTitleBarVisibilityChange = new Emitter<void>();
459
	private _onMenubarVisibilityChange = new Emitter<Dimension>();
460 461 462 463 464

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

465 466 467 468
	public get onMenubarVisibilityChange(): Event<Dimension> {
		return this._onMenubarVisibilityChange.event;
	}

B
Benjamin Pasero 已提交
469
	public isRestored(): boolean {
E
Erich Gamma 已提交
470 471 472
		return true;
	}

473
	public hasFocus(_part: Parts): boolean {
E
Erich Gamma 已提交
474 475 476
		return false;
	}

477
	public isVisible(_part: Parts): boolean {
E
Erich Gamma 已提交
478 479 480
		return true;
	}

481
	public getContainer(_part: Parts): HTMLElement | null {
482 483 484
		return null;
	}

B
Benjamin Pasero 已提交
485 486 487 488
	public isTitleBarHidden(): boolean {
		return false;
	}

489 490 491 492
	public getTitleBarOffset(): number {
		return 0;
	}

493 494 495 496
	public isStatusBarHidden(): boolean {
		return false;
	}

S
Sanders Lauture 已提交
497 498 499 500
	public isActivityBarHidden(): boolean {
		return false;
	}

501
	public setActivityBarHidden(_hidden: boolean): void { }
S
Sanders Lauture 已提交
502

E
Erich Gamma 已提交
503 504 505 506
	public isSideBarHidden(): boolean {
		return false;
	}

507
	public setEditorHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
S
SteVen Batten 已提交
508

509
	public setSideBarHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
E
Erich Gamma 已提交
510

I
isidor 已提交
511
	public isPanelHidden(): boolean {
I
isidor 已提交
512 513 514
		return false;
	}

515
	public setPanelHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
I
isidor 已提交
516

I
isidor 已提交
517 518
	public toggleMaximizedPanel(): void { }

B
Benjamin Pasero 已提交
519 520 521 522
	public isPanelMaximized(): boolean {
		return false;
	}

S
SteVen Batten 已提交
523
	public getMenubarVisibility(): MenuBarVisibility {
524
		throw new Error('not implemented');
S
SteVen Batten 已提交
525 526
	}

E
Erich Gamma 已提交
527 528 529 530
	public getSideBarPosition() {
		return 0;
	}

I
isidor 已提交
531 532 533 534
	public getPanelPosition() {
		return 0;
	}

J
Johannes Rieken 已提交
535
	public setPanelPosition(_position: PartPosition): Promise<void> {
536
		return Promise.resolve();
I
isidor 已提交
537 538
	}

539 540
	public addClass(_clazz: string): void { }
	public removeClass(_clazz: string): void { }
541
	public getWorkbenchElement(): HTMLElement { throw new Error('not implemented'); }
B
Benjamin Pasero 已提交
542

I
isidor 已提交
543
	public toggleZenMode(): void { }
544

B
Benjamin Pasero 已提交
545
	public isEditorLayoutCentered(): boolean { return false; }
546
	public centerEditorLayout(_active: boolean): void { }
S
SrTobi 已提交
547 548


549
	public resizePart(_part: Parts, _sizeChange: number): void { }
550 551

	public registerPart(part: Part): void { }
E
Erich Gamma 已提交
552 553
}

554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
let activeViewlet: Viewlet = {} as any;

export class TestViewletService implements IViewletService {
	public _serviceBrand: any;

	onDidViewletRegisterEmitter = new Emitter<ViewletDescriptor>();
	onDidViewletDeregisterEmitter = new Emitter<ViewletDescriptor>();
	onDidViewletOpenEmitter = new Emitter<IViewlet>();
	onDidViewletCloseEmitter = new Emitter<IViewlet>();

	onDidViewletRegister = this.onDidViewletRegisterEmitter.event;
	onDidViewletDeregister = this.onDidViewletDeregisterEmitter.event;
	onDidViewletOpen = this.onDidViewletOpenEmitter.event;
	onDidViewletClose = this.onDidViewletCloseEmitter.event;

	public openViewlet(id: string, focus?: boolean): Promise<IViewlet> {
		return Promise.resolve(null!);
	}

	public getViewlets(): ViewletDescriptor[] {
		return [];
	}

	public getAllViewlets(): ViewletDescriptor[] {
		return [];
	}

	public getActiveViewlet(): IViewlet {
		return activeViewlet;
	}

	public dispose() {
	}

	public getDefaultViewletId(): string {
		return 'workbench.view.explorer';
	}

	public getViewlet(id: string): ViewletDescriptor | undefined {
		return undefined;
	}

	public getProgressIndicator(id: string) {
		return null!;
	}
599 600 601 602 603 604

	public hideActiveViewlet(): void { }

	public getLastActiveViewletId(): string {
		return undefined;
	}
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
}

export class TestPanelService implements IPanelService {
	public _serviceBrand: any;

	onDidPanelOpen = new Emitter<{ panel: IPanel, focus: boolean }>().event;
	onDidPanelClose = new Emitter<IPanel>().event;

	public openPanel(id: string, focus?: boolean): IPanel {
		return null!;
	}

	public getPanels(): any[] {
		return [];
	}

	public getPinnedPanels(): any[] {
		return [];
	}

	public getActivePanel(): IViewlet {
		return activeViewlet;
	}

	public setPanelEnablement(id: string, enabled: boolean): void { }

	public dispose() {
	}

	public showActivity(panelId: string, badge: IBadge, clazz?: string): IDisposable {
		throw new Error('Method not implemented.');
	}

	public hideActivePanel(): void { }

	public getLastActivePanelId(): string {
		return undefined;
	}
}

645
export class TestStorageService extends InMemoryStorageService { }
646

647 648
export class TestEditorGroupsService implements IEditorGroupsService {

649 650
	_serviceBrand: ServiceIdentifier<any>;

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

653
	onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
B
Benjamin Pasero 已提交
654
	onDidActivateGroup: Event<IEditorGroup> = Event.None;
655 656 657
	onDidAddGroup: Event<IEditorGroup> = Event.None;
	onDidRemoveGroup: Event<IEditorGroup> = Event.None;
	onDidMoveGroup: Event<IEditorGroup> = Event.None;
658
	onDidLayout: Event<IDimension> = Event.None;
659 660

	orientation: any;
R
Rob Lourens 已提交
661
	whenRestored: Promise<void> = Promise.resolve(undefined);
662

663
	get activeGroup(): IEditorGroup {
664 665 666 667 668 669 670
		return this.groups[0];
	}

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

671
	getGroups(_order?: GroupsOrder): ReadonlyArray<IEditorGroup> {
672 673 674
		return this.groups;
	}

675
	getGroup(identifier: number): IEditorGroup {
676 677 678
		for (const group of this.groups) {
			if (group.id === identifier) {
				return group;
679 680 681
			}
		}

682
		return undefined!;
683 684
	}

685
	getLabel(_identifier: number): string {
686 687 688
		return 'Group 1';
	}

689
	findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup {
690
		throw new Error('not implemented');
691 692
	}

693
	activateGroup(_group: number | IEditorGroup): IEditorGroup {
694
		throw new Error('not implemented');
695 696
	}

697
	getSize(_group: number | IEditorGroup): number {
698
		return 100;
699 700
	}

701
	setSize(_group: number | IEditorGroup, _size: number): void { }
702

703
	arrangeGroups(_arrangement: GroupsArrangement): void { }
704

705
	applyLayout(_layout: EditorGroupLayout): void { }
706

707
	setGroupOrientation(_orientation: any): void { }
708

709
	addGroup(_location: number | IEditorGroup, _direction: GroupDirection, _options?: IAddGroupOptions): IEditorGroup {
710
		throw new Error('not implemented');
711 712
	}

713
	removeGroup(_group: number | IEditorGroup): void { }
714

715
	moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
716
		throw new Error('not implemented');
717 718
	}

719
	mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup {
720
		throw new Error('not implemented');
721 722
	}

723
	copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
724
		throw new Error('not implemented');
725
	}
726 727 728 729 730 731 732 733 734 735 736

	centerLayout(active: boolean): void { }

	isLayoutCentered(): boolean {
		return false;
	}

	partOptions: IEditorPartOptions;
	enforcePartOptions(options: IEditorPartOptions): IDisposable {
		return Disposable.None;
	}
737 738
}

B
Benjamin Pasero 已提交
739
export class TestEditorGroup implements IEditorGroupView {
740 741 742

	constructor(public id: number) { }

743
	get group(): EditorGroup { throw new Error('not implemented'); }
744
	activeControl: IActiveEditor;
745 746 747
	activeEditor: IEditorInput;
	previewEditor: IEditorInput;
	count: number;
B
Benjamin Pasero 已提交
748
	disposed: boolean;
B
Benjamin Pasero 已提交
749
	editors: ReadonlyArray<IEditorInput> = [];
750
	label: string;
R
Rob Lourens 已提交
751
	whenRestored: Promise<void> = Promise.resolve(undefined);
B
Benjamin Pasero 已提交
752 753 754 755 756
	element: HTMLElement;
	minimumWidth: number;
	maximumWidth: number;
	minimumHeight: number;
	maximumHeight: number;
757 758

	onWillDispose: Event<void> = Event.None;
759
	onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
B
Benjamin Pasero 已提交
760 761
	onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
762 763
	onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
	onDidOpenEditorFail: Event<IEditorInput> = Event.None;
B
Benjamin Pasero 已提交
764 765
	onDidFocus: Event<void> = Event.None;
	onDidChange: Event<{ width: number; height: number; }> = Event.None;
766

767
	getEditors(_order?: EditorsOrder): ReadonlyArray<IEditorInput> {
B
Benjamin Pasero 已提交
768 769 770
		return [];
	}

771
	getEditor(_index: number): IEditorInput {
772
		throw new Error('not implemented');
773 774
	}

775
	getIndexOfEditor(_editor: IEditorInput): number {
776 777 778
		return -1;
	}

J
Johannes Rieken 已提交
779
	openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditor> {
780
		throw new Error('not implemented');
781 782
	}

J
Johannes Rieken 已提交
783
	openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditor> {
784
		throw new Error('not implemented');
785 786
	}

787
	isOpened(_editor: IEditorInput): boolean {
788 789 790
		return false;
	}

791
	isPinned(_editor: IEditorInput): boolean {
792 793 794
		return false;
	}

795
	isActive(_editor: IEditorInput): boolean {
796 797 798
		return false;
	}

799
	moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
800

801
	copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
802

803
	closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> {
B
Benjamin Pasero 已提交
804
		return Promise.resolve();
805 806
	}

807
	closeEditors(_editors: IEditorInput[] | { except?: IEditorInput; direction?: CloseDirection; savedOnly?: boolean; }, options?: ICloseEditorOptions): Promise<void> {
B
Benjamin Pasero 已提交
808
		return Promise.resolve();
809 810
	}

J
Johannes Rieken 已提交
811
	closeAllEditors(): Promise<void> {
B
Benjamin Pasero 已提交
812
		return Promise.resolve();
813 814
	}

J
Johannes Rieken 已提交
815
	replaceEditors(_editors: IEditorReplacement[]): Promise<void> {
B
Benjamin Pasero 已提交
816
		return Promise.resolve();
817 818
	}

819
	pinEditor(_editor?: IEditorInput): void { }
820 821 822 823

	focus(): void { }

	invokeWithinContext<T>(fn: (accessor: ServicesAccessor) => T): T {
824
		throw new Error('not implemented');
825
	}
B
Benjamin Pasero 已提交
826 827

	isEmpty(): boolean { return true; }
828 829
	setActive(_isActive: boolean): void { }
	setLabel(_label: string): void { }
B
Benjamin Pasero 已提交
830 831
	dispose(): void { }
	toJSON(): object { return Object.create(null); }
832
	layout(_width: number, _height: number): void { }
833
	relayout() { }
834 835
}

B
Benjamin Pasero 已提交
836
export class TestEditorService implements EditorServiceImpl {
837 838 839 840 841

	_serviceBrand: ServiceIdentifier<any>;

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
842
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
843 844
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

M
Matt Bierner 已提交
845
	activeControl: IActiveEditor;
846
	activeTextEditorWidget: any;
847
	activeEditor: IEditorInput;
848
	editors: ReadonlyArray<IEditorInput> = [];
B
Benjamin Pasero 已提交
849
	visibleControls: ReadonlyArray<IEditor> = [];
850
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
851
	visibleEditors: ReadonlyArray<IEditorInput> = [];
852

853
	overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
R
Rob Lourens 已提交
854
		return toDisposable(() => undefined);
855 856
	}

857 858
	openEditor(_editor: any, _options?: any, _group?: any): Promise<any> {
		throw new Error('not implemented');
859 860
	}

861 862
	openEditors(_editors: any, _group?: any): Promise<IEditor[]> {
		throw new Error('not implemented');
863 864
	}

865
	isOpen(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
866 867 868
		return false;
	}

869
	getOpened(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): IEditorInput {
870
		throw new Error('not implemented');
871 872
	}

873
	replaceEditors(_editors: any, _group: any) {
R
Rob Lourens 已提交
874
		return Promise.resolve(undefined);
875 876
	}

877
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
878
		throw new Error('not implemented');
879 880
	}

881
	createInput(_input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
882
		throw new Error('not implemented');
883 884 885
	}
}

886 887 888 889
export class TestFileService implements IFileService {

	public _serviceBrand: any;

890 891
	public encoding: IResourceEncodings;

M
Matt Bierner 已提交
892 893
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
894

895 896
	private content = 'Hello Html';

897 898 899 900 901
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

902 903 904 905 906 907 908 909
	public setContent(content: string): void {
		this.content = content;
	}

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

910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925
	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);
	}

J
Johannes Rieken 已提交
926
	resolveFile(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat> {
B
Benjamin Pasero 已提交
927
		return Promise.resolve({
928 929
			resource,
			etag: Date.now().toString(),
B
Benjamin Pasero 已提交
930
			encoding: 'utf8',
B
Benjamin Pasero 已提交
931
			mtime: Date.now(),
932
			isDirectory: false,
B
Benjamin Pasero 已提交
933
			name: resources.basename(resource)
B
Benjamin Pasero 已提交
934
		});
935
	}
B
Benjamin Pasero 已提交
936

J
Johannes Rieken 已提交
937
	resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
B
Benjamin Pasero 已提交
938
		return Promise.all(toResolve.map(resourceAndOption => this.resolveFile(resourceAndOption.resource, resourceAndOption.options))).then(stats => stats.map(stat => ({ stat, success: true })));
I
isidor 已提交
939 940
	}

J
Johannes Rieken 已提交
941
	existsFile(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
942
		return Promise.resolve(true);
943
	}
B
Benjamin Pasero 已提交
944

J
Johannes Rieken 已提交
945
	resolveContent(resource: URI, _options?: IResolveContentOptions): Promise<IContent> {
B
Benjamin Pasero 已提交
946
		return Promise.resolve({
B
Benjamin Pasero 已提交
947
			resource: resource,
948
			value: this.content,
949
			etag: 'index.txt',
B
Benjamin Pasero 已提交
950 951
			encoding: 'utf8',
			mtime: Date.now(),
B
Benjamin Pasero 已提交
952
			name: resources.basename(resource)
E
Erich Gamma 已提交
953
		});
954
	}
E
Erich Gamma 已提交
955

J
Johannes Rieken 已提交
956
	resolveStreamContent(resource: URI, _options?: IResolveContentOptions): Promise<IStreamContent> {
B
Benjamin Pasero 已提交
957
		return Promise.resolve({
A
Alex Dima 已提交
958 959
			resource: resource,
			value: {
960
				on: (event: string, callback: Function): void => {
A
Alex Dima 已提交
961
					if (event === 'data') {
962
						callback(this.content);
A
Alex Dima 已提交
963 964 965 966 967 968 969 970
					}
					if (event === 'end') {
						callback();
					}
				}
			},
			etag: 'index.txt',
			encoding: 'utf8',
B
Benjamin Pasero 已提交
971
			mtime: Date.now(),
B
Benjamin Pasero 已提交
972
			name: resources.basename(resource)
A
Alex Dima 已提交
973
		});
974 975
	}

J
Johannes Rieken 已提交
976
	updateContent(resource: URI, _value: string | ITextSnapshot, _options?: IUpdateContentOptions): Promise<IFileStat> {
B
Benjamin Pasero 已提交
977
		return timeout(0).then(() => ({
978 979 980 981 982
			resource,
			etag: 'index.txt',
			encoding: 'utf8',
			mtime: Date.now(),
			isDirectory: false,
B
Benjamin Pasero 已提交
983
			name: resources.basename(resource)
B
Benjamin Pasero 已提交
984
		}));
985
	}
D
Daniel Imms 已提交
986

J
Johannes Rieken 已提交
987
	moveFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStat> {
988
		return Promise.resolve(null!);
989
	}
D
Daniel Imms 已提交
990

J
Johannes Rieken 已提交
991
	copyFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStat> {
992
		throw new Error('not implemented');
993
	}
D
Daniel Imms 已提交
994

J
Johannes Rieken 已提交
995
	createFile(_resource: URI, _content?: string, _options?: ICreateFileOptions): Promise<IFileStat> {
996
		throw new Error('not implemented');
E
Erich Gamma 已提交
997
	}
998

C
Christof Marti 已提交
999
	readFolder(_resource: URI) {
B
Benjamin Pasero 已提交
1000
		return Promise.resolve([]);
C
Christof Marti 已提交
1001 1002
	}

J
Johannes Rieken 已提交
1003
	createFolder(_resource: URI): Promise<IFileStat> {
1004
		throw new Error('not implemented');
1005 1006
	}

1007 1008
	onDidChangeFileSystemProviderRegistrations = Event.None;

1009
	registerProvider(_scheme: string, _provider) {
1010 1011 1012
		return { dispose() { } };
	}

1013 1014
	activateProvider(_scheme: string): Promise<void> {
		throw new Error('not implemented');
1015 1016
	}

1017 1018 1019 1020
	canHandleResource(resource: URI): boolean {
		return resource.scheme === 'file';
	}

J
Johannes Rieken 已提交
1021
	del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
1022
		return Promise.resolve();
1023 1024
	}

1025
	watchFileChanges(_resource: URI): void {
1026 1027
	}

1028
	unwatchFileChanges(_resource: URI): void {
1029 1030
	}

1031
	getWriteEncoding(_resource: URI): string {
1032 1033
		return 'utf8';
	}
D
Daniel Imms 已提交
1034

1035
	dispose(): void {
E
Erich Gamma 已提交
1036
	}
1037
}
1038

1039 1040
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
1041

J
Johannes Rieken 已提交
1042
	public hasBackups(): Promise<boolean> {
B
Benjamin Pasero 已提交
1043
		return Promise.resolve(false);
1044 1045
	}

J
Johannes Rieken 已提交
1046
	public hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
1047
		return Promise.resolve(false);
1048 1049
	}

1050
	public loadBackupResource(resource: URI): Promise<URI | undefined> {
B
Benjamin Pasero 已提交
1051 1052
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
1053
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
1054 1055
			}

R
Rob Lourens 已提交
1056
			return undefined;
B
Benjamin Pasero 已提交
1057 1058 1059
		});
	}

J
Johannes Rieken 已提交
1060
	public registerResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1061
		return Promise.resolve();
D
Daniel Imms 已提交
1062 1063
	}

J
Johannes Rieken 已提交
1064
	public deregisterResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1065
		return Promise.resolve();
D
Daniel Imms 已提交
1066 1067
	}

1068
	public toBackupResource(_resource: URI): URI {
1069
		throw new Error('not implemented');
D
Daniel Imms 已提交
1070
	}
1071

J
Johannes Rieken 已提交
1072
	public backupResource(_resource: URI, _content: ITextSnapshot): Promise<void> {
B
Benjamin Pasero 已提交
1073
		return Promise.resolve();
1074 1075
	}

J
Johannes Rieken 已提交
1076
	public getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
1077
		return Promise.resolve([]);
1078 1079
	}

1080 1081 1082 1083 1084
	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);
1085 1086
	}

J
Johannes Rieken 已提交
1087
	public resolveBackupContent(_backup: URI): Promise<ITextBufferFactory> {
1088
		throw new Error('not implemented');
1089 1090
	}

J
Johannes Rieken 已提交
1091
	public discardResourceBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1092
		return Promise.resolve();
1093 1094
	}

J
Johannes Rieken 已提交
1095
	public discardAllWorkspaceBackups(): Promise<void> {
B
Benjamin Pasero 已提交
1096
		return Promise.resolve();
1097
	}
1098
}
D
Daniel Imms 已提交
1099

B
Benjamin Pasero 已提交
1100 1101 1102 1103 1104 1105 1106
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;
A
Alex Dima 已提交
1107
	onDidChangeTransientModelProperty: Event<ITextModel> = Event.None;
B
Benjamin Pasero 已提交
1108

1109 1110
	addCodeEditor(_editor: ICodeEditor): void { }
	removeCodeEditor(_editor: ICodeEditor): void { }
B
Benjamin Pasero 已提交
1111
	listCodeEditors(): ICodeEditor[] { return []; }
1112 1113
	addDiffEditor(_editor: IDiffEditor): void { }
	removeDiffEditor(_editor: IDiffEditor): void { }
B
Benjamin Pasero 已提交
1114
	listDiffEditors(): IDiffEditor[] { return []; }
1115
	getFocusedCodeEditor(): ICodeEditor | null { return null; }
1116 1117 1118 1119 1120
	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) { }
1121 1122
	getActiveCodeEditor(): ICodeEditor | null { return null; }
	openCodeEditor(_input: IResourceInput, _source: ICodeEditor, _sideBySide?: boolean): Promise<ICodeEditor | null> { return Promise.resolve(null); }
B
Benjamin Pasero 已提交
1123 1124
}

1125 1126 1127 1128
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

1129
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
S
SteVen Batten 已提交
1130
	onDidChangeMaximize: Event<boolean>;
1131

1132 1133
	hasFocus = true;

J
Johannes Rieken 已提交
1134
	isFocused(): Promise<boolean> {
B
Benjamin Pasero 已提交
1135
		return Promise.resolve(false);
1136 1137
	}

J
Johannes Rieken 已提交
1138
	isMaximized(): Promise<boolean> {
B
Benjamin Pasero 已提交
1139
		return Promise.resolve(false);
S
SteVen Batten 已提交
1140 1141
	}

1142 1143 1144 1145
	getConfiguration(): IWindowConfiguration {
		return Object.create(null);
	}

1146 1147 1148 1149
	getCurrentWindowId(): number {
		return 0;
	}

J
Johannes Rieken 已提交
1150
	pickFileFolderAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1151
		return Promise.resolve();
1152 1153
	}

J
Johannes Rieken 已提交
1154
	pickFileAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1155
		return Promise.resolve();
1156 1157
	}

J
Johannes Rieken 已提交
1158
	pickFolderAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1159
		return Promise.resolve();
1160 1161
	}

J
Johannes Rieken 已提交
1162
	pickWorkspaceAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1163
		return Promise.resolve();
1164 1165
	}

J
Johannes Rieken 已提交
1166
	reloadWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1167
		return Promise.resolve();
1168 1169
	}

J
Johannes Rieken 已提交
1170
	openDevTools(): Promise<void> {
B
Benjamin Pasero 已提交
1171
		return Promise.resolve();
1172 1173
	}

J
Johannes Rieken 已提交
1174
	toggleDevTools(): Promise<void> {
B
Benjamin Pasero 已提交
1175
		return Promise.resolve();
1176 1177
	}

J
Johannes Rieken 已提交
1178
	closeWorkspace(): Promise<void> {
B
Benjamin Pasero 已提交
1179
		return Promise.resolve();
1180 1181
	}

M
Matt Bierner 已提交
1182
	enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1183
		return Promise.resolve(undefined);
1184 1185
	}

J
Johannes Rieken 已提交
1186
	toggleFullScreen(): Promise<void> {
B
Benjamin Pasero 已提交
1187
		return Promise.resolve();
1188 1189
	}

J
Johannes Rieken 已提交
1190
	setRepresentedFilename(_fileName: string): Promise<void> {
B
Benjamin Pasero 已提交
1191
		return Promise.resolve();
1192 1193
	}

J
Johannes Rieken 已提交
1194
	getRecentlyOpened(): Promise<IRecentlyOpened> {
1195 1196 1197 1198
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1199 1200
	}

J
Johannes Rieken 已提交
1201
	focusWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1202
		return Promise.resolve();
1203 1204
	}

J
Johannes Rieken 已提交
1205
	maximizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1206
		return Promise.resolve();
S
SteVen Batten 已提交
1207 1208
	}

J
Johannes Rieken 已提交
1209
	unmaximizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1210
		return Promise.resolve();
S
SteVen Batten 已提交
1211 1212
	}

J
Johannes Rieken 已提交
1213
	minimizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1214
		return Promise.resolve();
S
SteVen Batten 已提交
1215 1216
	}

1217
	openWindow(_uris: IURIToOpen[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Promise<void> {
B
Benjamin Pasero 已提交
1218
		return Promise.resolve();
B
Benjamin Pasero 已提交
1219 1220
	}

J
Johannes Rieken 已提交
1221
	closeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1222
		return Promise.resolve();
1223 1224
	}

J
Johannes Rieken 已提交
1225
	setDocumentEdited(_flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1226
		return Promise.resolve();
1227 1228
	}

J
Johannes Rieken 已提交
1229
	onWindowTitleDoubleClick(): Promise<void> {
B
Benjamin Pasero 已提交
1230
		return Promise.resolve();
1231
	}
1232

J
Johannes Rieken 已提交
1233
	show(): Promise<void> {
B
Benjamin Pasero 已提交
1234
		return Promise.resolve();
J
Joao 已提交
1235 1236
	}

J
Johannes Rieken 已提交
1237
	showMessageBox(_options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
B
Benjamin Pasero 已提交
1238
		return Promise.resolve({ button: 0 });
1239 1240
	}

J
Johannes Rieken 已提交
1241
	showSaveDialog(_options: Electron.SaveDialogOptions): Promise<string> {
1242
		throw new Error('not implemented');
1243
	}
1244

J
Johannes Rieken 已提交
1245
	showOpenDialog(_options: Electron.OpenDialogOptions): Promise<string[]> {
1246
		throw new Error('not implemented');
1247
	}
1248

J
Johannes Rieken 已提交
1249
	updateTouchBar(_items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1250
		return Promise.resolve();
1251
	}
1252 1253

	resolveProxy(url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1254
		return Promise.resolve(undefined);
1255
	}
1256 1257
}

1258 1259
export class TestLifecycleService implements ILifecycleService {

1260
	public _serviceBrand: any;
1261

1262
	public phase: LifecyclePhase;
1263
	public startupKind: StartupKind;
1264

1265
	private _onBeforeShutdown = new Emitter<BeforeShutdownEvent>();
1266
	private _onWillShutdown = new Emitter<WillShutdownEvent>();
1267
	private _onShutdown = new Emitter<void>();
1268

J
Johannes Rieken 已提交
1269
	when(): Promise<void> {
B
Benjamin Pasero 已提交
1270
		return Promise.resolve();
B
Benjamin Pasero 已提交
1271
	}
1272

1273
	public fireShutdown(reason = ShutdownReason.QUIT): void {
1274
		this._onWillShutdown.fire({
1275 1276 1277
			join: () => { },
			reason
		});
1278 1279
	}

1280 1281 1282 1283 1284 1285
	public fireWillShutdown(event: BeforeShutdownEvent): void {
		this._onBeforeShutdown.fire(event);
	}

	public get onBeforeShutdown(): Event<BeforeShutdownEvent> {
		return this._onBeforeShutdown.event;
1286 1287
	}

1288
	public get onWillShutdown(): Event<WillShutdownEvent> {
1289 1290 1291
		return this._onWillShutdown.event;
	}

1292
	public get onShutdown(): Event<void> {
1293 1294
		return this._onShutdown.event;
	}
1295 1296
}

1297 1298 1299 1300
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1301 1302
	public windowCount = 1;

1303 1304
	onWindowOpen: Event<number>;
	onWindowFocus: Event<number>;
1305
	onWindowBlur: Event<number>;
S
SteVen Batten 已提交
1306 1307
	onWindowMaximize: Event<number>;
	onWindowUnmaximize: Event<number>;
S
SteVen Batten 已提交
1308
	onRecentlyOpenedChange: Event<void>;
1309

J
Johannes Rieken 已提交
1310
	isFocused(_windowId: number): Promise<boolean> {
B
Benjamin Pasero 已提交
1311
		return Promise.resolve(false);
1312 1313
	}

J
Johannes Rieken 已提交
1314
	pickFileFolderAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1315
		return Promise.resolve();
1316
	}
1317

J
Johannes Rieken 已提交
1318
	pickFileAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1319
		return Promise.resolve();
1320
	}
1321

J
Johannes Rieken 已提交
1322
	pickFolderAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1323
		return Promise.resolve();
1324
	}
1325

J
Johannes Rieken 已提交
1326
	pickWorkspaceAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1327
		return Promise.resolve();
1328 1329
	}

J
Johannes Rieken 已提交
1330
	reloadWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1331
		return Promise.resolve();
1332
	}
1333

J
Johannes Rieken 已提交
1334
	openDevTools(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1335
		return Promise.resolve();
1336
	}
1337

J
Johannes Rieken 已提交
1338
	toggleDevTools(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1339
		return Promise.resolve();
1340
	}
1341

J
Johannes Rieken 已提交
1342
	closeWorkspace(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1343
		return Promise.resolve();
1344
	}
1345

1346
	enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1347
		return Promise.resolve(undefined);
1348 1349
	}

J
Johannes Rieken 已提交
1350
	toggleFullScreen(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1351
		return Promise.resolve();
1352
	}
1353

J
Johannes Rieken 已提交
1354
	setRepresentedFilename(_windowId: number, _fileName: string): Promise<void> {
B
Benjamin Pasero 已提交
1355
		return Promise.resolve();
1356
	}
1357

1358
	addRecentlyOpened(_workspaces: URI[], _folders: URI[], _files: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1359
		return Promise.resolve();
1360
	}
1361

J
Johannes Rieken 已提交
1362
	removeFromRecentlyOpened(_paths: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1363
		return Promise.resolve();
1364
	}
1365

J
Johannes Rieken 已提交
1366
	clearRecentlyOpened(): Promise<void> {
B
Benjamin Pasero 已提交
1367
		return Promise.resolve();
C
22768  
Cristian 已提交
1368
	}
1369

J
Johannes Rieken 已提交
1370
	getRecentlyOpened(_windowId: number): Promise<IRecentlyOpened> {
1371 1372 1373 1374
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1375
	}
1376

J
Johannes Rieken 已提交
1377
	focusWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1378
		return Promise.resolve();
1379
	}
1380

J
Johannes Rieken 已提交
1381
	closeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1382
		return Promise.resolve();
1383 1384
	}

J
Johannes Rieken 已提交
1385
	isMaximized(_windowId: number): Promise<boolean> {
1386
		return Promise.resolve(false);
1387
	}
1388

J
Johannes Rieken 已提交
1389
	maximizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1390
		return Promise.resolve();
1391
	}
1392

J
Johannes Rieken 已提交
1393
	minimizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1394
		return Promise.resolve();
S
SteVen Batten 已提交
1395 1396
	}

J
Johannes Rieken 已提交
1397
	unmaximizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1398
		return Promise.resolve();
1399
	}
1400

J
Johannes Rieken 已提交
1401
	onWindowTitleDoubleClick(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1402
		return Promise.resolve();
1403
	}
1404

J
Johannes Rieken 已提交
1405
	setDocumentEdited(_windowId: number, _flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1406
		return Promise.resolve();
1407
	}
1408

J
Johannes Rieken 已提交
1409
	quit(): Promise<void> {
B
Benjamin Pasero 已提交
1410
		return Promise.resolve();
1411
	}
1412

J
Johannes Rieken 已提交
1413
	relaunch(_options: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
B
Benjamin Pasero 已提交
1414
		return Promise.resolve();
J
Johannes Rieken 已提交
1415
	}
1416

J
Johannes Rieken 已提交
1417
	whenSharedProcessReady(): Promise<void> {
B
Benjamin Pasero 已提交
1418
		return Promise.resolve();
1419
	}
1420

J
Johannes Rieken 已提交
1421
	toggleSharedProcess(): Promise<void> {
B
Benjamin Pasero 已提交
1422
		return Promise.resolve();
1423
	}
1424

1425
	// Global methods
1426
	openWindow(_windowId: number, _uris: IURIToOpen[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Promise<void> {
B
Benjamin Pasero 已提交
1427
		return Promise.resolve();
1428
	}
1429

J
Johannes Rieken 已提交
1430
	openNewWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1431
		return Promise.resolve();
1432
	}
1433

J
Johannes Rieken 已提交
1434
	showWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1435
		return Promise.resolve();
1436
	}
1437

J
Johannes Rieken 已提交
1438
	getWindows(): Promise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> {
1439
		throw new Error('not implemented');
1440
	}
1441

J
Johannes Rieken 已提交
1442
	getWindowCount(): Promise<number> {
B
Benjamin Pasero 已提交
1443
		return Promise.resolve(this.windowCount);
1444
	}
1445

J
Johannes Rieken 已提交
1446
	log(_severity: string, ..._messages: string[]): Promise<void> {
B
Benjamin Pasero 已提交
1447
		return Promise.resolve();
1448
	}
1449

M
Martin Aeschlimann 已提交
1450
	showItemInFolder(_path: URI): Promise<void> {
B
Benjamin Pasero 已提交
1451
		return Promise.resolve();
1452 1453
	}

J
Johannes Rieken 已提交
1454
	newWindowTab(): Promise<void> {
B
Benjamin Pasero 已提交
1455
		return Promise.resolve();
1456 1457
	}

J
Johannes Rieken 已提交
1458
	showPreviousWindowTab(): Promise<void> {
B
Benjamin Pasero 已提交
1459
		return Promise.resolve();
1460 1461
	}

J
Johannes Rieken 已提交
1462
	showNextWindowTab(): Promise<void> {
B
Benjamin Pasero 已提交
1463
		return Promise.resolve();
1464 1465
	}

J
Johannes Rieken 已提交
1466
	moveWindowTabToNewWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1467
		return Promise.resolve();
1468 1469
	}

J
Johannes Rieken 已提交
1470
	mergeAllWindowTabs(): Promise<void> {
B
Benjamin Pasero 已提交
1471
		return Promise.resolve();
1472 1473
	}

J
Johannes Rieken 已提交
1474
	toggleWindowTabsBar(): Promise<void> {
B
Benjamin Pasero 已提交
1475
		return Promise.resolve();
1476 1477
	}

J
Johannes Rieken 已提交
1478
	updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1479
		return Promise.resolve();
1480 1481
	}

J
Johannes Rieken 已提交
1482
	getActiveWindowId(): Promise<number | undefined> {
B
Benjamin Pasero 已提交
1483
		return Promise.resolve(undefined);
J
Joao Moreno 已提交
1484 1485
	}

1486 1487
	// This needs to be handled from browser process to prevent
	// foreground ordering issues on Windows
J
Johannes Rieken 已提交
1488
	openExternal(_url: string): Promise<boolean> {
B
Benjamin Pasero 已提交
1489
		return Promise.resolve(true);
1490 1491 1492
	}

	// TODO: this is a bit backwards
J
Johannes Rieken 已提交
1493
	startCrashReporter(_config: Electron.CrashReporterStartOptions): Promise<void> {
B
Benjamin Pasero 已提交
1494
		return Promise.resolve();
1495
	}
1496

J
Johannes Rieken 已提交
1497
	showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
1498
		throw new Error('not implemented');
1499 1500
	}

J
Johannes Rieken 已提交
1501
	showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): Promise<string> {
1502
		throw new Error('not implemented');
1503 1504
	}

J
Johannes Rieken 已提交
1505
	showOpenDialog(_windowId: number, _options: Electron.OpenDialogOptions): Promise<string[]> {
1506
		throw new Error('not implemented');
1507
	}
J
Joao Moreno 已提交
1508

J
Johannes Rieken 已提交
1509
	openAboutDialog(): Promise<void> {
B
Benjamin Pasero 已提交
1510
		return Promise.resolve();
J
Joao Moreno 已提交
1511
	}
1512 1513

	resolveProxy(windowId: number, url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1514
		return Promise.resolve(undefined);
1515
	}
1516
}
B
Benjamin Pasero 已提交
1517

1518 1519 1520 1521 1522 1523 1524
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1525
	public onDidChangeConfiguration() {
1526 1527 1528
		return { dispose() { } };
	}

1529
	getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
1530 1531
		const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;
		const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
1532
		return this.configurationService.getValue(section, { resource });
1533
	}
B
Benjamin Pasero 已提交
1534 1535
}

S
Sandeep Somavarapu 已提交
1536 1537 1538 1539 1540
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

	_serviceBrand: any;

	constructor(
1541
		@IConfigurationService private readonly configurationService: IConfigurationService,
S
Sandeep Somavarapu 已提交
1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556
	) {
	}

	getEOL(resource: URI): string {
		const filesConfiguration = this.configurationService.getValue<{ eol: string }>('files');
		if (filesConfiguration && filesConfiguration.eol) {
			if (filesConfiguration.eol !== 'auto') {
				return filesConfiguration.eol;
			}
		}
		return (isLinux || isMacintosh) ? '\n' : '\r\n';
	}
}


R
Ramya Achutha Rao 已提交
1557 1558 1559 1560 1561 1562
export class TestHashService implements IHashService {
	_serviceBrand: any;

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