workbenchTestServices.ts 50.6 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 { FileOperationEvent, IFileService, IReadTextFileOptions, FileOperationError, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, IContent, ICreateFileOptions, ITextSnapshot, IResourceEncoding, IFileSystemProvider, FileSystemProviderCapabilities, IFileChange, IWatchOptions, IStat, FileType, FileDeleteOptions, FileOverwriteOptions, FileWriteOptions, FileOpenOptions, IFileStatWithMetadata, IResolveMetadataFileOptions, IWriteFileOptions, IReadFileOptions, IFileContent, IFileStreamContent } from 'vs/platform/files/common/files';
29
import { IModelService } from 'vs/editor/common/services/modelService';
30
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
J
Johannes Rieken 已提交
31
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
32
import { ITextFileStreamContent, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
J
Johannes Rieken 已提交
33 34 35
import { parseArgs } from 'vs/platform/environment/node/argv';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
36
import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
37
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
38
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, MenuBarVisibility, IURIToOpen, IOpenSettings, IWindowConfiguration } from 'vs/platform/windows/common/windows';
S
Sandeep Somavarapu 已提交
39
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
40
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
B
Benjamin Pasero 已提交
41
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
42
import { IThemeService } from 'vs/platform/theme/common/themeService';
B
Benjamin Pasero 已提交
43
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
44
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
M
Martin Aeschlimann 已提交
45
import { IRecentlyOpened, IRecent } from 'vs/platform/history/common/history';
S
Sandeep Somavarapu 已提交
46
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
47
import { IPosition, Position as EditorPosition } from 'vs/editor/common/core/position';
B
Benjamin Pasero 已提交
48
import { IMenuService, MenuId, IMenu, ISerializableCommandAction } from 'vs/platform/actions/common/actions';
I
isidor 已提交
49
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
B
Benjamin Pasero 已提交
50
import { MockContextKeyService, MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
B
Benjamin Pasero 已提交
51
import { ITextBufferFactory, DefaultEndOfLine, EndOfLinePreference, IModelDecorationOptions, ITextModel } from 'vs/editor/common/model';
52
import { Range } from 'vs/editor/common/core/range';
M
Martin Aeschlimann 已提交
53
import { IConfirmation, IConfirmationResult, IDialogService, IDialogOptions, IPickAndOpenOptions, ISaveDialogOptions, IOpenDialogOptions, IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
54 55
import { INotificationService } from 'vs/platform/notification/common/notification';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
56
import { IExtensionService, NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
B
Benjamin Pasero 已提交
57
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
B
Benjamin Pasero 已提交
58
import { IDecorationsService, IResourceDecorationChangeEvent, IDecoration, IDecorationData, IDecorationsProvider } from 'vs/workbench/services/decorations/browser/decorations';
J
Joao Moreno 已提交
59
import { IDisposable, toDisposable, Disposable } from 'vs/base/common/lifecycle';
60
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, EditorsOrder, IFindGroupScope, EditorGroupLayout, ICloseEditorOptions } from 'vs/workbench/services/editor/common/editorGroupsService';
61
import { IEditorService, IOpenEditorOverrideHandler, IVisibleEditor } from 'vs/workbench/services/editor/common/editorService';
B
Benjamin Pasero 已提交
62 63 64
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 已提交
65
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
66
import { Dimension } from 'vs/base/browser/dom';
67
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
I
isidor 已提交
68
import { ILabelService } from 'vs/platform/label/common/label';
69
import { timeout } from 'vs/base/common/async';
70
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
71
import { ViewletDescriptor, Viewlet } from 'vs/workbench/browser/viewlet';
72
import { IViewlet } from 'vs/workbench/common/viewlet';
73
import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/common/storage';
S
Sandeep Somavarapu 已提交
74
import { isLinux, isMacintosh } from 'vs/base/common/platform';
I
isidor 已提交
75
import { LabelService } from 'vs/workbench/services/label/common/labelService';
B
Benjamin Pasero 已提交
76
import { IDimension } from 'vs/platform/layout/browser/layoutService';
77
import { Part } from 'vs/workbench/browser/part';
78 79 80
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';
81
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
82 83
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
84
import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
B
Benjamin Pasero 已提交
85
import { BrowserTextFileService } from 'vs/workbench/services/textfile/browser/textFileService';
B
Benjamin Pasero 已提交
86

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

91
export const TestEnvironmentService = new WorkbenchEnvironmentService(parseArgs(process.argv) as IWindowConfiguration, process.execPath);
92

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	public updateOptions() {

	}

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

		return false;
	}

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

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

B
Benjamin Pasero 已提交
179
export class TestTextFileService extends BrowserTextFileService {
180 181
	public cleanupBackupsBeforeShutdownCalled: boolean;

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

	constructor(
187
		@IWorkspaceContextService contextService: IWorkspaceContextService,
188
		@IFileService protected fileService: IFileService,
189
		@IUntitledEditorService untitledEditorService: IUntitledEditorService,
190
		@ILifecycleService lifecycleService: ILifecycleService,
191
		@IInstantiationService instantiationService: IInstantiationService,
192 193 194
		@IConfigurationService configurationService: IConfigurationService,
		@IModeService modeService: IModeService,
		@IModelService modelService: IModelService,
195
		@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
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
		super(
			contextService,
			fileService,
			untitledEditorService,
			lifecycleService,
			instantiationService,
			configurationService,
			modeService,
			modelService,
			environmentService,
			notificationService,
			backupFileService,
			windowsService,
			historyService,
			contextKeyService,
			dialogService,
			fileDialogService,
			editorService
		);
A
Alex Dima 已提交
224
	}
225

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

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

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

238
	public readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {
239 240 241 242
		if (this.resolveTextContentError) {
			const error = this.resolveTextContentError;
			this.resolveTextContentError = null;

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

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

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

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

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

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

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

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

	return instantiationService;
}

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

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

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

export class TestMenuService implements IMenuService {

	public _serviceBrand: any;

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

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

	public _serviceBrand: any;

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

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

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

373 374 375
	public last(): void {
	}

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

	public clear(): void {
	}

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

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

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

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

	public openLastEditLocation(): void {
	}
B
Benjamin Pasero 已提交
399 400
}

401
export class TestDialogService implements IDialogService {
402 403

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

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

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

M
Martin Aeschlimann 已提交
414 415 416 417
export class TestFileDialogService implements IFileDialogService {

	public _serviceBrand: any;

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

447
export class TestLayoutService implements IWorkbenchLayoutService {
B
Benjamin Pasero 已提交
448

449
	public _serviceBrand: any;
E
Erich Gamma 已提交
450

451 452
	dimension: IDimension = { width: 800, height: 600 };

453 454
	container: HTMLElement = window.document.body;

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

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

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

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

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

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

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

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

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

489 490 491 492
	public getTitleBarOffset(): number {
		return 0;
	}

493 494 495 496
	public isStatusBarHidden(): boolean {
		return false;
	}

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

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

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

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

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

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

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

I
isidor 已提交
517 518
	public toggleMaximizedPanel(): void { }

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

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

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

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

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

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

I
isidor 已提交
543
	public toggleZenMode(): void { }
544

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


549
	public resizePart(_part: Parts, _sizeChange: number): void { }
550 551

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

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
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!;
	}
599 600 601 602

	public hideActiveViewlet(): void { }

	public getLastActiveViewletId(): string {
M
Matt Bierner 已提交
603
		return undefined!;
604
	}
605 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
}

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 已提交
641
		return undefined!;
642
	}
E
Erich Gamma 已提交
643 644
}

645
export class TestStorageService extends InMemoryStorageService { }
646

647 648
export class TestEditorGroupsService implements IEditorGroupsService {

649 650
	_serviceBrand: ServiceIdentifier<any>;

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

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

	orientation: any;
R
Rob Lourens 已提交
661
	whenRestored: Promise<void> = Promise.resolve(undefined);
B
Benjamin Pasero 已提交
662
	willRestoreEditors = false;
663

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

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

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

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

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

685
		return undefined!;
686 687
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

	centerLayout(active: boolean): void { }

	isLayoutCentered(): boolean {
		return false;
	}

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

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

	constructor(public id: number) { }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	focus(): void { }

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

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

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

	_serviceBrand: ServiceIdentifier<any>;

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

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

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

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

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

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

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

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

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

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

889 890 891 892
export class TestFileService implements IFileService {

	public _serviceBrand: any;

M
Matt Bierner 已提交
893 894
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
895

896
	readonly onWillActivateFileSystemProvider = Event.None;
897
	readonly onError: Event<Error> = Event.None;
898

899 900
	private content = 'Hello Html';

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

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

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

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

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

B
Benjamin Pasero 已提交
944 945
	resolveAll(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
		return Promise.all(toResolve.map(resourceAndOption => this.resolve(resourceAndOption.resource, resourceAndOption.options))).then(stats => stats.map(stat => ({ stat, success: true })));
I
isidor 已提交
946 947
	}

B
Benjamin Pasero 已提交
948
	exists(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
949
		return Promise.resolve(true);
950
	}
B
Benjamin Pasero 已提交
951

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

964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986
	readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
		return Promise.resolve({
			resource: resource,
			value: VSBuffer.fromString(this.content),
			etag: 'index.txt',
			encoding: 'utf8',
			mtime: Date.now(),
			name: resources.basename(resource),
			size: 1
		});
	}

	readFileStream(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileStreamContent> {
		return Promise.resolve({
			resource: resource,
			value: {
				on: (event: string, callback: Function): void => {
					if (event === 'data') {
						callback(this.content);
					}
					if (event === 'end') {
						callback();
					}
B
Benjamin Pasero 已提交
987 988 989 990
				},
				resume: () => { },
				pause: () => { },
				destroy: () => { }
991 992 993 994 995 996 997 998 999
			},
			etag: 'index.txt',
			encoding: 'utf8',
			mtime: Date.now(),
			size: 1,
			name: resources.basename(resource)
		});
	}

1000
	writeFile(resource: URI, bufferOrReadable: VSBuffer | VSBufferReadable, options?: IWriteFileOptions): Promise<IFileStatWithMetadata> {
B
Benjamin Pasero 已提交
1001
		return timeout(0).then(() => ({
1002 1003 1004 1005
			resource,
			etag: 'index.txt',
			encoding: 'utf8',
			mtime: Date.now(),
1006
			size: 42,
1007
			isDirectory: false,
B
Benjamin Pasero 已提交
1008
			name: resources.basename(resource)
B
Benjamin Pasero 已提交
1009
		}));
1010
	}
D
Daniel Imms 已提交
1011

B
Benjamin Pasero 已提交
1012
	move(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> {
1013
		return Promise.resolve(null!);
1014
	}
D
Daniel Imms 已提交
1015

B
Benjamin Pasero 已提交
1016
	copy(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> {
1017
		throw new Error('not implemented');
1018
	}
D
Daniel Imms 已提交
1019

1020
	createFile(_resource: URI, _content?: VSBuffer | VSBufferReadable, _options?: ICreateFileOptions): Promise<IFileStatWithMetadata> {
1021 1022 1023
		throw new Error('not implemented');
	}

1024
	createFolder(_resource: URI): Promise<IFileStatWithMetadata> {
1025
		throw new Error('not implemented');
1026 1027
	}

1028 1029
	onDidChangeFileSystemProviderRegistrations = Event.None;

B
Benjamin Pasero 已提交
1030
	registerProvider(_scheme: string, _provider: IFileSystemProvider) {
1031 1032 1033
		return { dispose() { } };
	}

1034 1035
	activateProvider(_scheme: string): Promise<void> {
		throw new Error('not implemented');
1036 1037
	}

1038 1039 1040 1041
	canHandleResource(resource: URI): boolean {
		return resource.scheme === 'file';
	}

1042
	hasCapability(resource: URI, capability: FileSystemProviderCapabilities): boolean { return false; }
1043

J
Johannes Rieken 已提交
1044
	del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
1045
		return Promise.resolve();
1046 1047
	}

1048 1049
	watch(_resource: URI): IDisposable {
		return Disposable.None;
1050 1051
	}

1052 1053
	getWriteEncoding(_resource: URI): IResourceEncoding {
		return { encoding: 'utf8', hasBOM: false };
1054
	}
D
Daniel Imms 已提交
1055

1056
	dispose(): void {
E
Erich Gamma 已提交
1057
	}
1058
}
1059

1060 1061
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
1062

J
Johannes Rieken 已提交
1063
	public hasBackups(): Promise<boolean> {
B
Benjamin Pasero 已提交
1064
		return Promise.resolve(false);
1065 1066
	}

J
Johannes Rieken 已提交
1067
	public hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
1068
		return Promise.resolve(false);
1069 1070
	}

1071
	public loadBackupResource(resource: URI): Promise<URI | undefined> {
B
Benjamin Pasero 已提交
1072 1073
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
1074
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
1075 1076
			}

R
Rob Lourens 已提交
1077
			return undefined;
B
Benjamin Pasero 已提交
1078 1079 1080
		});
	}

J
Johannes Rieken 已提交
1081
	public registerResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1082
		return Promise.resolve();
D
Daniel Imms 已提交
1083 1084
	}

J
Johannes Rieken 已提交
1085
	public deregisterResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1086
		return Promise.resolve();
D
Daniel Imms 已提交
1087 1088
	}

1089
	public toBackupResource(_resource: URI): URI {
1090
		throw new Error('not implemented');
D
Daniel Imms 已提交
1091
	}
1092

J
Johannes Rieken 已提交
1093
	public backupResource(_resource: URI, _content: ITextSnapshot): Promise<void> {
B
Benjamin Pasero 已提交
1094
		return Promise.resolve();
1095 1096
	}

J
Johannes Rieken 已提交
1097
	public getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
1098
		return Promise.resolve([]);
1099 1100
	}

1101 1102 1103 1104 1105
	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);
1106 1107
	}

J
Johannes Rieken 已提交
1108
	public resolveBackupContent(_backup: URI): Promise<ITextBufferFactory> {
1109
		throw new Error('not implemented');
1110 1111
	}

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

J
Johannes Rieken 已提交
1116
	public discardAllWorkspaceBackups(): Promise<void> {
B
Benjamin Pasero 已提交
1117
		return Promise.resolve();
1118
	}
1119
}
D
Daniel Imms 已提交
1120

B
Benjamin Pasero 已提交
1121 1122 1123 1124 1125 1126 1127
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 已提交
1128
	onDidChangeTransientModelProperty: Event<ITextModel> = Event.None;
B
Benjamin Pasero 已提交
1129

1130 1131
	addCodeEditor(_editor: ICodeEditor): void { }
	removeCodeEditor(_editor: ICodeEditor): void { }
B
Benjamin Pasero 已提交
1132
	listCodeEditors(): ICodeEditor[] { return []; }
1133 1134
	addDiffEditor(_editor: IDiffEditor): void { }
	removeDiffEditor(_editor: IDiffEditor): void { }
B
Benjamin Pasero 已提交
1135
	listDiffEditors(): IDiffEditor[] { return []; }
1136
	getFocusedCodeEditor(): ICodeEditor | null { return null; }
1137 1138 1139 1140 1141
	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) { }
1142 1143
	getActiveCodeEditor(): ICodeEditor | null { return null; }
	openCodeEditor(_input: IResourceInput, _source: ICodeEditor, _sideBySide?: boolean): Promise<ICodeEditor | null> { return Promise.resolve(null); }
B
Benjamin Pasero 已提交
1144 1145
}

1146 1147 1148 1149
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

1150
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
S
SteVen Batten 已提交
1151
	onDidChangeMaximize: Event<boolean>;
1152

1153 1154
	hasFocus = true;

1155 1156
	readonly windowId = 0;

J
Johannes Rieken 已提交
1157
	isFocused(): Promise<boolean> {
B
Benjamin Pasero 已提交
1158
		return Promise.resolve(false);
1159 1160
	}

J
Johannes Rieken 已提交
1161
	isMaximized(): Promise<boolean> {
B
Benjamin Pasero 已提交
1162
		return Promise.resolve(false);
S
SteVen Batten 已提交
1163 1164
	}

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

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

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

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

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

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

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

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

M
Matt Bierner 已提交
1197
	enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1198
		return Promise.resolve(undefined);
1199 1200
	}

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

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

J
Johannes Rieken 已提交
1209
	getRecentlyOpened(): Promise<IRecentlyOpened> {
1210 1211 1212 1213
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1214 1215
	}

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

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

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

J
Johannes Rieken 已提交
1228
	minimizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1229
		return Promise.resolve();
S
SteVen Batten 已提交
1230 1231
	}

M
Martin Aeschlimann 已提交
1232
	openWindow(_uris: IURIToOpen[], _options?: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1233
		return Promise.resolve();
B
Benjamin Pasero 已提交
1234 1235
	}

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

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

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

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

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

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

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

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

1269 1270
export class TestLifecycleService implements ILifecycleService {

1271
	public _serviceBrand: any;
1272

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

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

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

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

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

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

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

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

1308 1309 1310 1311
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1312 1313
	public windowCount = 1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1525 1526 1527 1528 1529 1530 1531
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1532
	public onDidChangeConfiguration() {
1533 1534 1535
		return { dispose() { } };
	}

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

S
Sandeep Somavarapu 已提交
1543 1544 1545 1546 1547
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

	_serviceBrand: any;

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

	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';
	}
}


1564 1565 1566 1567 1568 1569 1570 1571 1572
export class TestSharedProcessService implements ISharedProcessService {

	_serviceBrand: ServiceIdentifier<any>;

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

	registerChannel(channelName: string, channel: any): void { }
1573 1574 1575 1576 1577 1578 1579 1580 1581
}

export class NullFileSystemProvider implements IFileSystemProvider {

	capabilities: FileSystemProviderCapabilities = FileSystemProviderCapabilities.Readonly;

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

1582 1583 1584
	constructor(private disposableFactory: () => IDisposable = () => Disposable.None) { }

	watch(resource: URI, opts: IWatchOptions): IDisposable { return this.disposableFactory(); }
1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596
	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!); }
1597
}