workbenchTestServices.ts 46.5 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, 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 136 137 138
	getCompleteWorkspace(): Promise<IWorkbenchWorkspace> {
		return Promise.resolve(this.getWorkspace());
	}

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

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

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

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

	public updateOptions() {

	}

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

		return false;
	}

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

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

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

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

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

M
Martin Aeschlimann 已提交
201
	public setPromptPath(path: URI): void {
202 203 204 205 206 207 208
		this.promptPath = path;
	}

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

209
	public setResolveTextContentErrorOnce(error: FileOperationError): void {
210 211 212
		this.resolveTextContentError = error;
	}

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

B
Benjamin Pasero 已提交
218
			return Promise.reject(error);
219 220
		}

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

J
Johannes Rieken 已提交
233
	public promptForPath(_resource: URI, _defaultPath: URI): Promise<URI> {
B
Benjamin Pasero 已提交
234
		return Promise.resolve(this.promptPath);
235 236
	}

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

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

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

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

	return instantiationService;
}

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

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

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

export class TestMenuService implements IMenuService {

	public _serviceBrand: any;

340
	createMenu(_id: MenuId, _scopedKeybindingService: IContextKeyService): IMenu {
B
Benjamin Pasero 已提交
341 342
		return {
			onDidChange: Event.None,
R
Rob Lourens 已提交
343
			dispose: () => undefined,
B
Benjamin Pasero 已提交
344 345 346 347 348
			getActions: () => []
		};
	}
}

B
Benjamin Pasero 已提交
349 350 351 352 353 354 355 356 357 358
export class TestHistoryService implements IHistoryService {

	public _serviceBrand: any;

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

359
	public forward(_acrossEditors?: boolean): void {
B
Benjamin Pasero 已提交
360 361
	}

362
	public back(_acrossEditors?: boolean): void {
B
Benjamin Pasero 已提交
363 364
	}

365 366 367
	public last(): void {
	}

368
	public remove(_input: IEditorInput | IResourceInput): void {
B
Benjamin Pasero 已提交
369 370 371 372 373
	}

	public clear(): void {
	}

B
Benjamin Pasero 已提交
374 375 376
	public clearRecentlyOpened(): void {
	}

377
	public getHistory(): Array<IEditorInput | IResourceInput> {
B
Benjamin Pasero 已提交
378 379 380
		return [];
	}

381
	public getLastActiveWorkspaceRoot(_schemeFilter: string): URI {
B
Benjamin Pasero 已提交
382 383
		return this.root;
	}
384

385
	public getLastActiveFile(_schemeFilter: string): URI {
R
Rob Lourens 已提交
386
		return undefined;
387
	}
B
Benjamin Pasero 已提交
388 389 390

	public openLastEditLocation(): void {
	}
B
Benjamin Pasero 已提交
391 392
}

393
export class TestDialogService implements IDialogService {
394 395

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

J
Johannes Rieken 已提交
397
	public confirm(_confirmation: IConfirmation): Promise<IConfirmationResult> {
B
Benjamin Pasero 已提交
398
		return Promise.resolve({ confirmed: false });
399
	}
400

J
Johannes Rieken 已提交
401
	public show(_severity: Severity, _message: string, _buttons: string[], _options?: IDialogOptions): Promise<number> {
B
Benjamin Pasero 已提交
402
		return Promise.resolve(0);
403
	}
E
Erich Gamma 已提交
404 405
}

M
Martin Aeschlimann 已提交
406 407 408 409
export class TestFileDialogService implements IFileDialogService {

	public _serviceBrand: any;

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

439
export class TestPartService implements IPartService {
B
Benjamin Pasero 已提交
440

441
	public _serviceBrand: any;
E
Erich Gamma 已提交
442

443
	private _onTitleBarVisibilityChange = new Emitter<void>();
444
	private _onMenubarVisibilityChange = new Emitter<Dimension>();
445
	private _onEditorLayout = new Emitter<IDimension>();
446 447 448 449 450

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

451 452 453 454
	public get onMenubarVisibilityChange(): Event<Dimension> {
		return this._onMenubarVisibilityChange.event;
	}

455
	public get onEditorLayout(): Event<IDimension> {
456 457 458
		return this._onEditorLayout.event;
	}

B
Benjamin Pasero 已提交
459
	public isRestored(): boolean {
E
Erich Gamma 已提交
460 461 462
		return true;
	}

463
	public hasFocus(_part: Parts): boolean {
E
Erich Gamma 已提交
464 465 466
		return false;
	}

467
	public isVisible(_part: Parts): boolean {
E
Erich Gamma 已提交
468 469 470
		return true;
	}

471
	public getContainer(_part: Parts): HTMLElement {
472 473 474
		return null;
	}

B
Benjamin Pasero 已提交
475 476 477 478
	public isTitleBarHidden(): boolean {
		return false;
	}

479 480 481 482
	public getTitleBarOffset(): number {
		return 0;
	}

483 484 485 486
	public isStatusBarHidden(): boolean {
		return false;
	}

S
Sanders Lauture 已提交
487 488 489 490
	public isActivityBarHidden(): boolean {
		return false;
	}

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

E
Erich Gamma 已提交
493 494 495 496
	public isSideBarHidden(): boolean {
		return false;
	}

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

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

I
isidor 已提交
501
	public isPanelHidden(): boolean {
I
isidor 已提交
502 503 504
		return false;
	}

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

I
isidor 已提交
507 508
	public toggleMaximizedPanel(): void { }

B
Benjamin Pasero 已提交
509 510 511 512
	public isPanelMaximized(): boolean {
		return false;
	}

S
SteVen Batten 已提交
513 514 515 516
	public getMenubarVisibility(): MenuBarVisibility {
		return null;
	}

E
Erich Gamma 已提交
517 518 519 520
	public getSideBarPosition() {
		return 0;
	}

I
isidor 已提交
521 522 523 524
	public getPanelPosition() {
		return 0;
	}

J
Johannes Rieken 已提交
525
	public setPanelPosition(_position: PartPosition): Promise<void> {
B
Benjamin Pasero 已提交
526
		return Promise.resolve(null);
I
isidor 已提交
527 528
	}

529 530
	public addClass(_clazz: string): void { }
	public removeClass(_clazz: string): void { }
R
Rob Lourens 已提交
531
	public getWorkbenchElement(): HTMLElement { return undefined; }
B
Benjamin Pasero 已提交
532

I
isidor 已提交
533
	public toggleZenMode(): void { }
534

B
Benjamin Pasero 已提交
535
	public isEditorLayoutCentered(): boolean { return false; }
536
	public centerEditorLayout(_active: boolean): void { }
S
SrTobi 已提交
537 538


539
	public resizePart(_part: Parts, _sizeChange: number): void { }
E
Erich Gamma 已提交
540 541
}

542
export class TestStorageService extends InMemoryStorageService { }
543

B
Benjamin Pasero 已提交
544
export class TestEditorGroupsService implements EditorGroupsServiceImpl {
545 546
	_serviceBrand: ServiceIdentifier<any>;

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

549 550 551 552
	onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
	onDidAddGroup: Event<IEditorGroup> = Event.None;
	onDidRemoveGroup: Event<IEditorGroup> = Event.None;
	onDidMoveGroup: Event<IEditorGroup> = Event.None;
553 554

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

557
	get activeGroup(): IEditorGroup {
558 559 560 561 562 563 564
		return this.groups[0];
	}

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

565
	getGroups(_order?: GroupsOrder): ReadonlyArray<IEditorGroup> {
566 567 568
		return this.groups;
	}

569
	getGroup(identifier: number): IEditorGroup {
570 571 572
		for (const group of this.groups) {
			if (group.id === identifier) {
				return group;
573 574 575
			}
		}

R
Rob Lourens 已提交
576
		return undefined;
577 578
	}

579
	getLabel(_identifier: number): string {
580 581 582
		return 'Group 1';
	}

583
	findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup {
584 585 586
		return null;
	}

587
	activateGroup(_group: number | IEditorGroup): IEditorGroup {
588 589 590
		return null;
	}

591
	getSize(_group: number | IEditorGroup): number {
592
		return 100;
593 594
	}

595
	setSize(_group: number | IEditorGroup, _size: number): void { }
596

597
	arrangeGroups(_arrangement: GroupsArrangement): void { }
598

599
	applyLayout(_layout: EditorGroupLayout): void { }
600

601
	setGroupOrientation(_orientation: any): void { }
602

603
	addGroup(_location: number | IEditorGroup, _direction: GroupDirection, _options?: IAddGroupOptions): IEditorGroup {
604 605 606
		return null;
	}

607
	removeGroup(_group: number | IEditorGroup): void { }
608

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

613
	mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup {
614 615 616
		return null;
	}

617
	copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
618 619 620 621
		return null;
	}
}

B
Benjamin Pasero 已提交
622
export class TestEditorGroup implements IEditorGroupView {
623 624 625

	constructor(public id: number) { }

R
Rob Lourens 已提交
626
	group: EditorGroup = undefined;
627 628 629 630
	activeControl: IEditor;
	activeEditor: IEditorInput;
	previewEditor: IEditorInput;
	count: number;
B
Benjamin Pasero 已提交
631
	disposed: boolean;
B
Benjamin Pasero 已提交
632
	editors: ReadonlyArray<IEditorInput> = [];
633
	label: string;
R
Rob Lourens 已提交
634
	whenRestored: Promise<void> = Promise.resolve(undefined);
B
Benjamin Pasero 已提交
635 636 637 638 639
	element: HTMLElement;
	minimumWidth: number;
	maximumWidth: number;
	minimumHeight: number;
	maximumHeight: number;
640 641

	onWillDispose: Event<void> = Event.None;
642
	onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
B
Benjamin Pasero 已提交
643 644
	onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
645 646
	onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
	onDidOpenEditorFail: Event<IEditorInput> = Event.None;
B
Benjamin Pasero 已提交
647 648
	onDidFocus: Event<void> = Event.None;
	onDidChange: Event<{ width: number; height: number; }> = Event.None;
649

650
	getEditors(_order?: EditorsOrder): ReadonlyArray<IEditorInput> {
B
Benjamin Pasero 已提交
651 652 653
		return [];
	}

654
	getEditor(_index: number): IEditorInput {
655 656 657
		return null;
	}

658
	getIndexOfEditor(_editor: IEditorInput): number {
659 660 661
		return -1;
	}

J
Johannes Rieken 已提交
662
	openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditor> {
B
Benjamin Pasero 已提交
663
		return Promise.resolve(null);
664 665
	}

J
Johannes Rieken 已提交
666
	openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditor> {
B
Benjamin Pasero 已提交
667
		return Promise.resolve(null);
668 669
	}

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

674
	isPinned(_editor: IEditorInput): boolean {
675 676 677
		return false;
	}

678
	isActive(_editor: IEditorInput): boolean {
679 680 681
		return false;
	}

682
	moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
683

684
	copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
685

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

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

J
Johannes Rieken 已提交
694
	closeAllEditors(): Promise<void> {
B
Benjamin Pasero 已提交
695
		return Promise.resolve();
696 697
	}

J
Johannes Rieken 已提交
698
	replaceEditors(_editors: IEditorReplacement[]): Promise<void> {
B
Benjamin Pasero 已提交
699
		return Promise.resolve();
700 701
	}

702
	pinEditor(_editor?: IEditorInput): void { }
703 704 705 706 707 708

	focus(): void { }

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

	isEmpty(): boolean { return true; }
711 712
	setActive(_isActive: boolean): void { }
	setLabel(_label: string): void { }
B
Benjamin Pasero 已提交
713 714
	dispose(): void { }
	toJSON(): object { return Object.create(null); }
715
	layout(_width: number, _height: number): void { }
716
	relayout() { }
717 718
}

B
Benjamin Pasero 已提交
719
export class TestEditorService implements EditorServiceImpl {
720 721 722 723 724

	_serviceBrand: ServiceIdentifier<any>;

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
725
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
726 727 728
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

	activeControl: IEditor;
729
	activeTextEditorWidget: any;
730
	activeEditor: IEditorInput;
731
	editors: ReadonlyArray<IEditorInput> = [];
B
Benjamin Pasero 已提交
732
	visibleControls: ReadonlyArray<IEditor> = [];
733
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
734
	visibleEditors: ReadonlyArray<IEditorInput> = [];
735

736
	overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
R
Rob Lourens 已提交
737
		return toDisposable(() => undefined);
738 739
	}

740
	openEditor(_editor: any, _options?: any, _group?: any) {
B
Benjamin Pasero 已提交
741
		return Promise.resolve(null);
742 743
	}

744
	openEditors(_editors: any, _group?: any) {
B
Benjamin Pasero 已提交
745
		return Promise.resolve(null);
746 747
	}

748
	isOpen(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
749 750 751
		return false;
	}

752
	getOpened(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): IEditorInput {
R
Rob Lourens 已提交
753
		return undefined;
754 755
	}

756
	replaceEditors(_editors: any, _group: any) {
R
Rob Lourens 已提交
757
		return Promise.resolve(undefined);
758 759
	}

760 761 762 763
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
		return fn(null);
	}

764
	createInput(_input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
765 766 767 768
		return null;
	}
}

769 770 771 772
export class TestFileService implements IFileService {

	public _serviceBrand: any;

773 774
	public encoding: IResourceEncodings;

M
Matt Bierner 已提交
775 776
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
777

778 779
	private content = 'Hello Html';

780 781 782 783 784
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

785 786 787 788 789 790 791 792
	public setContent(content: string): void {
		this.content = content;
	}

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

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

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

J
Johannes Rieken 已提交
824
	existsFile(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
825
		return Promise.resolve(null);
826
	}
B
Benjamin Pasero 已提交
827

J
Johannes Rieken 已提交
828
	resolveContent(resource: URI, _options?: IResolveContentOptions): Promise<IContent> {
B
Benjamin Pasero 已提交
829
		return Promise.resolve({
B
Benjamin Pasero 已提交
830
			resource: resource,
831
			value: this.content,
832
			etag: 'index.txt',
B
Benjamin Pasero 已提交
833 834
			encoding: 'utf8',
			mtime: Date.now(),
835
			name: paths.basename(resource.fsPath)
E
Erich Gamma 已提交
836
		});
837
	}
E
Erich Gamma 已提交
838

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

J
Johannes Rieken 已提交
859
	updateContent(resource: URI, _value: string | ITextSnapshot, _options?: IUpdateContentOptions): Promise<IFileStat> {
B
Benjamin Pasero 已提交
860
		return timeout(0).then(() => ({
861 862 863 864 865 866
			resource,
			etag: 'index.txt',
			encoding: 'utf8',
			mtime: Date.now(),
			isDirectory: false,
			name: paths.basename(resource.fsPath)
B
Benjamin Pasero 已提交
867
		}));
868
	}
D
Daniel Imms 已提交
869

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

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

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

C
Christof Marti 已提交
882
	readFolder(_resource: URI) {
B
Benjamin Pasero 已提交
883
		return Promise.resolve([]);
C
Christof Marti 已提交
884 885
	}

J
Johannes Rieken 已提交
886
	createFolder(_resource: URI): Promise<IFileStat> {
B
Benjamin Pasero 已提交
887
		return Promise.resolve(null);
888 889
	}

890 891
	onDidChangeFileSystemProviderRegistrations = Event.None;

892
	registerProvider(_scheme: string, _provider) {
893 894 895
		return { dispose() { } };
	}

896
	activateProvider(_scheme: string) {
B
Benjamin Pasero 已提交
897
		return Promise.resolve(null);
898 899
	}

900 901 902 903
	canHandleResource(resource: URI): boolean {
		return resource.scheme === 'file';
	}

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

908
	watchFileChanges(_resource: URI): void {
909 910
	}

911
	unwatchFileChanges(_resource: URI): void {
912 913
	}

914
	getWriteEncoding(_resource: URI): string {
915 916
		return 'utf8';
	}
D
Daniel Imms 已提交
917

918
	dispose(): void {
E
Erich Gamma 已提交
919
	}
920
}
921

922 923
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
924

J
Johannes Rieken 已提交
925
	public hasBackups(): Promise<boolean> {
B
Benjamin Pasero 已提交
926
		return Promise.resolve(false);
927 928
	}

J
Johannes Rieken 已提交
929
	public hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
930
		return Promise.resolve(false);
931 932
	}

J
Johannes Rieken 已提交
933
	public loadBackupResource(resource: URI): Promise<URI> {
B
Benjamin Pasero 已提交
934 935
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
936
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
937 938
			}

R
Rob Lourens 已提交
939
			return undefined;
B
Benjamin Pasero 已提交
940 941 942
		});
	}

J
Johannes Rieken 已提交
943
	public registerResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
944
		return Promise.resolve();
D
Daniel Imms 已提交
945 946
	}

J
Johannes Rieken 已提交
947
	public deregisterResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
948
		return Promise.resolve();
D
Daniel Imms 已提交
949 950
	}

951
	public toBackupResource(_resource: URI): URI {
D
Daniel Imms 已提交
952 953
		return null;
	}
954

J
Johannes Rieken 已提交
955
	public backupResource(_resource: URI, _content: ITextSnapshot): Promise<void> {
B
Benjamin Pasero 已提交
956
		return Promise.resolve();
957 958
	}

J
Johannes Rieken 已提交
959
	public getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
960
		return Promise.resolve([]);
961 962
	}

963 964 965 966 967
	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);
968 969
	}

J
Johannes Rieken 已提交
970
	public resolveBackupContent(_backup: URI): Promise<ITextBufferFactory> {
B
Benjamin Pasero 已提交
971
		return Promise.resolve(null);
972 973
	}

J
Johannes Rieken 已提交
974
	public discardResourceBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
975
		return Promise.resolve();
976 977
	}

J
Johannes Rieken 已提交
978
	public discardAllWorkspaceBackups(): Promise<void> {
B
Benjamin Pasero 已提交
979
		return Promise.resolve();
980
	}
981
}
D
Daniel Imms 已提交
982

B
Benjamin Pasero 已提交
983 984 985 986 987 988 989
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 已提交
990
	onDidChangeTransientModelProperty: Event<ITextModel> = Event.None;
B
Benjamin Pasero 已提交
991

992 993
	addCodeEditor(_editor: ICodeEditor): void { }
	removeCodeEditor(_editor: ICodeEditor): void { }
B
Benjamin Pasero 已提交
994
	listCodeEditors(): ICodeEditor[] { return []; }
995 996
	addDiffEditor(_editor: IDiffEditor): void { }
	removeDiffEditor(_editor: IDiffEditor): void { }
B
Benjamin Pasero 已提交
997 998
	listDiffEditors(): IDiffEditor[] { return []; }
	getFocusedCodeEditor(): ICodeEditor { return null; }
999 1000 1001 1002 1003
	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) { }
1004
	getActiveCodeEditor(): ICodeEditor { return null; }
J
Johannes Rieken 已提交
1005
	openCodeEditor(_input: IResourceInput, _source: ICodeEditor, _sideBySide?: boolean): Promise<ICodeEditor> { return Promise.resolve(); }
B
Benjamin Pasero 已提交
1006 1007
}

1008 1009 1010 1011
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

1012
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
S
SteVen Batten 已提交
1013
	onDidChangeMaximize: Event<boolean>;
1014

1015 1016
	hasFocus = true;

J
Johannes Rieken 已提交
1017
	isFocused(): Promise<boolean> {
B
Benjamin Pasero 已提交
1018
		return Promise.resolve(false);
1019 1020
	}

J
Johannes Rieken 已提交
1021
	isMaximized(): Promise<boolean> {
B
Benjamin Pasero 已提交
1022
		return Promise.resolve(false);
S
SteVen Batten 已提交
1023 1024
	}

1025 1026 1027 1028
	getConfiguration(): IWindowConfiguration {
		return Object.create(null);
	}

1029 1030 1031 1032
	getCurrentWindowId(): number {
		return 0;
	}

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

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

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

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

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

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

J
Johannes Rieken 已提交
1057
	toggleDevTools(): Promise<void> {
B
Benjamin Pasero 已提交
1058
		return Promise.resolve();
1059 1060
	}

J
Johannes Rieken 已提交
1061
	closeWorkspace(): Promise<void> {
B
Benjamin Pasero 已提交
1062
		return Promise.resolve();
1063 1064
	}

M
Martin Aeschlimann 已提交
1065
	enterWorkspace(_path: URI): 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
	toggleFullScreen(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1231
		return Promise.resolve();
1232
	}
1233

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

J
Johannes Rieken 已提交
1238
	addRecentlyOpened(_files: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1239
		return Promise.resolve();
1240
	}
1241

J
Johannes Rieken 已提交
1242
	removeFromRecentlyOpened(_paths: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1243
		return Promise.resolve();
1244
	}
1245

J
Johannes Rieken 已提交
1246
	clearRecentlyOpened(): Promise<void> {
B
Benjamin Pasero 已提交
1247
		return Promise.resolve();
C
22768  
Cristian 已提交
1248
	}
1249

J
Johannes Rieken 已提交
1250
	getRecentlyOpened(_windowId: number): Promise<IRecentlyOpened> {
B
Benjamin Pasero 已提交
1251
		return Promise.resolve();
1252
	}
1253

J
Johannes Rieken 已提交
1254
	focusWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1255
		return Promise.resolve();
1256
	}
1257

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

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

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

J
Johannes Rieken 已提交
1270
	minimizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1271
		return Promise.resolve();
S
SteVen Batten 已提交
1272 1273
	}

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

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

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

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

J
Johannes Rieken 已提交
1290
	relaunch(_options: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
B
Benjamin Pasero 已提交
1291
		return Promise.resolve();
J
Johannes Rieken 已提交
1292
	}
1293

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

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

1302
	// Global methods
J
Johannes Rieken 已提交
1303
	openWindow(_windowId: number, _paths: URI[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Promise<void> {
B
Benjamin Pasero 已提交
1304
		return Promise.resolve();
1305
	}
1306

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

J
Johannes Rieken 已提交
1311
	showWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1312
		return Promise.resolve();
1313
	}
1314

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

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

J
Johannes Rieken 已提交
1323
	log(_severity: string, ..._messages: string[]): Promise<void> {
B
Benjamin Pasero 已提交
1324
		return Promise.resolve();
1325
	}
1326

J
Johannes Rieken 已提交
1327
	showItemInFolder(_path: string): Promise<void> {
B
Benjamin Pasero 已提交
1328
		return Promise.resolve();
1329 1330
	}

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

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

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

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

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

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

J
Johannes Rieken 已提交
1355
	updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1356
		return Promise.resolve();
1357 1358
	}

J
Johannes Rieken 已提交
1359
	getActiveWindowId(): Promise<number | undefined> {
B
Benjamin Pasero 已提交
1360
		return Promise.resolve(undefined);
J
Joao Moreno 已提交
1361 1362
	}

1363 1364
	// This needs to be handled from browser process to prevent
	// foreground ordering issues on Windows
J
Johannes Rieken 已提交
1365
	openExternal(_url: string): Promise<boolean> {
B
Benjamin Pasero 已提交
1366
		return Promise.resolve(true);
1367 1368 1369
	}

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

J
Johannes Rieken 已提交
1374
	showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
B
Benjamin Pasero 已提交
1375
		return Promise.resolve();
1376 1377
	}

J
Johannes Rieken 已提交
1378
	showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): Promise<string> {
B
Benjamin Pasero 已提交
1379
		return Promise.resolve();
1380 1381
	}

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

J
Johannes Rieken 已提交
1386
	openAboutDialog(): Promise<void> {
B
Benjamin Pasero 已提交
1387
		return Promise.resolve();
J
Joao Moreno 已提交
1388
	}
1389 1390

	resolveProxy(windowId: number, url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1391
		return Promise.resolve(undefined);
1392
	}
1393
}
B
Benjamin Pasero 已提交
1394

1395 1396 1397 1398 1399 1400 1401
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1402
	public onDidChangeConfiguration() {
1403 1404 1405
		return { dispose() { } };
	}

1406 1407
	getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
		const position: IPosition = EditorPosition.isIPosition(arg2) ? arg2 : null;
R
Rob Lourens 已提交
1408
		const section: string = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
1409
		return this.configurationService.getValue(section, { resource });
1410
	}
B
Benjamin Pasero 已提交
1411 1412
}

S
Sandeep Somavarapu 已提交
1413 1414 1415 1416 1417
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

	_serviceBrand: any;

	constructor(
1418
		@IConfigurationService private readonly configurationService: IConfigurationService,
S
Sandeep Somavarapu 已提交
1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433
	) {
	}

	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 已提交
1434 1435 1436 1437 1438 1439 1440 1441
export class TestHashService implements IHashService {
	_serviceBrand: any;

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

1442 1443 1444 1445 1446
export class TestViewletService implements IViewletService {

	_serviceBrand: ServiceIdentifier<any>;

	readonly onDidViewletRegister: Event<ViewletDescriptor> = new Emitter<ViewletDescriptor>().event;
1447
	readonly onDidViewletDeregister: Event<ViewletDescriptor> = new Emitter<ViewletDescriptor>().event;
1448 1449 1450
	onDidViewletOpen: Event<IViewlet> = new Emitter<IViewlet>().event;
	onDidViewletClose: Event<IViewlet> = new Emitter<IViewlet>().event;

1451
	openViewlet(_id: string, _focus?: boolean): Promise<IViewlet> { return null; }
1452 1453 1454 1455 1456

	getActiveViewlet(): IViewlet { return null; }

	getDefaultViewletId(): string { return null; }

1457
	getViewlet(_id: string): ViewletDescriptor { return null; }
1458 1459 1460 1461 1462

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

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

1463
	getProgressIndicator(_id: string): IProgressService { return null; }
1464 1465 1466

}

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