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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	public updateOptions() {

	}

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

		return false;
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

272 273
	public onFilesConfigurationChange(configuration: any): void {
		super.onFilesConfigurationChange(configuration);
274 275
	}

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

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

	return instantiationService;
}

I
isidor 已提交
324 325 326
export class TestLogService implements ILogService {
	_serviceBrand: any; onDidChangeLogLevel: Event<LogLevel>;
	getLevel(): LogLevel { return LogLevel.Info; }
327 328 329 330 331 332 333
	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 已提交
334 335 336
	dispose(): void { }
}

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

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

export class TestMenuService implements IMenuService {

	public _serviceBrand: any;

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

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

	public _serviceBrand: any;

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

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

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

375 376 377
	public last(): void {
	}

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

	public clear(): void {
	}

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

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

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

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

	public openLastEditLocation(): void {
	}
B
Benjamin Pasero 已提交
401 402
}

403
export class TestDialogService implements IDialogService {
404 405

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

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

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

M
Martin Aeschlimann 已提交
416 417 418 419
export class TestFileDialogService implements IFileDialogService {

	public _serviceBrand: any;

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

449
export class TestLayoutService implements IWorkbenchLayoutService {
B
Benjamin Pasero 已提交
450

451
	public _serviceBrand: any;
E
Erich Gamma 已提交
452

453 454
	dimension: IDimension = { width: 800, height: 600 };

455 456
	container: HTMLElement = window.document.body;

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

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

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

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

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

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

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

B
Benjamin Pasero 已提交
483 484
	public getContainer(_part: Parts): HTMLElement {
		return null!;
485 486
	}

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

491 492 493 494
	public getTitleBarOffset(): number {
		return 0;
	}

495 496 497 498
	public isStatusBarHidden(): boolean {
		return false;
	}

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

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

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

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

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

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

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

I
isidor 已提交
519 520
	public toggleMaximizedPanel(): void { }

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

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

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

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

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

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

I
isidor 已提交
545
	public toggleZenMode(): void { }
546

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


551
	public resizePart(_part: Parts, _sizeChange: number): void { }
552 553

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

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

export class TestViewletService implements IViewletService {
	public _serviceBrand: any;

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

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

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

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

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

	public getActiveViewlet(): IViewlet {
		return activeViewlet;
	}

	public dispose() {
	}

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

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

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

	public hideActiveViewlet(): void { }

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

export class TestPanelService implements IPanelService {
	public _serviceBrand: any;

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

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

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

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

	public getActivePanel(): IViewlet {
		return activeViewlet;
	}

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

	public dispose() {
	}

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

	public hideActivePanel(): void { }

	public getLastActivePanelId(): string {
M
Matt Bierner 已提交
643
		return undefined!;
644
	}
E
Erich Gamma 已提交
645 646
}

647
export class TestStorageService extends InMemoryStorageService { }
648

649 650
export class TestEditorGroupsService implements IEditorGroupsService {

651 652
	_serviceBrand: ServiceIdentifier<any>;

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

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

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

B
Benjamin Pasero 已提交
665 666
	dimension = { width: 800, height: 600 };

667
	get activeGroup(): IEditorGroup {
668 669 670 671 672 673 674
		return this.groups[0];
	}

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

675
	getGroups(_order?: GroupsOrder): ReadonlyArray<IEditorGroup> {
676 677 678
		return this.groups;
	}

679
	getGroup(identifier: number): IEditorGroup {
680 681 682
		for (const group of this.groups) {
			if (group.id === identifier) {
				return group;
683 684 685
			}
		}

686
		return undefined!;
687 688
	}

689
	getLabel(_identifier: number): string {
690 691 692
		return 'Group 1';
	}

693
	findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup {
694
		throw new Error('not implemented');
695 696
	}

697
	activateGroup(_group: number | IEditorGroup): IEditorGroup {
698
		throw new Error('not implemented');
699 700
	}

701
	getSize(_group: number | IEditorGroup): number {
702
		return 100;
703 704
	}

705
	setSize(_group: number | IEditorGroup, _size: number): void { }
706

707
	arrangeGroups(_arrangement: GroupsArrangement): void { }
708

709
	applyLayout(_layout: EditorGroupLayout): void { }
710

711
	setGroupOrientation(_orientation: any): void { }
712

713
	addGroup(_location: number | IEditorGroup, _direction: GroupDirection, _options?: IAddGroupOptions): IEditorGroup {
714
		throw new Error('not implemented');
715 716
	}

717
	removeGroup(_group: number | IEditorGroup): void { }
718

719
	moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
720
		throw new Error('not implemented');
721 722
	}

723
	mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup {
724
		throw new Error('not implemented');
725 726
	}

727
	copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
728
		throw new Error('not implemented');
729
	}
730 731 732 733 734 735 736 737 738 739 740

	centerLayout(active: boolean): void { }

	isLayoutCentered(): boolean {
		return false;
	}

	partOptions: IEditorPartOptions;
	enforcePartOptions(options: IEditorPartOptions): IDisposable {
		return Disposable.None;
	}
741 742
}

B
Benjamin Pasero 已提交
743
export class TestEditorGroup implements IEditorGroupView {
744 745 746

	constructor(public id: number) { }

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

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

771
	getEditors(_order?: EditorsOrder): ReadonlyArray<IEditorInput> {
B
Benjamin Pasero 已提交
772 773 774
		return [];
	}

775
	getEditor(_index: number): IEditorInput {
776
		throw new Error('not implemented');
777 778
	}

779
	getIndexOfEditor(_editor: IEditorInput): number {
780 781 782
		return -1;
	}

J
Johannes Rieken 已提交
783
	openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditor> {
784
		throw new Error('not implemented');
785 786
	}

J
Johannes Rieken 已提交
787
	openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditor> {
788
		throw new Error('not implemented');
789 790
	}

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

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

799
	isActive(_editor: IEditorInput): boolean {
800 801 802
		return false;
	}

803
	moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
804

805
	copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
806

807
	closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> {
B
Benjamin Pasero 已提交
808
		return Promise.resolve();
809 810
	}

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

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

J
Johannes Rieken 已提交
819
	replaceEditors(_editors: IEditorReplacement[]): Promise<void> {
B
Benjamin Pasero 已提交
820
		return Promise.resolve();
821 822
	}

823
	pinEditor(_editor?: IEditorInput): void { }
824 825 826 827

	focus(): void { }

	invokeWithinContext<T>(fn: (accessor: ServicesAccessor) => T): T {
828
		throw new Error('not implemented');
829
	}
B
Benjamin Pasero 已提交
830 831

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

B
Benjamin Pasero 已提交
840
export class TestEditorService implements EditorServiceImpl {
841 842 843 844 845

	_serviceBrand: ServiceIdentifier<any>;

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
846
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
847 848
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

849
	activeControl: IVisibleEditor;
850
	activeTextEditorWidget: any;
851
	activeEditor: IEditorInput;
852
	editors: ReadonlyArray<IEditorInput> = [];
M
Matt Bierner 已提交
853
	visibleControls: ReadonlyArray<IVisibleEditor> = [];
854
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
855
	visibleEditors: ReadonlyArray<IEditorInput> = [];
856

857
	overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
R
Rob Lourens 已提交
858
		return toDisposable(() => undefined);
859 860
	}

861 862
	openEditor(_editor: any, _options?: any, _group?: any): Promise<any> {
		throw new Error('not implemented');
863 864
	}

865 866
	openEditors(_editors: any, _group?: any): Promise<IEditor[]> {
		throw new Error('not implemented');
867 868
	}

869
	isOpen(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
870 871 872
		return false;
	}

873
	getOpened(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): IEditorInput {
874
		throw new Error('not implemented');
875 876
	}

877
	replaceEditors(_editors: any, _group: any) {
R
Rob Lourens 已提交
878
		return Promise.resolve(undefined);
879 880
	}

881
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
882
		throw new Error('not implemented');
883 884
	}

885
	createInput(_input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
886
		throw new Error('not implemented');
887 888 889
	}
}

890 891 892 893
export class TestFileService implements IFileService {

	public _serviceBrand: any;

894 895
	public encoding: IResourceEncodings;

M
Matt Bierner 已提交
896 897
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
898

899 900
	readonly onWillActivateFileSystemProvider = Event.None;

901 902
	private content = 'Hello Html';

903 904 905 906 907
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

908 909 910 911 912 913 914 915
	public setContent(content: string): void {
		this.content = content;
	}

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

916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931
	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);
	}

932 933
	resolveFile(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat>;
	resolveFile(resource: URI, _options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
J
Johannes Rieken 已提交
934
	resolveFile(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat> {
B
Benjamin Pasero 已提交
935
		return Promise.resolve({
936 937
			resource,
			etag: Date.now().toString(),
B
Benjamin Pasero 已提交
938
			encoding: 'utf8',
B
Benjamin Pasero 已提交
939
			mtime: Date.now(),
940
			size: 42,
941
			isDirectory: false,
B
Benjamin Pasero 已提交
942
			name: resources.basename(resource)
B
Benjamin Pasero 已提交
943
		});
944
	}
B
Benjamin Pasero 已提交
945

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

J
Johannes Rieken 已提交
950
	existsFile(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
951
		return Promise.resolve(true);
952
	}
B
Benjamin Pasero 已提交
953

J
Johannes Rieken 已提交
954
	resolveContent(resource: URI, _options?: IResolveContentOptions): Promise<IContent> {
B
Benjamin Pasero 已提交
955
		return Promise.resolve({
B
Benjamin Pasero 已提交
956
			resource: resource,
957
			value: this.content,
958
			etag: 'index.txt',
B
Benjamin Pasero 已提交
959 960
			encoding: 'utf8',
			mtime: Date.now(),
961 962
			name: resources.basename(resource),
			size: 1
E
Erich Gamma 已提交
963
		});
964
	}
E
Erich Gamma 已提交
965

J
Johannes Rieken 已提交
966
	resolveStreamContent(resource: URI, _options?: IResolveContentOptions): Promise<IStreamContent> {
B
Benjamin Pasero 已提交
967
		return Promise.resolve({
A
Alex Dima 已提交
968 969
			resource: resource,
			value: {
970
				on: (event: string, callback: Function): void => {
A
Alex Dima 已提交
971
					if (event === 'data') {
972
						callback(this.content);
A
Alex Dima 已提交
973 974 975 976 977 978 979 980
					}
					if (event === 'end') {
						callback();
					}
				}
			},
			etag: 'index.txt',
			encoding: 'utf8',
B
Benjamin Pasero 已提交
981
			mtime: Date.now(),
982
			size: 1,
B
Benjamin Pasero 已提交
983
			name: resources.basename(resource)
A
Alex Dima 已提交
984
		});
985 986
	}

987
	updateContent(resource: URI, _value: string | ITextSnapshot, _options?: IUpdateContentOptions): Promise<IFileStatWithMetadata> {
B
Benjamin Pasero 已提交
988
		return timeout(0).then(() => ({
989 990 991 992
			resource,
			etag: 'index.txt',
			encoding: 'utf8',
			mtime: Date.now(),
993
			size: 42,
994
			isDirectory: false,
B
Benjamin Pasero 已提交
995
			name: resources.basename(resource)
B
Benjamin Pasero 已提交
996
		}));
997
	}
D
Daniel Imms 已提交
998

B
Benjamin Pasero 已提交
999
	moveFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> {
1000
		return Promise.resolve(null!);
1001
	}
D
Daniel Imms 已提交
1002

B
Benjamin Pasero 已提交
1003
	copyFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> {
1004
		throw new Error('not implemented');
1005
	}
D
Daniel Imms 已提交
1006

1007
	createFile(_resource: URI, _content?: string, _options?: ICreateFileOptions): Promise<IFileStatWithMetadata> {
1008
		throw new Error('not implemented');
E
Erich Gamma 已提交
1009
	}
1010

1011
	createFolder(_resource: URI): Promise<IFileStatWithMetadata> {
1012
		throw new Error('not implemented');
1013 1014
	}

1015 1016
	onDidChangeFileSystemProviderRegistrations = Event.None;

B
Benjamin Pasero 已提交
1017
	registerProvider(_scheme: string, _provider: IFileSystemProvider) {
1018 1019 1020
		return { dispose() { } };
	}

1021 1022
	activateProvider(_scheme: string): Promise<void> {
		throw new Error('not implemented');
1023 1024
	}

1025 1026 1027 1028
	canHandleResource(resource: URI): boolean {
		return resource.scheme === 'file';
	}

1029 1030
	hasCapability(resource: URI, capability: FileSystemProviderCapabilities): Promise<boolean> { return Promise.resolve(false); }

J
Johannes Rieken 已提交
1031
	del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
1032
		return Promise.resolve();
1033 1034
	}

1035
	watchFileChanges(_resource: URI): void {
1036 1037
	}

1038
	unwatchFileChanges(_resource: URI): void {
1039 1040
	}

1041 1042
	getWriteEncoding(_resource: URI): IResourceEncoding {
		return { encoding: 'utf8', hasBOM: false };
1043
	}
D
Daniel Imms 已提交
1044

1045
	dispose(): void {
E
Erich Gamma 已提交
1046
	}
1047
}
1048

1049 1050
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
1051

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

J
Johannes Rieken 已提交
1056
	public hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
1057
		return Promise.resolve(false);
1058 1059
	}

1060
	public loadBackupResource(resource: URI): Promise<URI | undefined> {
B
Benjamin Pasero 已提交
1061 1062
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
1063
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
1064 1065
			}

R
Rob Lourens 已提交
1066
			return undefined;
B
Benjamin Pasero 已提交
1067 1068 1069
		});
	}

J
Johannes Rieken 已提交
1070
	public registerResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1071
		return Promise.resolve();
D
Daniel Imms 已提交
1072 1073
	}

J
Johannes Rieken 已提交
1074
	public deregisterResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1075
		return Promise.resolve();
D
Daniel Imms 已提交
1076 1077
	}

1078
	public toBackupResource(_resource: URI): URI {
1079
		throw new Error('not implemented');
D
Daniel Imms 已提交
1080
	}
1081

J
Johannes Rieken 已提交
1082
	public backupResource(_resource: URI, _content: ITextSnapshot): Promise<void> {
B
Benjamin Pasero 已提交
1083
		return Promise.resolve();
1084 1085
	}

J
Johannes Rieken 已提交
1086
	public getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
1087
		return Promise.resolve([]);
1088 1089
	}

1090 1091 1092 1093 1094
	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);
1095 1096
	}

J
Johannes Rieken 已提交
1097
	public resolveBackupContent(_backup: URI): Promise<ITextBufferFactory> {
1098
		throw new Error('not implemented');
1099 1100
	}

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

J
Johannes Rieken 已提交
1105
	public discardAllWorkspaceBackups(): Promise<void> {
B
Benjamin Pasero 已提交
1106
		return Promise.resolve();
1107
	}
1108
}
D
Daniel Imms 已提交
1109

B
Benjamin Pasero 已提交
1110 1111 1112 1113 1114 1115 1116
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 已提交
1117
	onDidChangeTransientModelProperty: Event<ITextModel> = Event.None;
B
Benjamin Pasero 已提交
1118

1119 1120
	addCodeEditor(_editor: ICodeEditor): void { }
	removeCodeEditor(_editor: ICodeEditor): void { }
B
Benjamin Pasero 已提交
1121
	listCodeEditors(): ICodeEditor[] { return []; }
1122 1123
	addDiffEditor(_editor: IDiffEditor): void { }
	removeDiffEditor(_editor: IDiffEditor): void { }
B
Benjamin Pasero 已提交
1124
	listDiffEditors(): IDiffEditor[] { return []; }
1125
	getFocusedCodeEditor(): ICodeEditor | null { return null; }
1126 1127 1128 1129 1130
	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) { }
1131 1132
	getActiveCodeEditor(): ICodeEditor | null { return null; }
	openCodeEditor(_input: IResourceInput, _source: ICodeEditor, _sideBySide?: boolean): Promise<ICodeEditor | null> { return Promise.resolve(null); }
B
Benjamin Pasero 已提交
1133 1134
}

1135 1136 1137 1138
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

1139
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
S
SteVen Batten 已提交
1140
	onDidChangeMaximize: Event<boolean>;
1141

1142 1143
	hasFocus = true;

J
Johannes Rieken 已提交
1144
	isFocused(): Promise<boolean> {
B
Benjamin Pasero 已提交
1145
		return Promise.resolve(false);
1146 1147
	}

J
Johannes Rieken 已提交
1148
	isMaximized(): Promise<boolean> {
B
Benjamin Pasero 已提交
1149
		return Promise.resolve(false);
S
SteVen Batten 已提交
1150 1151
	}

1152 1153 1154 1155
	getConfiguration(): IWindowConfiguration {
		return Object.create(null);
	}

1156 1157 1158 1159
	getCurrentWindowId(): number {
		return 0;
	}

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

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

J
Johannes Rieken 已提交
1168
	pickFolderAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1169
		return Promise.resolve();
1170 1171
	}

J
Johannes Rieken 已提交
1172
	pickWorkspaceAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1173
		return Promise.resolve();
1174 1175
	}

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

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

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

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

M
Matt Bierner 已提交
1192
	enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1193
		return Promise.resolve(undefined);
1194 1195
	}

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

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

J
Johannes Rieken 已提交
1204
	getRecentlyOpened(): Promise<IRecentlyOpened> {
1205 1206 1207 1208
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1209 1210
	}

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

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

J
Johannes Rieken 已提交
1219
	unmaximizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1220
		return Promise.resolve();
S
SteVen Batten 已提交
1221 1222
	}

J
Johannes Rieken 已提交
1223
	minimizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1224
		return Promise.resolve();
S
SteVen Batten 已提交
1225 1226
	}

M
Martin Aeschlimann 已提交
1227
	openWindow(_uris: IURIToOpen[], _options?: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1228
		return Promise.resolve();
B
Benjamin Pasero 已提交
1229 1230
	}

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

J
Johannes Rieken 已提交
1235
	setDocumentEdited(_flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1236
		return Promise.resolve();
1237 1238
	}

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

J
Johannes Rieken 已提交
1243
	show(): Promise<void> {
B
Benjamin Pasero 已提交
1244
		return Promise.resolve();
J
Joao 已提交
1245 1246
	}

J
Johannes Rieken 已提交
1247
	showMessageBox(_options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
B
Benjamin Pasero 已提交
1248
		return Promise.resolve({ button: 0 });
1249 1250
	}

J
Johannes Rieken 已提交
1251
	showSaveDialog(_options: Electron.SaveDialogOptions): Promise<string> {
1252
		throw new Error('not implemented');
1253
	}
1254

J
Johannes Rieken 已提交
1255
	showOpenDialog(_options: Electron.OpenDialogOptions): Promise<string[]> {
1256
		throw new Error('not implemented');
1257
	}
1258

J
Johannes Rieken 已提交
1259
	updateTouchBar(_items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1260
		return Promise.resolve();
1261
	}
1262 1263

	resolveProxy(url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1264
		return Promise.resolve(undefined);
1265
	}
1266 1267
}

1268 1269
export class TestLifecycleService implements ILifecycleService {

1270
	public _serviceBrand: any;
1271

1272
	public phase: LifecyclePhase;
1273
	public startupKind: StartupKind;
1274

1275
	private _onBeforeShutdown = new Emitter<BeforeShutdownEvent>();
1276
	private _onWillShutdown = new Emitter<WillShutdownEvent>();
1277
	private _onShutdown = new Emitter<void>();
1278

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

1283
	public fireShutdown(reason = ShutdownReason.QUIT): void {
1284
		this._onWillShutdown.fire({
1285 1286 1287
			join: () => { },
			reason
		});
1288 1289
	}

1290 1291 1292 1293 1294 1295
	public fireWillShutdown(event: BeforeShutdownEvent): void {
		this._onBeforeShutdown.fire(event);
	}

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

1298
	public get onWillShutdown(): Event<WillShutdownEvent> {
1299 1300 1301
		return this._onWillShutdown.event;
	}

1302
	public get onShutdown(): Event<void> {
1303 1304
		return this._onShutdown.event;
	}
1305 1306
}

1307 1308 1309 1310
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1311 1312
	public windowCount = 1;

1313 1314
	onWindowOpen: Event<number>;
	onWindowFocus: Event<number>;
1315
	onWindowBlur: Event<number>;
S
SteVen Batten 已提交
1316 1317
	onWindowMaximize: Event<number>;
	onWindowUnmaximize: Event<number>;
S
SteVen Batten 已提交
1318
	onRecentlyOpenedChange: Event<void>;
1319

J
Johannes Rieken 已提交
1320
	isFocused(_windowId: number): Promise<boolean> {
B
Benjamin Pasero 已提交
1321
		return Promise.resolve(false);
1322 1323
	}

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

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

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

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

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

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

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

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

1356
	enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1357
		return Promise.resolve(undefined);
1358 1359
	}

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

J
Johannes Rieken 已提交
1364
	setRepresentedFilename(_windowId: number, _fileName: string): Promise<void> {
B
Benjamin Pasero 已提交
1365
		return Promise.resolve();
1366
	}
1367

M
Martin Aeschlimann 已提交
1368
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
B
Benjamin Pasero 已提交
1369
		return Promise.resolve();
1370
	}
1371

J
Johannes Rieken 已提交
1372
	removeFromRecentlyOpened(_paths: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1373
		return Promise.resolve();
1374
	}
1375

J
Johannes Rieken 已提交
1376
	clearRecentlyOpened(): Promise<void> {
B
Benjamin Pasero 已提交
1377
		return Promise.resolve();
C
22768  
Cristian 已提交
1378
	}
1379

J
Johannes Rieken 已提交
1380
	getRecentlyOpened(_windowId: number): Promise<IRecentlyOpened> {
1381 1382 1383 1384
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1385
	}
1386

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

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

J
Johannes Rieken 已提交
1395
	isMaximized(_windowId: number): Promise<boolean> {
1396
		return Promise.resolve(false);
1397
	}
1398

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

J
Johannes Rieken 已提交
1403
	minimizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1404
		return Promise.resolve();
S
SteVen Batten 已提交
1405 1406
	}

J
Johannes Rieken 已提交
1407
	unmaximizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1408
		return Promise.resolve();
1409
	}
1410

J
Johannes Rieken 已提交
1411
	onWindowTitleDoubleClick(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1412
		return Promise.resolve();
1413
	}
1414

J
Johannes Rieken 已提交
1415
	setDocumentEdited(_windowId: number, _flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1416
		return Promise.resolve();
1417
	}
1418

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

J
Johannes Rieken 已提交
1423
	relaunch(_options: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
B
Benjamin Pasero 已提交
1424
		return Promise.resolve();
J
Johannes Rieken 已提交
1425
	}
1426

J
Johannes Rieken 已提交
1427
	whenSharedProcessReady(): Promise<void> {
B
Benjamin Pasero 已提交
1428
		return Promise.resolve();
1429
	}
1430

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

1435
	// Global methods
M
Martin Aeschlimann 已提交
1436
	openWindow(_windowId: number, _uris: IURIToOpen[], _options: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1437
		return Promise.resolve();
1438
	}
1439

J
Johannes Rieken 已提交
1440
	openNewWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1441
		return Promise.resolve();
1442
	}
1443

J
Johannes Rieken 已提交
1444
	showWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1445
		return Promise.resolve();
1446
	}
1447

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

J
Johannes Rieken 已提交
1452
	getWindowCount(): Promise<number> {
B
Benjamin Pasero 已提交
1453
		return Promise.resolve(this.windowCount);
1454
	}
1455

J
Johannes Rieken 已提交
1456
	log(_severity: string, ..._messages: string[]): Promise<void> {
B
Benjamin Pasero 已提交
1457
		return Promise.resolve();
1458
	}
1459

M
Martin Aeschlimann 已提交
1460
	showItemInFolder(_path: URI): Promise<void> {
B
Benjamin Pasero 已提交
1461
		return Promise.resolve();
1462 1463
	}

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

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

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

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

J
Johannes Rieken 已提交
1480
	mergeAllWindowTabs(): Promise<void> {
B
Benjamin Pasero 已提交
1481
		return Promise.resolve();
1482 1483
	}

J
Johannes Rieken 已提交
1484
	toggleWindowTabsBar(): Promise<void> {
B
Benjamin Pasero 已提交
1485
		return Promise.resolve();
1486 1487
	}

J
Johannes Rieken 已提交
1488
	updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1489
		return Promise.resolve();
1490 1491
	}

J
Johannes Rieken 已提交
1492
	getActiveWindowId(): Promise<number | undefined> {
B
Benjamin Pasero 已提交
1493
		return Promise.resolve(undefined);
J
Joao Moreno 已提交
1494 1495
	}

1496 1497
	// This needs to be handled from browser process to prevent
	// foreground ordering issues on Windows
J
Johannes Rieken 已提交
1498
	openExternal(_url: string): Promise<boolean> {
B
Benjamin Pasero 已提交
1499
		return Promise.resolve(true);
1500 1501 1502
	}

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

J
Johannes Rieken 已提交
1507
	showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
1508
		throw new Error('not implemented');
1509 1510
	}

J
Johannes Rieken 已提交
1511
	showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): Promise<string> {
1512
		throw new Error('not implemented');
1513 1514
	}

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

J
Johannes Rieken 已提交
1519
	openAboutDialog(): Promise<void> {
B
Benjamin Pasero 已提交
1520
		return Promise.resolve();
J
Joao Moreno 已提交
1521
	}
1522 1523

	resolveProxy(windowId: number, url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1524
		return Promise.resolve(undefined);
1525
	}
1526
}
B
Benjamin Pasero 已提交
1527

1528 1529 1530 1531 1532 1533 1534
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1535
	public onDidChangeConfiguration() {
1536 1537 1538
		return { dispose() { } };
	}

1539
	getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
1540 1541
		const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;
		const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
1542
		return this.configurationService.getValue(section, { resource });
1543
	}
B
Benjamin Pasero 已提交
1544 1545
}

S
Sandeep Somavarapu 已提交
1546 1547 1548 1549 1550
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

	_serviceBrand: any;

	constructor(
1551
		@IConfigurationService private readonly configurationService: IConfigurationService,
S
Sandeep Somavarapu 已提交
1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566
	) {
	}

	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 已提交
1567 1568 1569
export class TestHashService implements IHashService {
	_serviceBrand: any;

1570 1571
	createSHA1(content: string): Thenable<string> {
		return Promise.resolve(content);
R
Ramya Achutha Rao 已提交
1572
	}
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583
}

export class TestSharedProcessService implements ISharedProcessService {

	_serviceBrand: ServiceIdentifier<any>;

	getChannel(channelName: string): any {
		return undefined;
	}

	registerChannel(channelName: string, channel: any): void { }
1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605
}

export class NullFileSystemProvider implements IFileSystemProvider {

	capabilities: FileSystemProviderCapabilities = FileSystemProviderCapabilities.Readonly;

	onDidChangeCapabilities: Event<void> = Event.None;
	onDidChangeFile: Event<IFileChange[]> = Event.None;

	watch(resource: URI, opts: IWatchOptions): IDisposable { return Disposable.None; }
	stat(resource: URI): Promise<IStat> { return Promise.resolve(undefined!); }
	mkdir(resource: URI): Promise<void> { return Promise.resolve(undefined!); }
	readdir(resource: URI): Promise<[string, FileType][]> { return Promise.resolve(undefined!); }
	delete(resource: URI, opts: FileDeleteOptions): Promise<void> { return Promise.resolve(undefined!); }
	rename(from: URI, to: URI, opts: FileOverwriteOptions): Promise<void> { return Promise.resolve(undefined!); }
	copy?(from: URI, to: URI, opts: FileOverwriteOptions): Promise<void> { return Promise.resolve(undefined!); }
	readFile?(resource: URI): Promise<Uint8Array> { return Promise.resolve(undefined!); }
	writeFile?(resource: URI, content: Uint8Array, opts: FileWriteOptions): Promise<void> { return Promise.resolve(undefined!); }
	open?(resource: URI, opts: FileOpenOptions): Promise<number> { return Promise.resolve(undefined!); }
	close?(fd: number): Promise<void> { return Promise.resolve(undefined!); }
	read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return Promise.resolve(undefined!); }
	write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return Promise.resolve(undefined!); }
1606
}