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

export class TestMenuService implements IMenuService {

	public _serviceBrand: any;

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

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

	public _serviceBrand: any;

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

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

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

358 359 360
	public last(): void {
	}

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

	public clear(): void {
	}

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

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

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

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

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

386
export class TestDialogService implements IDialogService {
387 388

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

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

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

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

	public _serviceBrand: any;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

533
export class TestStorageService extends InMemoryStorageService { }
534

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	constructor(public id: number) { }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	focus(): void { }

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

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

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

	_serviceBrand: ServiceIdentifier<any>;

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

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

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

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

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

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

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

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

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

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

760 761 762 763
export class TestFileService implements IFileService {

	public _serviceBrand: any;

764 765
	public encoding: IResourceEncodings;

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

769 770
	private content = 'Hello Html';

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

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

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

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

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

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

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

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

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

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

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

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

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

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

881 882
	onDidChangeFileSystemProviderRegistrations = Event.None;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

999 1000 1001 1002
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

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

1006 1007
	hasFocus = true;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1137 1138
export class TestLifecycleService implements ILifecycleService {

1139
	public _serviceBrand: any;
1140

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

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

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

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

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

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

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

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

1176 1177 1178 1179
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1180 1181
	public windowCount = 1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	_serviceBrand: any;

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

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

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

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

	_serviceBrand: any;

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

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

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

1449 1450 1451 1452 1453
export class TestViewletService implements IViewletService {

	_serviceBrand: ServiceIdentifier<any>;

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

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

	getActiveViewlet(): IViewlet { return null; }

	getDefaultViewletId(): string { return null; }

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

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

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

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

}

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