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 } 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';
I
isidor 已提交
82
import { LabelService } from 'vs/workbench/services/label/common/labelService';
B
Benjamin Pasero 已提交
83

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	public updateOptions() {

	}

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

		return false;
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return instantiationService;
}

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

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

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

export class TestMenuService implements IMenuService {

	public _serviceBrand: any;

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

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

	public _serviceBrand: any;

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

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

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

359 360 361
	public last(): void {
	}

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

	public clear(): void {
	}

B
Benjamin Pasero 已提交
368 369 370
	public clearRecentlyOpened(): void {
	}

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

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

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

	public openLastEditLocation(): void {
	}
B
Benjamin Pasero 已提交
385 386
}

387
export class TestDialogService implements IDialogService {
388 389

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

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

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

M
Martin Aeschlimann 已提交
400 401 402 403
export class TestFileDialogService implements IFileDialogService {

	public _serviceBrand: any;

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

433
export class TestPartService implements IPartService {
B
Benjamin Pasero 已提交
434

435
	public _serviceBrand: any;
E
Erich Gamma 已提交
436

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

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

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

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

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

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

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

465
	public getContainer(_part: Parts): HTMLElement {
466 467 468
		return null;
	}

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

473 474 475 476
	public getTitleBarOffset(): number {
		return 0;
	}

477 478 479 480
	public isStatusBarHidden(): boolean {
		return false;
	}

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

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

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

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

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

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

I
isidor 已提交
499 500
	public toggleMaximizedPanel(): void { }

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

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

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

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

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

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

I
isidor 已提交
525
	public toggleZenMode(): void { }
526

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


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

534
export class TestStorageService extends InMemoryStorageService { }
535

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

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

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

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

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

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

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

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

R
Rob Lourens 已提交
568
		return undefined;
569 570
	}

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

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

579
	activateGroup(_group: number | IEditorGroup): IEditorGroup {
580 581 582
		return null;
	}

583
	getSize(_group: number | IEditorGroup): number {
584
		return 100;
585 586
	}

587
	setSize(_group: number | IEditorGroup, _size: number): void { }
588

589
	arrangeGroups(_arrangement: GroupsArrangement): void { }
590

591
	applyLayout(_layout: EditorGroupLayout): void { }
592

593
	setGroupOrientation(_orientation: any): void { }
594

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

599
	removeGroup(_group: number | IEditorGroup): void { }
600

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

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

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

B
Benjamin Pasero 已提交
614
export class TestEditorGroup implements IEditorGroupView {
615 616 617

	constructor(public id: number) { }

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

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

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

646
	getEditor(_index: number): IEditorInput {
647 648 649
		return null;
	}

650
	getIndexOfEditor(_editor: IEditorInput): number {
651 652 653
		return -1;
	}

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

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

662
	isOpened(_editor: IEditorInput): boolean {
663 664 665
		return false;
	}

666
	isPinned(_editor: IEditorInput): boolean {
667 668 669
		return false;
	}

670
	isActive(_editor: IEditorInput): boolean {
671 672 673
		return false;
	}

674
	moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
675

676
	copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
677

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

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

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

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

694
	pinEditor(_editor?: IEditorInput): void { }
695 696 697 698 699 700

	focus(): void { }

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

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

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

	_serviceBrand: ServiceIdentifier<any>;

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

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

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

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

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

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

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

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

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

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

761 762 763 764
export class TestFileService implements IFileService {

	public _serviceBrand: any;

765 766
	public encoding: IResourceEncodings;

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

770 771
	private content = 'Hello Html';

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

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

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

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

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

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

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

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

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

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

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

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

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

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

882 883
	onDidChangeFileSystemProviderRegistrations = Event.None;

884
	registerProvider(_scheme: string, _provider) {
885 886 887
		return { dispose() { } };
	}

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

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

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

900
	watchFileChanges(_resource: URI): void {
901 902
	}

903
	unwatchFileChanges(_resource: URI): void {
904 905
	}

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

910
	dispose(): void {
E
Erich Gamma 已提交
911
	}
912
}
913

914 915
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
916

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1000 1001 1002 1003
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

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

1007 1008
	hasFocus = true;

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

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

1017 1018 1019 1020
	getConfiguration(): IWindowConfiguration {
		return Object.create(null);
	}

1021 1022 1023 1024
	getCurrentWindowId(): number {
		return 0;
	}

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

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

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

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

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

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

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

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

M
Martin Aeschlimann 已提交
1057
	enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult> {
B
Benjamin Pasero 已提交
1058
		return Promise.resolve();
1059 1060
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1138 1139
export class TestLifecycleService implements ILifecycleService {

1140
	public _serviceBrand: any;
1141

1142
	public phase: LifecyclePhase;
1143
	public startupKind: StartupKind;
1144

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

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

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

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

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

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

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

1177 1178 1179 1180
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1181 1182
	public windowCount = 1;

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

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

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

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

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

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

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

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

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

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

M
Martin Aeschlimann 已提交
1226
	enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult> {
B
Benjamin Pasero 已提交
1227
		return Promise.resolve();
1228 1229
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1403 1404 1405 1406 1407 1408 1409
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1410
	public onDidChangeConfiguration() {
1411 1412 1413
		return { dispose() { } };
	}

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

S
Sandeep Somavarapu 已提交
1421 1422 1423 1424 1425
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

	_serviceBrand: any;

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

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

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

1450 1451 1452 1453 1454
export class TestViewletService implements IViewletService {

	_serviceBrand: ServiceIdentifier<any>;

	readonly onDidViewletRegister: Event<ViewletDescriptor> = new Emitter<ViewletDescriptor>().event;
1455
	readonly onDidViewletDeregister: Event<ViewletDescriptor> = new Emitter<ViewletDescriptor>().event;
1456 1457 1458
	onDidViewletOpen: Event<IViewlet> = new Emitter<IViewlet>().event;
	onDidViewletClose: Event<IViewlet> = new Emitter<IViewlet>().event;

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

	getActiveViewlet(): IViewlet { return null; }

	getDefaultViewletId(): string { return null; }

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

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

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

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
}