workbenchTestServices.ts 46.7 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/parts/files/electron-browser/files.contribution'; // load our contribution into the test
S
Sandeep Somavarapu 已提交
7
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
8
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
9
import * as paths from 'vs/base/common/paths';
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';
B
Benjamin Pasero 已提交
14
import { ConfirmResult, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent } from 'vs/workbench/common/editor';
B
Benjamin Pasero 已提交
15
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, EditorGroupsServiceImpl } 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';
20
import { IPartService, Parts, Position as PartPosition, IDimension } from 'vs/workbench/services/part/common/partService';
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';
S
SteVen Batten 已提交
40
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, MenuBarVisibility } 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 46
import { generateUuid } from 'vs/base/common/uuid';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
47
import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
B
Benjamin Pasero 已提交
48
import { IRecentlyOpened } from 'vs/platform/history/common/history';
S
Sandeep Somavarapu 已提交
49
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
50
import { IPosition, Position as EditorPosition } from 'vs/editor/common/core/position';
B
Benjamin Pasero 已提交
51
import { IMenuService, MenuId, IMenu, ISerializableCommandAction } from 'vs/platform/actions/common/actions';
R
Ramya Achutha Rao 已提交
52
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
I
isidor 已提交
53
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
B
Benjamin Pasero 已提交
54
import { MockContextKeyService, MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
B
Benjamin Pasero 已提交
55
import { ITextBufferFactory, DefaultEndOfLine, EndOfLinePreference, IModelDecorationOptions, ITextModel } from 'vs/editor/common/model';
56
import { Range } from 'vs/editor/common/core/range';
M
Martin Aeschlimann 已提交
57
import { IConfirmation, IConfirmationResult, IDialogService, IDialogOptions, IPickAndOpenOptions, ISaveDialogOptions, IOpenDialogOptions, IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
58 59
import { INotificationService } from 'vs/platform/notification/common/notification';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
60
import { IExtensionService, ProfileSession, IExtensionsStatus, ExtensionPointContribution, IExtensionDescription, IWillActivateEvent, IResponsiveStateChangeEvent } from '../services/extensions/common/extensions';
B
Benjamin Pasero 已提交
61
import { IExtensionPoint } from 'vs/workbench/services/extensions/common/extensionsRegistry';
B
Benjamin Pasero 已提交
62
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
B
Benjamin Pasero 已提交
63
import { IDecorationsService, IResourceDecorationChangeEvent, IDecoration, IDecorationData, IDecorationsProvider } from 'vs/workbench/services/decorations/browser/decorations';
J
Joao Moreno 已提交
64
import { IDisposable, toDisposable, Disposable } from 'vs/base/common/lifecycle';
65
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, EditorsOrder, IFindGroupScope, EditorGroupLayout } from 'vs/workbench/services/group/common/editorGroupsService';
66
import { IEditorService, IOpenEditorOverrideHandler } from 'vs/workbench/services/editor/common/editorService';
B
Benjamin Pasero 已提交
67 68 69
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 已提交
70
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
71
import { Dimension } from 'vs/base/browser/dom';
72
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
I
isidor 已提交
73
import { ILabelService, LabelService } from 'vs/platform/label/common/label';
74
import { timeout } from 'vs/base/common/async';
75 76 77 78
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ViewletDescriptor } from 'vs/workbench/browser/viewlet';
import { IViewlet } from 'vs/workbench/common/viewlet';
import { IProgressService } from 'vs/platform/progress/common/progress';
79
import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/common/storage';
S
Sandeep Somavarapu 已提交
80
import { isLinux, isMacintosh } from 'vs/base/common/platform';
81
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
B
Benjamin Pasero 已提交
82

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

87
export const TestEnvironmentService = new EnvironmentService(parseArgs(process.argv), process.execPath);
88

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

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

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

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

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

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

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

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

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

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

131
		return WorkbenchState.EMPTY;
S
Sandeep Somavarapu 已提交
132 133
	}

134
	public getWorkspace(): IWorkbenchWorkspace {
B
Benjamin Pasero 已提交
135
		return this.workspace;
136 137
	}

S
Sandeep Somavarapu 已提交
138
	public getWorkspaceFolder(resource: URI): IWorkspaceFolder {
S
Sandeep Somavarapu 已提交
139
		return this.workspace.getFolder(resource);
140 141
	}

D
Daniel Imms 已提交
142 143 144 145
	public setWorkspace(workspace: any): void {
		this.workspace = workspace;
	}

E
Erich Gamma 已提交
146 147 148 149 150 151 152 153 154 155
	public getOptions() {
		return this.options;
	}

	public updateOptions() {

	}

	public isInsideWorkspace(resource: URI): boolean {
		if (resource && this.workspace) {
156
			return resources.isEqualOrParent(resource, this.workspace.folders[0].uri);
E
Erich Gamma 已提交
157 158 159 160 161 162
		}

		return false;
	}

	public toResource(workspaceRelativePath: string): URI {
163
		return URI.file(paths.join('C:\\', workspaceRelativePath));
E
Erich Gamma 已提交
164
	}
165

166
	public isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean {
167
		return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && resources.isEqual(this.workspace.folders[0].uri, workspaceIdentifier);
168
	}
E
Erich Gamma 已提交
169 170
}

171
export class TestTextFileService extends TextFileService {
172 173
	public cleanupBackupsBeforeShutdownCalled: boolean;

M
Martin Aeschlimann 已提交
174
	private promptPath: URI;
175
	private confirmResult: ConfirmResult;
176
	private resolveTextContentError: FileOperationError;
A
Alex Dima 已提交
177 178

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

M
Martin Aeschlimann 已提交
196
	public setPromptPath(path: URI): void {
197 198 199 200 201 202 203
		this.promptPath = path;
	}

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

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

J
Johannes Rieken 已提交
208
	public resolveTextContent(resource: URI, options?: IResolveContentOptions): Promise<IRawTextContent> {
209 210 211 212
		if (this.resolveTextContentError) {
			const error = this.resolveTextContentError;
			this.resolveTextContentError = null;

B
Benjamin Pasero 已提交
213
			return Promise.reject(error);
214 215
		}

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

J
Johannes Rieken 已提交
228
	public promptForPath(_resource: URI, _defaultPath: URI): Promise<URI> {
B
Benjamin Pasero 已提交
229
		return Promise.resolve(this.promptPath);
230 231
	}

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

236 237
	public onFilesConfigurationChange(configuration: any): void {
		super.onFilesConfigurationChange(configuration);
238 239
	}

J
Johannes Rieken 已提交
240
	protected cleanupBackupsBeforeShutdown(): Promise<void> {
241
		this.cleanupBackupsBeforeShutdownCalled = true;
B
Benjamin Pasero 已提交
242
		return Promise.resolve();
243
	}
A
Alex Dima 已提交
244 245
}

246
export function workbenchInstantiationService(): IInstantiationService {
247
	let instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
I
isidor 已提交
248
	instantiationService.stub(IContextKeyService, <IContextKeyService>instantiationService.createInstance(MockContextKeyService));
I
isidor 已提交
249 250
	const workspaceContextService = new TestContextService(TestWorkspace);
	instantiationService.stub(IWorkspaceContextService, workspaceContextService);
251 252 253
	const configService = new TestConfigurationService();
	instantiationService.stub(IConfigurationService, configService);
	instantiationService.stub(ITextResourceConfigurationService, new TestTextResourceConfigurationService(configService));
254
	instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
255
	instantiationService.stub(IStorageService, new TestStorageService());
256
	instantiationService.stub(IPartService, new TestPartService());
J
Johannes Rieken 已提交
257
	instantiationService.stub(IModeService, instantiationService.createInstance(ModeServiceImpl));
B
Benjamin Pasero 已提交
258
	instantiationService.stub(IHistoryService, new TestHistoryService());
S
Sandeep Somavarapu 已提交
259
	instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(configService));
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());
I
isidor 已提交
277
	instantiationService.stub(ILogService, new TestLogService());
278
	instantiationService.stub(IEditorGroupsService, new TestEditorGroupsService([new TestEditorGroup(0)]));
M
Martin Aeschlimann 已提交
279
	instantiationService.stub(ILabelService, <ILabelService>instantiationService.createInstance(LabelService));
B
Benjamin Pasero 已提交
280
	const editorService = new TestEditorService();
281
	instantiationService.stub(IEditorService, editorService);
B
Benjamin Pasero 已提交
282
	instantiationService.stub(ICodeEditorService, new TestCodeEditorService());
283
	instantiationService.stub(IViewletService, new TestViewletService());
284 285 286 287

	return instantiationService;
}

I
isidor 已提交
288 289 290
export class TestLogService implements ILogService {
	_serviceBrand: any; onDidChangeLogLevel: Event<LogLevel>;
	getLevel(): LogLevel { return LogLevel.Info; }
291 292 293 294 295 296 297
	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 已提交
298 299 300
	dispose(): void { }
}

B
Benjamin Pasero 已提交
301 302 303
export class TestDecorationsService implements IDecorationsService {
	_serviceBrand: any;
	onDidChangeDecorations: Event<IResourceDecorationChangeEvent> = Event.None;
304
	registerDecorationsProvider(_provider: IDecorationsProvider): IDisposable { return Disposable.None; }
R
Rob Lourens 已提交
305
	getDecoration(_uri: URI, _includeChildren: boolean, _overwrite?: IDecorationData): IDecoration { return undefined; }
B
Benjamin Pasero 已提交
306 307 308 309 310
}

export class TestExtensionService implements IExtensionService {
	_serviceBrand: any;
	onDidRegisterExtensions: Event<void> = Event.None;
311
	onDidChangeExtensionsStatus: Event<ExtensionIdentifier[]> = Event.None;
312
	onWillActivateByEvent: Event<IWillActivateEvent> = Event.None;
313
	onDidChangeResponsiveChange: Event<IResponsiveStateChangeEvent> = Event.None;
R
Rob Lourens 已提交
314
	activateByEvent(_activationEvent: string): Promise<void> { return Promise.resolve(undefined); }
A
Alex Dima 已提交
315 316
	whenInstalledExtensionsRegistered(): Promise<boolean> { return Promise.resolve(true); }
	getExtensions(): Promise<IExtensionDescription[]> { return Promise.resolve([]); }
317
	getExtension() { return Promise.resolve(undefined); }
A
Alex Dima 已提交
318
	readExtensionPointContributions<T>(_extPoint: IExtensionPoint<T>): Promise<ExtensionPointContribution<T>[]> { return Promise.resolve(Object.create(null)); }
B
Benjamin Pasero 已提交
319 320
	getExtensionsStatus(): { [id: string]: IExtensionsStatus; } { return Object.create(null); }
	canProfileExtensionHost(): boolean { return false; }
321
	getInspectPort(): number { return 0; }
A
Alex Dima 已提交
322
	startExtensionHostProfile(): Promise<ProfileSession> { return Promise.resolve(Object.create(null)); }
B
Benjamin Pasero 已提交
323 324 325 326 327 328 329 330 331
	restartExtensionHost(): void { }
	startExtensionHost(): void { }
	stopExtensionHost(): void { }
}

export class TestMenuService implements IMenuService {

	public _serviceBrand: any;

332
	createMenu(_id: MenuId, _scopedKeybindingService: IContextKeyService): IMenu {
B
Benjamin Pasero 已提交
333 334
		return {
			onDidChange: Event.None,
R
Rob Lourens 已提交
335
			dispose: () => undefined,
B
Benjamin Pasero 已提交
336 337 338 339 340
			getActions: () => []
		};
	}
}

B
Benjamin Pasero 已提交
341 342 343 344 345 346 347 348 349 350
export class TestHistoryService implements IHistoryService {

	public _serviceBrand: any;

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

351
	public forward(_acrossEditors?: boolean): void {
B
Benjamin Pasero 已提交
352 353
	}

354
	public back(_acrossEditors?: boolean): void {
B
Benjamin Pasero 已提交
355 356
	}

357 358 359
	public last(): void {
	}

360
	public remove(_input: IEditorInput | IResourceInput): void {
B
Benjamin Pasero 已提交
361 362 363 364 365
	}

	public clear(): void {
	}

B
Benjamin Pasero 已提交
366 367 368
	public clearRecentlyOpened(): void {
	}

369
	public getHistory(): Array<IEditorInput | IResourceInput> {
B
Benjamin Pasero 已提交
370 371 372
		return [];
	}

373
	public getLastActiveWorkspaceRoot(_schemeFilter: string): URI {
B
Benjamin Pasero 已提交
374 375
		return this.root;
	}
376

377
	public getLastActiveFile(_schemeFilter: string): URI {
R
Rob Lourens 已提交
378
		return undefined;
379
	}
B
Benjamin Pasero 已提交
380 381 382

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

385
export class TestDialogService implements IDialogService {
386 387

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

J
Johannes Rieken 已提交
389
	public confirm(_confirmation: IConfirmation): Promise<IConfirmationResult> {
B
Benjamin Pasero 已提交
390
		return Promise.resolve({ confirmed: false });
391
	}
392

J
Johannes Rieken 已提交
393
	public show(_severity: Severity, _message: string, _buttons: string[], _options?: IDialogOptions): Promise<number> {
B
Benjamin Pasero 已提交
394
		return Promise.resolve(0);
395
	}
E
Erich Gamma 已提交
396 397
}

M
Martin Aeschlimann 已提交
398 399 400 401
export class TestFileDialogService implements IFileDialogService {

	public _serviceBrand: any;

402
	public defaultFilePath(_schemeFilter: string): URI {
R
Rob Lourens 已提交
403
		return undefined;
M
Martin Aeschlimann 已提交
404
	}
405
	public defaultFolderPath(_schemeFilter: string): URI {
R
Rob Lourens 已提交
406
		return undefined;
M
Martin Aeschlimann 已提交
407
	}
408
	public defaultWorkspacePath(_schemeFilter: string): URI {
R
Rob Lourens 已提交
409
		return undefined;
M
Martin Aeschlimann 已提交
410
	}
J
Johannes Rieken 已提交
411
	public pickFileFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
412
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
413
	}
J
Johannes Rieken 已提交
414
	public pickFileAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
415
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
416
	}
J
Johannes Rieken 已提交
417
	public pickFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
418
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
419
	}
J
Johannes Rieken 已提交
420
	public pickWorkspaceAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
421
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
422
	}
J
Johannes Rieken 已提交
423
	public showSaveDialog(_options: ISaveDialogOptions): Promise<URI> {
B
Benjamin Pasero 已提交
424
		return Promise.resolve();
M
Martin Aeschlimann 已提交
425
	}
J
Johannes Rieken 已提交
426
	public showOpenDialog(_options: IOpenDialogOptions): Promise<URI[]> {
B
Benjamin Pasero 已提交
427
		return Promise.resolve();
M
Martin Aeschlimann 已提交
428 429 430
	}
}

431
export class TestPartService implements IPartService {
B
Benjamin Pasero 已提交
432

433
	public _serviceBrand: any;
E
Erich Gamma 已提交
434

435
	private _onTitleBarVisibilityChange = new Emitter<void>();
436
	private _onMenubarVisibilityChange = new Emitter<Dimension>();
437
	private _onEditorLayout = new Emitter<IDimension>();
438 439 440 441 442

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

443 444 445 446
	public get onMenubarVisibilityChange(): Event<Dimension> {
		return this._onMenubarVisibilityChange.event;
	}

447
	public get onEditorLayout(): Event<IDimension> {
448 449 450
		return this._onEditorLayout.event;
	}

B
Benjamin Pasero 已提交
451
	public isRestored(): boolean {
E
Erich Gamma 已提交
452 453 454
		return true;
	}

455
	public hasFocus(_part: Parts): boolean {
E
Erich Gamma 已提交
456 457 458
		return false;
	}

459
	public isVisible(_part: Parts): boolean {
E
Erich Gamma 已提交
460 461 462
		return true;
	}

463
	public getContainer(_part: Parts): HTMLElement {
464 465 466
		return null;
	}

B
Benjamin Pasero 已提交
467 468 469 470
	public isTitleBarHidden(): boolean {
		return false;
	}

471 472 473 474
	public getTitleBarOffset(): number {
		return 0;
	}

475 476 477 478
	public isStatusBarHidden(): boolean {
		return false;
	}

S
Sanders Lauture 已提交
479 480 481 482
	public isActivityBarHidden(): boolean {
		return false;
	}

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

E
Erich Gamma 已提交
485 486 487 488
	public isSideBarHidden(): boolean {
		return false;
	}

J
Johannes Rieken 已提交
489
	public setSideBarHidden(_hidden: boolean): Promise<void> { return Promise.resolve(null); }
E
Erich Gamma 已提交
490

I
isidor 已提交
491
	public isPanelHidden(): boolean {
I
isidor 已提交
492 493 494
		return false;
	}

J
Johannes Rieken 已提交
495
	public setPanelHidden(_hidden: boolean): Promise<void> { return Promise.resolve(null); }
I
isidor 已提交
496

I
isidor 已提交
497 498
	public toggleMaximizedPanel(): void { }

B
Benjamin Pasero 已提交
499 500 501 502
	public isPanelMaximized(): boolean {
		return false;
	}

S
SteVen Batten 已提交
503 504 505 506
	public getMenubarVisibility(): MenuBarVisibility {
		return null;
	}

E
Erich Gamma 已提交
507 508 509 510
	public getSideBarPosition() {
		return 0;
	}

I
isidor 已提交
511 512 513 514
	public getPanelPosition() {
		return 0;
	}

J
Johannes Rieken 已提交
515
	public setPanelPosition(_position: PartPosition): Promise<void> {
B
Benjamin Pasero 已提交
516
		return Promise.resolve(null);
I
isidor 已提交
517 518
	}

519 520
	public addClass(_clazz: string): void { }
	public removeClass(_clazz: string): void { }
R
Rob Lourens 已提交
521
	public getWorkbenchElement(): HTMLElement { return undefined; }
B
Benjamin Pasero 已提交
522

I
isidor 已提交
523
	public toggleZenMode(): void { }
524

B
Benjamin Pasero 已提交
525
	public isEditorLayoutCentered(): boolean { return false; }
526
	public centerEditorLayout(_active: boolean): void { }
S
SrTobi 已提交
527 528


529
	public resizePart(_part: Parts, _sizeChange: number): void { }
E
Erich Gamma 已提交
530 531
}

532
export class TestStorageService extends InMemoryStorageService { }
533

B
Benjamin Pasero 已提交
534
export class TestEditorGroupsService implements EditorGroupsServiceImpl {
535 536
	_serviceBrand: ServiceIdentifier<any>;

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

539 540 541 542
	onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
	onDidAddGroup: Event<IEditorGroup> = Event.None;
	onDidRemoveGroup: Event<IEditorGroup> = Event.None;
	onDidMoveGroup: Event<IEditorGroup> = Event.None;
543 544

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

547
	get activeGroup(): IEditorGroup {
548 549 550 551 552 553 554
		return this.groups[0];
	}

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

555
	getGroups(_order?: GroupsOrder): ReadonlyArray<IEditorGroup> {
556 557 558
		return this.groups;
	}

559
	getGroup(identifier: number): IEditorGroup {
560 561 562
		for (const group of this.groups) {
			if (group.id === identifier) {
				return group;
563 564 565
			}
		}

R
Rob Lourens 已提交
566
		return undefined;
567 568
	}

569
	getLabel(_identifier: number): string {
570 571 572
		return 'Group 1';
	}

573
	findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup {
574 575 576
		return null;
	}

577
	activateGroup(_group: number | IEditorGroup): IEditorGroup {
578 579 580
		return null;
	}

581
	getSize(_group: number | IEditorGroup): number {
582
		return 100;
583 584
	}

585
	setSize(_group: number | IEditorGroup, _size: number): void { }
586

587
	arrangeGroups(_arrangement: GroupsArrangement): void { }
588

589
	applyLayout(_layout: EditorGroupLayout): void { }
590

591
	setGroupOrientation(_orientation: any): void { }
592

593
	addGroup(_location: number | IEditorGroup, _direction: GroupDirection, _options?: IAddGroupOptions): IEditorGroup {
594 595 596
		return null;
	}

597
	removeGroup(_group: number | IEditorGroup): void { }
598

599
	moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
600 601 602
		return null;
	}

603
	mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup {
604 605 606
		return null;
	}

607
	copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
608 609 610 611
		return null;
	}
}

B
Benjamin Pasero 已提交
612
export class TestEditorGroup implements IEditorGroupView {
613 614 615

	constructor(public id: number) { }

R
Rob Lourens 已提交
616
	group: EditorGroup = undefined;
617 618 619 620
	activeControl: IEditor;
	activeEditor: IEditorInput;
	previewEditor: IEditorInput;
	count: number;
B
Benjamin Pasero 已提交
621
	disposed: boolean;
B
Benjamin Pasero 已提交
622
	editors: ReadonlyArray<IEditorInput> = [];
623
	label: string;
R
Rob Lourens 已提交
624
	whenRestored: Promise<void> = Promise.resolve(undefined);
B
Benjamin Pasero 已提交
625 626 627 628 629
	element: HTMLElement;
	minimumWidth: number;
	maximumWidth: number;
	minimumHeight: number;
	maximumHeight: number;
630 631

	onWillDispose: Event<void> = Event.None;
632
	onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
B
Benjamin Pasero 已提交
633 634
	onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
635 636
	onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
	onDidOpenEditorFail: Event<IEditorInput> = Event.None;
B
Benjamin Pasero 已提交
637 638
	onDidFocus: Event<void> = Event.None;
	onDidChange: Event<{ width: number; height: number; }> = Event.None;
639

640
	getEditors(_order?: EditorsOrder): ReadonlyArray<IEditorInput> {
B
Benjamin Pasero 已提交
641 642 643
		return [];
	}

644
	getEditor(_index: number): IEditorInput {
645 646 647
		return null;
	}

648
	getIndexOfEditor(_editor: IEditorInput): number {
649 650 651
		return -1;
	}

J
Johannes Rieken 已提交
652
	openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditor> {
B
Benjamin Pasero 已提交
653
		return Promise.resolve(null);
654 655
	}

J
Johannes Rieken 已提交
656
	openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditor> {
B
Benjamin Pasero 已提交
657
		return Promise.resolve(null);
658 659
	}

660
	isOpened(_editor: IEditorInput): boolean {
661 662 663
		return false;
	}

664
	isPinned(_editor: IEditorInput): boolean {
665 666 667
		return false;
	}

668
	isActive(_editor: IEditorInput): boolean {
669 670 671
		return false;
	}

672
	moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
673

674
	copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
675

J
Johannes Rieken 已提交
676
	closeEditor(_editor?: IEditorInput): Promise<void> {
B
Benjamin Pasero 已提交
677
		return Promise.resolve();
678 679
	}

J
Johannes Rieken 已提交
680
	closeEditors(_editors: IEditorInput[] | { except?: IEditorInput; direction?: CloseDirection; savedOnly?: boolean; }): Promise<void> {
B
Benjamin Pasero 已提交
681
		return Promise.resolve();
682 683
	}

J
Johannes Rieken 已提交
684
	closeAllEditors(): Promise<void> {
B
Benjamin Pasero 已提交
685
		return Promise.resolve();
686 687
	}

J
Johannes Rieken 已提交
688
	replaceEditors(_editors: IEditorReplacement[]): Promise<void> {
B
Benjamin Pasero 已提交
689
		return Promise.resolve();
690 691
	}

692
	pinEditor(_editor?: IEditorInput): void { }
693 694 695 696 697 698

	focus(): void { }

	invokeWithinContext<T>(fn: (accessor: ServicesAccessor) => T): T {
		return fn(null);
	}
B
Benjamin Pasero 已提交
699 700

	isEmpty(): boolean { return true; }
701 702
	setActive(_isActive: boolean): void { }
	setLabel(_label: string): void { }
B
Benjamin Pasero 已提交
703 704
	dispose(): void { }
	toJSON(): object { return Object.create(null); }
705
	layout(_width: number, _height: number): void { }
706
	relayout() { }
707 708
}

B
Benjamin Pasero 已提交
709
export class TestEditorService implements EditorServiceImpl {
710 711 712 713 714

	_serviceBrand: ServiceIdentifier<any>;

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
715
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
716 717 718
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

	activeControl: IEditor;
719
	activeTextEditorWidget: any;
720
	activeEditor: IEditorInput;
721
	editors: ReadonlyArray<IEditorInput> = [];
B
Benjamin Pasero 已提交
722
	visibleControls: ReadonlyArray<IEditor> = [];
723
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
724
	visibleEditors: ReadonlyArray<IEditorInput> = [];
725

726
	overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
R
Rob Lourens 已提交
727
		return toDisposable(() => undefined);
728 729
	}

730
	openEditor(_editor: any, _options?: any, _group?: any) {
B
Benjamin Pasero 已提交
731
		return Promise.resolve(null);
732 733
	}

734
	openEditors(_editors: any, _group?: any) {
B
Benjamin Pasero 已提交
735
		return Promise.resolve(null);
736 737
	}

738
	isOpen(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
739 740 741
		return false;
	}

742
	getOpened(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): IEditorInput {
R
Rob Lourens 已提交
743
		return undefined;
744 745
	}

746
	replaceEditors(_editors: any, _group: any) {
R
Rob Lourens 已提交
747
		return Promise.resolve(undefined);
748 749
	}

750 751 752 753
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
		return fn(null);
	}

754
	createInput(_input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
755 756 757 758
		return null;
	}
}

759 760 761 762
export class TestFileService implements IFileService {

	public _serviceBrand: any;

763 764
	public encoding: IResourceEncodings;

M
Matt Bierner 已提交
765 766
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
767

768 769
	private content = 'Hello Html';

770 771 772 773 774
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

775 776 777 778 779 780 781 782
	public setContent(content: string): void {
		this.content = content;
	}

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

783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798
	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 已提交
799
	resolveFile(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat> {
B
Benjamin Pasero 已提交
800
		return Promise.resolve({
801 802
			resource,
			etag: Date.now().toString(),
B
Benjamin Pasero 已提交
803
			encoding: 'utf8',
B
Benjamin Pasero 已提交
804
			mtime: Date.now(),
805
			isDirectory: false,
B
Benjamin Pasero 已提交
806 807
			name: paths.basename(resource.fsPath)
		});
808
	}
B
Benjamin Pasero 已提交
809

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

J
Johannes Rieken 已提交
814
	existsFile(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
815
		return Promise.resolve(null);
816
	}
B
Benjamin Pasero 已提交
817

J
Johannes Rieken 已提交
818
	resolveContent(resource: URI, _options?: IResolveContentOptions): Promise<IContent> {
B
Benjamin Pasero 已提交
819
		return Promise.resolve({
B
Benjamin Pasero 已提交
820
			resource: resource,
821
			value: this.content,
822
			etag: 'index.txt',
B
Benjamin Pasero 已提交
823 824
			encoding: 'utf8',
			mtime: Date.now(),
825
			name: paths.basename(resource.fsPath)
E
Erich Gamma 已提交
826
		});
827
	}
E
Erich Gamma 已提交
828

J
Johannes Rieken 已提交
829
	resolveStreamContent(resource: URI, _options?: IResolveContentOptions): Promise<IStreamContent> {
B
Benjamin Pasero 已提交
830
		return Promise.resolve({
A
Alex Dima 已提交
831 832
			resource: resource,
			value: {
833
				on: (event: string, callback: Function): void => {
A
Alex Dima 已提交
834
					if (event === 'data') {
835
						callback(this.content);
A
Alex Dima 已提交
836 837 838 839 840 841 842 843
					}
					if (event === 'end') {
						callback();
					}
				}
			},
			etag: 'index.txt',
			encoding: 'utf8',
B
Benjamin Pasero 已提交
844
			mtime: Date.now(),
845
			name: paths.basename(resource.fsPath)
A
Alex Dima 已提交
846
		});
847 848
	}

J
Johannes Rieken 已提交
849
	updateContent(resource: URI, _value: string | ITextSnapshot, _options?: IUpdateContentOptions): Promise<IFileStat> {
B
Benjamin Pasero 已提交
850
		return timeout(0).then(() => ({
851 852 853 854 855 856
			resource,
			etag: 'index.txt',
			encoding: 'utf8',
			mtime: Date.now(),
			isDirectory: false,
			name: paths.basename(resource.fsPath)
B
Benjamin Pasero 已提交
857
		}));
858
	}
D
Daniel Imms 已提交
859

J
Johannes Rieken 已提交
860
	moveFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStat> {
B
Benjamin Pasero 已提交
861
		return Promise.resolve(null);
862
	}
D
Daniel Imms 已提交
863

J
Johannes Rieken 已提交
864
	copyFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStat> {
B
Benjamin Pasero 已提交
865
		return Promise.resolve(null);
866
	}
D
Daniel Imms 已提交
867

J
Johannes Rieken 已提交
868
	createFile(_resource: URI, _content?: string, _options?: ICreateFileOptions): Promise<IFileStat> {
B
Benjamin Pasero 已提交
869
		return Promise.resolve(null);
E
Erich Gamma 已提交
870
	}
871

C
Christof Marti 已提交
872
	readFolder(_resource: URI) {
B
Benjamin Pasero 已提交
873
		return Promise.resolve([]);
C
Christof Marti 已提交
874 875
	}

J
Johannes Rieken 已提交
876
	createFolder(_resource: URI): Promise<IFileStat> {
B
Benjamin Pasero 已提交
877
		return Promise.resolve(null);
878 879
	}

880 881
	onDidChangeFileSystemProviderRegistrations = Event.None;

882
	registerProvider(_scheme: string, _provider) {
883 884 885
		return { dispose() { } };
	}

886
	activateProvider(_scheme: string) {
B
Benjamin Pasero 已提交
887
		return Promise.resolve(null);
888 889
	}

890 891 892 893
	canHandleResource(resource: URI): boolean {
		return resource.scheme === 'file';
	}

J
Johannes Rieken 已提交
894
	del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
B
Benjamin Pasero 已提交
895
		return Promise.resolve(null);
896 897
	}

898
	watchFileChanges(_resource: URI): void {
899 900
	}

901
	unwatchFileChanges(_resource: URI): void {
902 903
	}

904
	getWriteEncoding(_resource: URI): string {
905 906
		return 'utf8';
	}
D
Daniel Imms 已提交
907

908
	dispose(): void {
E
Erich Gamma 已提交
909
	}
910
}
911

912 913
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
914

J
Johannes Rieken 已提交
915
	public hasBackups(): Promise<boolean> {
B
Benjamin Pasero 已提交
916
		return Promise.resolve(false);
917 918
	}

J
Johannes Rieken 已提交
919
	public hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
920
		return Promise.resolve(false);
921 922
	}

J
Johannes Rieken 已提交
923
	public loadBackupResource(resource: URI): Promise<URI> {
B
Benjamin Pasero 已提交
924 925
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
926
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
927 928
			}

R
Rob Lourens 已提交
929
			return undefined;
B
Benjamin Pasero 已提交
930 931 932
		});
	}

J
Johannes Rieken 已提交
933
	public registerResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
934
		return Promise.resolve();
D
Daniel Imms 已提交
935 936
	}

J
Johannes Rieken 已提交
937
	public deregisterResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
938
		return Promise.resolve();
D
Daniel Imms 已提交
939 940
	}

941
	public toBackupResource(_resource: URI): URI {
D
Daniel Imms 已提交
942 943
		return null;
	}
944

J
Johannes Rieken 已提交
945
	public backupResource(_resource: URI, _content: ITextSnapshot): Promise<void> {
B
Benjamin Pasero 已提交
946
		return Promise.resolve();
947 948
	}

J
Johannes Rieken 已提交
949
	public getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
950
		return Promise.resolve([]);
951 952
	}

953 954 955 956 957
	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);
958 959
	}

J
Johannes Rieken 已提交
960
	public resolveBackupContent(_backup: URI): Promise<ITextBufferFactory> {
B
Benjamin Pasero 已提交
961
		return Promise.resolve(null);
962 963
	}

J
Johannes Rieken 已提交
964
	public discardResourceBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
965
		return Promise.resolve();
966 967
	}

J
Johannes Rieken 已提交
968
	public discardAllWorkspaceBackups(): Promise<void> {
B
Benjamin Pasero 已提交
969
		return Promise.resolve();
970
	}
971
}
D
Daniel Imms 已提交
972

B
Benjamin Pasero 已提交
973 974 975 976 977 978 979
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 已提交
980
	onDidChangeTransientModelProperty: Event<ITextModel> = Event.None;
B
Benjamin Pasero 已提交
981

982 983
	addCodeEditor(_editor: ICodeEditor): void { }
	removeCodeEditor(_editor: ICodeEditor): void { }
B
Benjamin Pasero 已提交
984
	listCodeEditors(): ICodeEditor[] { return []; }
985 986
	addDiffEditor(_editor: IDiffEditor): void { }
	removeDiffEditor(_editor: IDiffEditor): void { }
B
Benjamin Pasero 已提交
987 988
	listDiffEditors(): IDiffEditor[] { return []; }
	getFocusedCodeEditor(): ICodeEditor { return null; }
989 990 991 992 993
	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) { }
994
	getActiveCodeEditor(): ICodeEditor { return null; }
J
Johannes Rieken 已提交
995
	openCodeEditor(_input: IResourceInput, _source: ICodeEditor, _sideBySide?: boolean): Promise<ICodeEditor> { return Promise.resolve(); }
B
Benjamin Pasero 已提交
996 997
}

998 999 1000 1001
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

1002
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
S
SteVen Batten 已提交
1003
	onDidChangeMaximize: Event<boolean>;
1004

1005 1006
	hasFocus = true;

J
Johannes Rieken 已提交
1007
	isFocused(): Promise<boolean> {
B
Benjamin Pasero 已提交
1008
		return Promise.resolve(false);
1009 1010
	}

J
Johannes Rieken 已提交
1011
	isMaximized(): Promise<boolean> {
B
Benjamin Pasero 已提交
1012
		return Promise.resolve(false);
S
SteVen Batten 已提交
1013 1014
	}

1015 1016 1017 1018
	getConfiguration(): IWindowConfiguration {
		return Object.create(null);
	}

1019 1020 1021 1022
	getCurrentWindowId(): number {
		return 0;
	}

J
Johannes Rieken 已提交
1023
	pickFileFolderAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1024
		return Promise.resolve();
1025 1026
	}

J
Johannes Rieken 已提交
1027
	pickFileAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1028
		return Promise.resolve();
1029 1030
	}

J
Johannes Rieken 已提交
1031
	pickFolderAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1032
		return Promise.resolve();
1033 1034
	}

J
Johannes Rieken 已提交
1035
	pickWorkspaceAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1036
		return Promise.resolve();
1037 1038
	}

J
Johannes Rieken 已提交
1039
	reloadWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1040
		return Promise.resolve();
1041 1042
	}

J
Johannes Rieken 已提交
1043
	openDevTools(): Promise<void> {
B
Benjamin Pasero 已提交
1044
		return Promise.resolve();
1045 1046
	}

J
Johannes Rieken 已提交
1047
	toggleDevTools(): Promise<void> {
B
Benjamin Pasero 已提交
1048
		return Promise.resolve();
1049 1050
	}

J
Johannes Rieken 已提交
1051
	closeWorkspace(): Promise<void> {
B
Benjamin Pasero 已提交
1052
		return Promise.resolve();
1053 1054
	}

J
Johannes Rieken 已提交
1055
	enterWorkspace(_path: string): Promise<IEnterWorkspaceResult> {
B
Benjamin Pasero 已提交
1056
		return Promise.resolve();
1057 1058
	}

J
Johannes Rieken 已提交
1059
	createAndEnterWorkspace(_folders?: IWorkspaceFolderCreationData[], _path?: string): Promise<IEnterWorkspaceResult> {
B
Benjamin Pasero 已提交
1060
		return Promise.resolve();
1061 1062
	}

J
Johannes Rieken 已提交
1063
	saveAndEnterWorkspace(_path: string): Promise<IEnterWorkspaceResult> {
B
Benjamin Pasero 已提交
1064
		return Promise.resolve();
1065 1066
	}

J
Johannes Rieken 已提交
1067
	toggleFullScreen(): Promise<void> {
B
Benjamin Pasero 已提交
1068
		return Promise.resolve();
1069 1070
	}

J
Johannes Rieken 已提交
1071
	setRepresentedFilename(_fileName: string): Promise<void> {
B
Benjamin Pasero 已提交
1072
		return Promise.resolve();
1073 1074
	}

J
Johannes Rieken 已提交
1075
	getRecentlyOpened(): Promise<IRecentlyOpened> {
B
Benjamin Pasero 已提交
1076
		return Promise.resolve();
1077 1078
	}

J
Johannes Rieken 已提交
1079
	focusWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1080
		return Promise.resolve();
1081 1082
	}

J
Johannes Rieken 已提交
1083
	maximizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1084
		return Promise.resolve();
S
SteVen Batten 已提交
1085 1086
	}

J
Johannes Rieken 已提交
1087
	unmaximizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1088
		return Promise.resolve();
S
SteVen Batten 已提交
1089 1090
	}

J
Johannes Rieken 已提交
1091
	minimizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1092
		return Promise.resolve();
S
SteVen Batten 已提交
1093 1094
	}

J
Johannes Rieken 已提交
1095
	openWindow(_paths: URI[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Promise<void> {
B
Benjamin Pasero 已提交
1096
		return Promise.resolve();
B
Benjamin Pasero 已提交
1097 1098
	}

J
Johannes Rieken 已提交
1099
	closeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1100
		return Promise.resolve();
1101 1102
	}

J
Johannes Rieken 已提交
1103
	setDocumentEdited(_flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1104
		return Promise.resolve();
1105 1106
	}

J
Johannes Rieken 已提交
1107
	onWindowTitleDoubleClick(): Promise<void> {
B
Benjamin Pasero 已提交
1108
		return Promise.resolve();
1109
	}
1110

J
Johannes Rieken 已提交
1111
	show(): Promise<void> {
B
Benjamin Pasero 已提交
1112
		return Promise.resolve();
J
Joao 已提交
1113 1114
	}

J
Johannes Rieken 已提交
1115
	showMessageBox(_options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
B
Benjamin Pasero 已提交
1116
		return Promise.resolve({ button: 0 });
1117 1118
	}

J
Johannes Rieken 已提交
1119
	showSaveDialog(_options: Electron.SaveDialogOptions): Promise<string> {
R
Rob Lourens 已提交
1120
		return Promise.resolve(undefined);
1121
	}
1122

J
Johannes Rieken 已提交
1123
	showOpenDialog(_options: Electron.OpenDialogOptions): Promise<string[]> {
R
Rob Lourens 已提交
1124
		return Promise.resolve(undefined);
1125
	}
1126

J
Johannes Rieken 已提交
1127
	updateTouchBar(_items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1128
		return Promise.resolve();
1129
	}
1130 1131

	resolveProxy(url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1132
		return Promise.resolve(undefined);
1133
	}
1134 1135
}

1136 1137
export class TestLifecycleService implements ILifecycleService {

1138
	public _serviceBrand: any;
1139

1140
	public phase: LifecyclePhase;
1141
	public startupKind: StartupKind;
1142

1143
	private _onBeforeShutdown = new Emitter<BeforeShutdownEvent>();
1144
	private _onWillShutdown = new Emitter<WillShutdownEvent>();
1145
	private _onShutdown = new Emitter<void>();
1146

J
Johannes Rieken 已提交
1147
	when(): Promise<void> {
B
Benjamin Pasero 已提交
1148
		return Promise.resolve();
B
Benjamin Pasero 已提交
1149
	}
1150

1151
	public fireShutdown(reason = ShutdownReason.QUIT): void {
1152
		this._onWillShutdown.fire({
1153 1154 1155
			join: () => { },
			reason
		});
1156 1157
	}

1158 1159 1160 1161 1162 1163
	public fireWillShutdown(event: BeforeShutdownEvent): void {
		this._onBeforeShutdown.fire(event);
	}

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

1166
	public get onWillShutdown(): Event<WillShutdownEvent> {
1167 1168 1169
		return this._onWillShutdown.event;
	}

1170
	public get onShutdown(): Event<void> {
1171 1172
		return this._onShutdown.event;
	}
1173 1174
}

1175 1176 1177 1178
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1179 1180
	public windowCount = 1;

1181 1182
	onWindowOpen: Event<number>;
	onWindowFocus: Event<number>;
1183
	onWindowBlur: Event<number>;
S
SteVen Batten 已提交
1184 1185
	onWindowMaximize: Event<number>;
	onWindowUnmaximize: Event<number>;
S
SteVen Batten 已提交
1186
	onRecentlyOpenedChange: Event<void>;
1187

J
Johannes Rieken 已提交
1188
	isFocused(_windowId: number): Promise<boolean> {
B
Benjamin Pasero 已提交
1189
		return Promise.resolve(false);
1190 1191
	}

J
Johannes Rieken 已提交
1192
	pickFileFolderAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1193
		return Promise.resolve();
1194
	}
1195

J
Johannes Rieken 已提交
1196
	pickFileAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1197
		return Promise.resolve();
1198
	}
1199

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

J
Johannes Rieken 已提交
1204
	pickWorkspaceAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1205
		return Promise.resolve();
1206 1207
	}

J
Johannes Rieken 已提交
1208
	reloadWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1209
		return Promise.resolve();
1210
	}
1211

J
Johannes Rieken 已提交
1212
	openDevTools(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1213
		return Promise.resolve();
1214
	}
1215

J
Johannes Rieken 已提交
1216
	toggleDevTools(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1217
		return Promise.resolve();
1218
	}
1219

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

J
Johannes Rieken 已提交
1224
	enterWorkspace(_windowId: number, _path: string): Promise<IEnterWorkspaceResult> {
B
Benjamin Pasero 已提交
1225
		return Promise.resolve();
1226 1227
	}

J
Johannes Rieken 已提交
1228
	createAndEnterWorkspace(_windowId: number, _folders?: IWorkspaceFolderCreationData[], _path?: string): Promise<IEnterWorkspaceResult> {
B
Benjamin Pasero 已提交
1229
		return Promise.resolve();
1230 1231
	}

J
Johannes Rieken 已提交
1232
	saveAndEnterWorkspace(_windowId: number, _path: string): Promise<IEnterWorkspaceResult> {
B
Benjamin Pasero 已提交
1233
		return Promise.resolve();
1234 1235
	}

J
Johannes Rieken 已提交
1236
	toggleFullScreen(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1237
		return Promise.resolve();
1238
	}
1239

J
Johannes Rieken 已提交
1240
	setRepresentedFilename(_windowId: number, _fileName: string): Promise<void> {
B
Benjamin Pasero 已提交
1241
		return Promise.resolve();
1242
	}
1243

J
Johannes Rieken 已提交
1244
	addRecentlyOpened(_files: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1245
		return Promise.resolve();
1246
	}
1247

J
Johannes Rieken 已提交
1248
	removeFromRecentlyOpened(_paths: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1249
		return Promise.resolve();
1250
	}
1251

J
Johannes Rieken 已提交
1252
	clearRecentlyOpened(): Promise<void> {
B
Benjamin Pasero 已提交
1253
		return Promise.resolve();
C
22768  
Cristian 已提交
1254
	}
1255

J
Johannes Rieken 已提交
1256
	getRecentlyOpened(_windowId: number): Promise<IRecentlyOpened> {
B
Benjamin Pasero 已提交
1257
		return Promise.resolve();
1258
	}
1259

J
Johannes Rieken 已提交
1260
	focusWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1261
		return Promise.resolve();
1262
	}
1263

J
Johannes Rieken 已提交
1264
	closeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1265
		return Promise.resolve();
1266 1267
	}

J
Johannes Rieken 已提交
1268
	isMaximized(_windowId: number): Promise<boolean> {
B
Benjamin Pasero 已提交
1269
		return Promise.resolve();
1270
	}
1271

J
Johannes Rieken 已提交
1272
	maximizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1273
		return Promise.resolve();
1274
	}
1275

J
Johannes Rieken 已提交
1276
	minimizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1277
		return Promise.resolve();
S
SteVen Batten 已提交
1278 1279
	}

J
Johannes Rieken 已提交
1280
	unmaximizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1281
		return Promise.resolve();
1282
	}
1283

J
Johannes Rieken 已提交
1284
	onWindowTitleDoubleClick(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1285
		return Promise.resolve();
1286
	}
1287

J
Johannes Rieken 已提交
1288
	setDocumentEdited(_windowId: number, _flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1289
		return Promise.resolve();
1290
	}
1291

J
Johannes Rieken 已提交
1292
	quit(): Promise<void> {
B
Benjamin Pasero 已提交
1293
		return Promise.resolve();
1294
	}
1295

J
Johannes Rieken 已提交
1296
	relaunch(_options: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
B
Benjamin Pasero 已提交
1297
		return Promise.resolve();
J
Johannes Rieken 已提交
1298
	}
1299

J
Johannes Rieken 已提交
1300
	whenSharedProcessReady(): Promise<void> {
B
Benjamin Pasero 已提交
1301
		return Promise.resolve();
1302
	}
1303

J
Johannes Rieken 已提交
1304
	toggleSharedProcess(): Promise<void> {
B
Benjamin Pasero 已提交
1305
		return Promise.resolve();
1306
	}
1307

1308
	// Global methods
J
Johannes Rieken 已提交
1309
	openWindow(_windowId: number, _paths: URI[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Promise<void> {
B
Benjamin Pasero 已提交
1310
		return Promise.resolve();
1311
	}
1312

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

J
Johannes Rieken 已提交
1317
	showWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1318
		return Promise.resolve();
1319
	}
1320

J
Johannes Rieken 已提交
1321
	getWindows(): Promise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> {
B
Benjamin Pasero 已提交
1322
		return Promise.resolve();
1323
	}
1324

J
Johannes Rieken 已提交
1325
	getWindowCount(): Promise<number> {
B
Benjamin Pasero 已提交
1326
		return Promise.resolve(this.windowCount);
1327
	}
1328

J
Johannes Rieken 已提交
1329
	log(_severity: string, ..._messages: string[]): Promise<void> {
B
Benjamin Pasero 已提交
1330
		return Promise.resolve();
1331
	}
1332

J
Johannes Rieken 已提交
1333
	showItemInFolder(_path: string): Promise<void> {
B
Benjamin Pasero 已提交
1334
		return Promise.resolve();
1335 1336
	}

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

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

J
Johannes Rieken 已提交
1345
	showNextWindowTab(): Promise<void> {
B
Benjamin Pasero 已提交
1346
		return Promise.resolve();
1347 1348
	}

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

J
Johannes Rieken 已提交
1353
	mergeAllWindowTabs(): Promise<void> {
B
Benjamin Pasero 已提交
1354
		return Promise.resolve();
1355 1356
	}

J
Johannes Rieken 已提交
1357
	toggleWindowTabsBar(): Promise<void> {
B
Benjamin Pasero 已提交
1358
		return Promise.resolve();
1359 1360
	}

J
Johannes Rieken 已提交
1361
	updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1362
		return Promise.resolve();
1363 1364
	}

J
Johannes Rieken 已提交
1365
	getActiveWindowId(): Promise<number | undefined> {
B
Benjamin Pasero 已提交
1366
		return Promise.resolve(undefined);
J
Joao Moreno 已提交
1367 1368
	}

1369 1370
	// This needs to be handled from browser process to prevent
	// foreground ordering issues on Windows
J
Johannes Rieken 已提交
1371
	openExternal(_url: string): Promise<boolean> {
B
Benjamin Pasero 已提交
1372
		return Promise.resolve(true);
1373 1374 1375
	}

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

J
Johannes Rieken 已提交
1380
	showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
B
Benjamin Pasero 已提交
1381
		return Promise.resolve();
1382 1383
	}

J
Johannes Rieken 已提交
1384
	showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): Promise<string> {
B
Benjamin Pasero 已提交
1385
		return Promise.resolve();
1386 1387
	}

J
Johannes Rieken 已提交
1388
	showOpenDialog(_windowId: number, _options: Electron.OpenDialogOptions): Promise<string[]> {
B
Benjamin Pasero 已提交
1389
		return Promise.resolve();
1390
	}
J
Joao Moreno 已提交
1391

J
Johannes Rieken 已提交
1392
	openAboutDialog(): Promise<void> {
B
Benjamin Pasero 已提交
1393
		return Promise.resolve();
J
Joao Moreno 已提交
1394
	}
1395 1396

	resolveProxy(windowId: number, url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1397
		return Promise.resolve(undefined);
1398
	}
1399
}
B
Benjamin Pasero 已提交
1400

1401 1402 1403 1404 1405 1406 1407
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1408
	public onDidChangeConfiguration() {
1409 1410 1411
		return { dispose() { } };
	}

1412 1413
	getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
		const position: IPosition = EditorPosition.isIPosition(arg2) ? arg2 : null;
R
Rob Lourens 已提交
1414
		const section: string = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
1415
		return this.configurationService.getValue(section, { resource });
1416
	}
B
Benjamin Pasero 已提交
1417 1418
}

S
Sandeep Somavarapu 已提交
1419 1420 1421 1422 1423
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

	_serviceBrand: any;

	constructor(
1424
		@IConfigurationService private readonly configurationService: IConfigurationService,
S
Sandeep Somavarapu 已提交
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439
	) {
	}

	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 已提交
1440 1441 1442 1443 1444 1445 1446 1447
export class TestHashService implements IHashService {
	_serviceBrand: any;

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

1448 1449 1450 1451 1452 1453 1454 1455 1456
export class TestViewletService implements IViewletService {

	_serviceBrand: ServiceIdentifier<any>;

	readonly onDidViewletRegister: Event<ViewletDescriptor> = new Emitter<ViewletDescriptor>().event;
	onDidViewletOpen: Event<IViewlet> = new Emitter<IViewlet>().event;
	onDidViewletClose: Event<IViewlet> = new Emitter<IViewlet>().event;
	onDidViewletEnablementChange: Event<{ id: string, enabled: boolean }> = new Emitter<{ id: string, enabled: boolean }>().event;

1457
	openViewlet(_id: string, _focus?: boolean): Promise<IViewlet> { return null; }
1458 1459 1460 1461 1462

	getActiveViewlet(): IViewlet { return null; }

	getDefaultViewletId(): string { return null; }

1463
	getViewlet(_id: string): ViewletDescriptor { return null; }
1464 1465 1466 1467 1468

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

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

1469
	setViewletEnablement(_id: string, _enabled: boolean): void { }
1470

1471
	getProgressIndicator(_id: string): IProgressService { return null; }
1472 1473 1474

}

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