workbenchTestServices.ts 52.3 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, IResolvedBackup } 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, FileOperationError, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, ICreateFileOptions, 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, IResourceEncoding, IReadTextFileOptions } 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';
B
Benjamin Pasero 已提交
40
import { createTextBufferFactoryFromStream } from 'vs/editor/common/model/textModel';
41
import { IEnvironmentService, ParsedArgs } 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';
51
import { ITextBufferFactory, DefaultEndOfLine, EndOfLinePreference, IModelDecorationOptions, ITextModel, ITextSnapshot } 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';
S
Sandeep Somavarapu 已提交
67
import { ILogService, NullLogService } 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';
74
import { isLinux, isMacintosh, IProcessEnvironment } 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 { NodeTextFileService } from 'vs/workbench/services/textfile/node/textFileService';
86
import { Schemas } from 'vs/base/common/network';
B
Benjamin Pasero 已提交
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	public updateOptions() {

	}

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

		return false;
	}

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

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

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

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

	constructor(
188
		@IWorkspaceContextService contextService: IWorkspaceContextService,
189
		@IFileService protected fileService: IFileService,
190
		@IUntitledEditorService untitledEditorService: IUntitledEditorService,
191
		@ILifecycleService lifecycleService: ILifecycleService,
192
		@IInstantiationService instantiationService: IInstantiationService,
193 194 195
		@IConfigurationService configurationService: IConfigurationService,
		@IModeService modeService: IModeService,
		@IModelService modelService: IModelService,
196
		@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
197
		@INotificationService notificationService: INotificationService,
198
		@IBackupFileService backupFileService: IBackupFileService,
199
		@IWindowsService windowsService: IWindowsService,
I
isidor 已提交
200
		@IHistoryService historyService: IHistoryService,
B
Benjamin Pasero 已提交
201
		@IContextKeyService contextKeyService: IContextKeyService,
202 203
		@IDialogService dialogService: IDialogService,
		@IFileDialogService fileDialogService: IFileDialogService,
B
Benjamin Pasero 已提交
204 205
		@IEditorService editorService: IEditorService,
		@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService
A
Alex Dima 已提交
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,
B
Benjamin Pasero 已提交
224 225
			editorService,
			textResourceConfigurationService
226
		);
A
Alex Dima 已提交
227
	}
228

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

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

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

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

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

B
Benjamin Pasero 已提交
249
		return this.fileService.readFileStream(resource, options).then(async (content): Promise<ITextFileStreamContent> => {
250
			return {
251
				resource: content.resource,
252 253 254
				name: content.name,
				mtime: content.mtime,
				etag: content.etag,
B
Benjamin Pasero 已提交
255 256 257
				encoding: 'utf8',
				value: await createTextBufferFactoryFromStream(content.value),
				size: 10
258 259 260
			};
		});
	}
261

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

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

B
Benjamin Pasero 已提交
270 271
	public confirmOverwrite(_resource: URI): Promise<boolean> {
		return Promise.resolve(true);
272
	}
D
Daniel Imms 已提交
273

274 275
	public onFilesConfigurationChange(configuration: any): void {
		super.onFilesConfigurationChange(configuration);
276 277
	}

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

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

	return instantiationService;
}

B
Benjamin Pasero 已提交
325 326 327
export class TestDecorationsService implements IDecorationsService {
	_serviceBrand: any;
	onDidChangeDecorations: Event<IResourceDecorationChangeEvent> = Event.None;
328
	registerDecorationsProvider(_provider: IDecorationsProvider): IDisposable { return Disposable.None; }
329
	getDecoration(_uri: URI, _includeChildren: boolean, _overwrite?: IDecorationData): IDecoration | undefined { return undefined; }
B
Benjamin Pasero 已提交
330 331
}

332
export class TestExtensionService extends NullExtensionService { }
B
Benjamin Pasero 已提交
333 334 335 336 337

export class TestMenuService implements IMenuService {

	public _serviceBrand: any;

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

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

	public _serviceBrand: any;

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

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

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

363 364 365
	public last(): void {
	}

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

	public clear(): void {
	}

B
Benjamin Pasero 已提交
372 373 374
	public clearRecentlyOpened(): void {
	}

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

379
	public getLastActiveWorkspaceRoot(_schemeFilter: string): URI | undefined {
B
Benjamin Pasero 已提交
380 381
		return this.root;
	}
382

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

	public openLastEditLocation(): void {
	}
B
Benjamin Pasero 已提交
389 390
}

391
export class TestDialogService implements IDialogService {
392 393

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

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

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

M
Martin Aeschlimann 已提交
404 405 406 407
export class TestFileDialogService implements IFileDialogService {

	public _serviceBrand: any;

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

440
export class TestLayoutService implements IWorkbenchLayoutService {
B
Benjamin Pasero 已提交
441

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

444 445
	dimension: IDimension = { width: 800, height: 600 };

446 447
	container: HTMLElement = window.document.body;

B
Benjamin Pasero 已提交
448
	onZenModeChange: Event<boolean> = Event.None;
S
SteVen Batten 已提交
449 450
	onCenteredLayoutChange: Event<boolean> = Event.None;
	onFullscreenChange: Event<boolean> = Event.None;
451
	onPanelPositionChange: Event<string> = Event.None;
452
	onLayout = Event.None;
B
Benjamin Pasero 已提交
453

454
	private _onTitleBarVisibilityChange = new Emitter<void>();
455
	private _onMenubarVisibilityChange = new Emitter<Dimension>();
456 457 458 459 460

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

461 462 463 464
	public get onMenubarVisibilityChange(): Event<Dimension> {
		return this._onMenubarVisibilityChange.event;
	}

B
Benjamin Pasero 已提交
465
	public isRestored(): boolean {
E
Erich Gamma 已提交
466 467 468
		return true;
	}

469
	public hasFocus(_part: Parts): boolean {
E
Erich Gamma 已提交
470 471 472
		return false;
	}

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

477
	public getContainer(_part: Parts): HTMLElement {
B
Benjamin Pasero 已提交
478
		return null!;
479 480
	}

B
Benjamin Pasero 已提交
481 482 483 484
	public isTitleBarHidden(): boolean {
		return false;
	}

485 486 487 488
	public getTitleBarOffset(): number {
		return 0;
	}

489 490 491 492
	public isStatusBarHidden(): boolean {
		return false;
	}

S
Sanders Lauture 已提交
493 494 495 496
	public isActivityBarHidden(): boolean {
		return false;
	}

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

E
Erich Gamma 已提交
499 500 501 502
	public isSideBarHidden(): boolean {
		return false;
	}

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

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

I
isidor 已提交
507
	public isPanelHidden(): boolean {
I
isidor 已提交
508 509 510
		return false;
	}

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

I
isidor 已提交
513 514
	public toggleMaximizedPanel(): void { }

B
Benjamin Pasero 已提交
515 516 517 518
	public isPanelMaximized(): boolean {
		return false;
	}

S
SteVen Batten 已提交
519
	public getMenubarVisibility(): MenuBarVisibility {
520
		throw new Error('not implemented');
S
SteVen Batten 已提交
521 522
	}

E
Erich Gamma 已提交
523 524 525 526
	public getSideBarPosition() {
		return 0;
	}

I
isidor 已提交
527 528 529 530
	public getPanelPosition() {
		return 0;
	}

J
Johannes Rieken 已提交
531
	public setPanelPosition(_position: PartPosition): Promise<void> {
532
		return Promise.resolve();
I
isidor 已提交
533 534
	}

535 536
	public addClass(_clazz: string): void { }
	public removeClass(_clazz: string): void { }
537 538

	public getWorkbenchContainer(): HTMLElement { throw new Error('not implemented'); }
539
	public getWorkbenchElement(): HTMLElement { throw new Error('not implemented'); }
B
Benjamin Pasero 已提交
540

I
isidor 已提交
541
	public toggleZenMode(): void { }
542

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


547
	public resizePart(_part: Parts, _sizeChange: number): void { }
548 549

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

552
let activeViewlet: Viewlet = {} as any;
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
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!;
	}
597 598 599 600

	public hideActiveViewlet(): void { }

	public getLastActiveViewletId(): string {
M
Matt Bierner 已提交
601
		return undefined!;
602
	}
603 604 605 606 607 608 609 610 611 612 613 614
}

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

B
Benjamin Pasero 已提交
615 616 617 618
	public getPanel(id: string): any {
		return activeViewlet;
	}

619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639
	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.');
	}

B
Benjamin Pasero 已提交
640 641 642 643
	public getProgressIndicator(id: string) {
		return null!;
	}

644 645 646
	public hideActivePanel(): void { }

	public getLastActivePanelId(): string {
M
Matt Bierner 已提交
647
		return undefined!;
648 649 650
	}
}

651
export class TestStorageService extends InMemoryStorageService { }
652

653 654
export class TestEditorGroupsService implements IEditorGroupsService {

655 656
	_serviceBrand: ServiceIdentifier<any>;

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

659
	onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
B
Benjamin Pasero 已提交
660
	onDidActivateGroup: Event<IEditorGroup> = Event.None;
661 662 663
	onDidAddGroup: Event<IEditorGroup> = Event.None;
	onDidRemoveGroup: Event<IEditorGroup> = Event.None;
	onDidMoveGroup: Event<IEditorGroup> = Event.None;
664
	onDidLayout: Event<IDimension> = Event.None;
665 666

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

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

672
	get activeGroup(): IEditorGroup {
673 674 675 676 677 678 679
		return this.groups[0];
	}

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

680
	getGroups(_order?: GroupsOrder): ReadonlyArray<IEditorGroup> {
681 682 683
		return this.groups;
	}

684
	getGroup(identifier: number): IEditorGroup {
685 686 687
		for (const group of this.groups) {
			if (group.id === identifier) {
				return group;
688 689 690
			}
		}

691
		return undefined!;
692 693
	}

694
	getLabel(_identifier: number): string {
695 696 697
		return 'Group 1';
	}

698
	findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup {
699
		throw new Error('not implemented');
700 701
	}

702
	activateGroup(_group: number | IEditorGroup): IEditorGroup {
703
		throw new Error('not implemented');
704 705
	}

706 707
	getSize(_group: number | IEditorGroup): { width: number, height: number } {
		return { width: 100, height: 100 };
708 709
	}

710
	setSize(_group: number | IEditorGroup, _size: { width: number, height: number }): void { }
711

712
	arrangeGroups(_arrangement: GroupsArrangement): void { }
713

714
	applyLayout(_layout: EditorGroupLayout): void { }
715

716
	setGroupOrientation(_orientation: any): void { }
717

718
	addGroup(_location: number | IEditorGroup, _direction: GroupDirection, _options?: IAddGroupOptions): IEditorGroup {
719
		throw new Error('not implemented');
720 721
	}

722
	removeGroup(_group: number | IEditorGroup): void { }
723

724
	moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
725
		throw new Error('not implemented');
726 727
	}

728
	mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup {
729
		throw new Error('not implemented');
730 731
	}

732
	copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
733
		throw new Error('not implemented');
734
	}
735 736 737 738 739 740 741 742 743 744

	centerLayout(active: boolean): void { }

	isLayoutCentered(): boolean {
		return false;
	}

	partOptions: IEditorPartOptions;
	enforcePartOptions(options: IEditorPartOptions): IDisposable {
		return Disposable.None;
745 746 747
	}
}

B
Benjamin Pasero 已提交
748
export class TestEditorGroup implements IEditorGroupView {
749 750 751

	constructor(public id: number) { }

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

	onWillDispose: Event<void> = Event.None;
768
	onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
B
Benjamin Pasero 已提交
769 770
	onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
771 772
	onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
	onDidOpenEditorFail: Event<IEditorInput> = Event.None;
B
Benjamin Pasero 已提交
773 774
	onDidFocus: Event<void> = Event.None;
	onDidChange: Event<{ width: number; height: number; }> = Event.None;
775

776
	getEditors(_order?: EditorsOrder): ReadonlyArray<IEditorInput> {
B
Benjamin Pasero 已提交
777 778 779
		return [];
	}

780
	getEditor(_index: number): IEditorInput {
781
		throw new Error('not implemented');
782 783
	}

784
	getIndexOfEditor(_editor: IEditorInput): number {
785 786 787
		return -1;
	}

J
Johannes Rieken 已提交
788
	openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditor> {
789
		throw new Error('not implemented');
790 791
	}

J
Johannes Rieken 已提交
792
	openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditor> {
793
		throw new Error('not implemented');
794 795
	}

796
	isOpened(_editor: IEditorInput): boolean {
797 798 799
		return false;
	}

800
	isPinned(_editor: IEditorInput): boolean {
801 802 803
		return false;
	}

804
	isActive(_editor: IEditorInput): boolean {
805 806 807
		return false;
	}

808
	moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
809

810
	copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
811

812
	closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> {
B
Benjamin Pasero 已提交
813
		return Promise.resolve();
814 815
	}

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

J
Johannes Rieken 已提交
820
	closeAllEditors(): Promise<void> {
B
Benjamin Pasero 已提交
821
		return Promise.resolve();
822 823
	}

J
Johannes Rieken 已提交
824
	replaceEditors(_editors: IEditorReplacement[]): Promise<void> {
B
Benjamin Pasero 已提交
825
		return Promise.resolve();
826 827
	}

828
	pinEditor(_editor?: IEditorInput): void { }
829 830 831 832

	focus(): void { }

	invokeWithinContext<T>(fn: (accessor: ServicesAccessor) => T): T {
833
		throw new Error('not implemented');
834
	}
B
Benjamin Pasero 已提交
835 836

	isEmpty(): boolean { return true; }
837 838
	setActive(_isActive: boolean): void { }
	setLabel(_label: string): void { }
B
Benjamin Pasero 已提交
839 840
	dispose(): void { }
	toJSON(): object { return Object.create(null); }
841
	layout(_width: number, _height: number): void { }
842
	relayout() { }
843 844
}

B
Benjamin Pasero 已提交
845
export class TestEditorService implements EditorServiceImpl {
846 847 848 849 850

	_serviceBrand: ServiceIdentifier<any>;

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
851
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
852 853
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

854
	activeControl: IVisibleEditor;
855
	activeTextEditorWidget: any;
856
	activeEditor: IEditorInput;
857
	editors: ReadonlyArray<IEditorInput> = [];
M
Matt Bierner 已提交
858
	visibleControls: ReadonlyArray<IVisibleEditor> = [];
859
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
860
	visibleEditors: ReadonlyArray<IEditorInput> = [];
861

862
	overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
R
Rob Lourens 已提交
863
		return toDisposable(() => undefined);
864 865
	}

866 867
	openEditor(_editor: any, _options?: any, _group?: any): Promise<any> {
		throw new Error('not implemented');
868 869
	}

870 871
	openEditors(_editors: any, _group?: any): Promise<IEditor[]> {
		throw new Error('not implemented');
872 873
	}

874
	isOpen(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
875 876 877
		return false;
	}

878
	getOpened(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): IEditorInput {
879
		throw new Error('not implemented');
880 881
	}

882
	replaceEditors(_editors: any, _group: any) {
R
Rob Lourens 已提交
883
		return Promise.resolve(undefined);
884 885
	}

886
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
887
		throw new Error('not implemented');
888 889
	}

890
	createInput(_input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
891
		throw new Error('not implemented');
892 893 894
	}
}

895 896 897 898
export class TestFileService implements IFileService {

	public _serviceBrand: any;

M
Matt Bierner 已提交
899 900
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
901

902
	readonly onWillActivateFileSystemProvider = Event.None;
903
	readonly onError: Event<Error> = Event.None;
904

905
	private content = 'Hello Html';
906
	private lastReadFileUri: URI;
907

908 909 910 911 912
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

913 914 915 916 917 918 919 920
	public setContent(content: string): void {
		this.content = content;
	}

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

921 922 923 924
	public getLastReadFileUri(): URI {
		return this.lastReadFileUri;
	}

925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940
	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 已提交
941 942 943
	resolve(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat>;
	resolve(resource: URI, _options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
	resolve(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat> {
B
Benjamin Pasero 已提交
944
		return Promise.resolve({
945 946
			resource,
			etag: Date.now().toString(),
B
Benjamin Pasero 已提交
947
			encoding: 'utf8',
B
Benjamin Pasero 已提交
948
			mtime: Date.now(),
949
			size: 42,
950
			isDirectory: false,
B
Benjamin Pasero 已提交
951
			name: resources.basename(resource)
B
Benjamin Pasero 已提交
952
		});
953
	}
B
Benjamin Pasero 已提交
954

B
Benjamin Pasero 已提交
955 956
	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 已提交
957 958
	}

B
Benjamin Pasero 已提交
959
	exists(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
960
		return Promise.resolve(true);
961
	}
B
Benjamin Pasero 已提交
962

963
	readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
964 965
		this.lastReadFileUri = resource;

966
		return Promise.resolve({
B
Benjamin Pasero 已提交
967
			resource: resource,
968
			value: VSBuffer.fromString(this.content),
969
			etag: 'index.txt',
B
Benjamin Pasero 已提交
970 971
			encoding: 'utf8',
			mtime: Date.now(),
972 973
			name: resources.basename(resource),
			size: 1
E
Erich Gamma 已提交
974
		});
975
	}
E
Erich Gamma 已提交
976

977
	readFileStream(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileStreamContent> {
978 979
		this.lastReadFileUri = resource;

980
		return Promise.resolve({
A
Alex Dima 已提交
981 982
			resource: resource,
			value: {
983
				on: (event: string, callback: Function): void => {
A
Alex Dima 已提交
984
					if (event === 'data') {
985
						callback(this.content);
A
Alex Dima 已提交
986 987 988 989
					}
					if (event === 'end') {
						callback();
					}
B
Benjamin Pasero 已提交
990 991 992 993
				},
				resume: () => { },
				pause: () => { },
				destroy: () => { }
A
Alex Dima 已提交
994 995 996
			},
			etag: 'index.txt',
			encoding: 'utf8',
B
Benjamin Pasero 已提交
997
			mtime: Date.now(),
998 999
			size: 1,
			name: resources.basename(resource)
A
Alex Dima 已提交
1000
		});
1001 1002
	}

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

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

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

1023
	createFile(_resource: URI, _content?: VSBuffer | VSBufferReadable, _options?: ICreateFileOptions): Promise<IFileStatWithMetadata> {
1024
		throw new Error('not implemented');
E
Erich Gamma 已提交
1025
	}
1026

1027
	createFolder(_resource: URI): Promise<IFileStatWithMetadata> {
1028
		throw new Error('not implemented');
1029 1030
	}

1031 1032
	onDidChangeFileSystemProviderRegistrations = Event.None;

1033 1034 1035 1036 1037 1038
	private providers = new Map<string, IFileSystemProvider>();

	registerProvider(scheme: string, provider: IFileSystemProvider) {
		this.providers.set(scheme, provider);

		return toDisposable(() => this.providers.delete(scheme));
1039 1040
	}

1041 1042
	activateProvider(_scheme: string): Promise<void> {
		throw new Error('not implemented');
1043 1044
	}

1045
	canHandleResource(resource: URI): boolean {
1046
		return resource.scheme === 'file' || this.providers.has(resource.scheme);
1047 1048
	}

1049
	hasCapability(resource: URI, capability: FileSystemProviderCapabilities): boolean { return false; }
1050

J
Johannes Rieken 已提交
1051
	del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
1052
		return Promise.resolve();
1053 1054
	}

1055 1056
	watch(_resource: URI): IDisposable {
		return Disposable.None;
1057 1058
	}

1059 1060
	getWriteEncoding(_resource: URI): IResourceEncoding {
		return { encoding: 'utf8', hasBOM: false };
1061
	}
D
Daniel Imms 已提交
1062

1063
	dispose(): void {
E
Erich Gamma 已提交
1064
	}
1065
}
1066

1067 1068
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
1069

J
Johannes Rieken 已提交
1070
	public hasBackups(): Promise<boolean> {
B
Benjamin Pasero 已提交
1071
		return Promise.resolve(false);
1072 1073
	}

J
Johannes Rieken 已提交
1074
	public hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
1075
		return Promise.resolve(false);
1076 1077
	}

1078 1079 1080 1081
	public hasBackupSync(resource: URI, versionId?: number): boolean {
		return false;
	}

1082
	public loadBackupResource(resource: URI): Promise<URI | undefined> {
B
Benjamin Pasero 已提交
1083 1084
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
1085
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
1086 1087
			}

R
Rob Lourens 已提交
1088
			return undefined;
B
Benjamin Pasero 已提交
1089 1090 1091
		});
	}

J
Johannes Rieken 已提交
1092
	public registerResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1093
		return Promise.resolve();
D
Daniel Imms 已提交
1094 1095
	}

J
Johannes Rieken 已提交
1096
	public deregisterResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1097
		return Promise.resolve();
D
Daniel Imms 已提交
1098 1099
	}

1100
	public toBackupResource(_resource: URI): URI {
1101
		throw new Error('not implemented');
D
Daniel Imms 已提交
1102
	}
1103

1104
	public backupResource<T extends object>(_resource: URI, _content: ITextSnapshot, versionId?: number, meta?: T): Promise<void> {
B
Benjamin Pasero 已提交
1105
		return Promise.resolve();
1106 1107
	}

J
Johannes Rieken 已提交
1108
	public getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
1109
		return Promise.resolve([]);
1110 1111
	}

1112 1113 1114 1115 1116
	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);
1117 1118
	}

1119
	public resolveBackupContent<T extends object>(_backup: URI): Promise<IResolvedBackup<T>> {
1120
		throw new Error('not implemented');
1121 1122
	}

J
Johannes Rieken 已提交
1123
	public discardResourceBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1124
		return Promise.resolve();
1125 1126
	}

J
Johannes Rieken 已提交
1127
	public discardAllWorkspaceBackups(): Promise<void> {
B
Benjamin Pasero 已提交
1128
		return Promise.resolve();
1129
	}
1130
}
D
Daniel Imms 已提交
1131

B
Benjamin Pasero 已提交
1132 1133 1134 1135 1136 1137 1138
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 已提交
1139
	onDidChangeTransientModelProperty: Event<ITextModel> = Event.None;
B
Benjamin Pasero 已提交
1140

1141 1142
	addCodeEditor(_editor: ICodeEditor): void { }
	removeCodeEditor(_editor: ICodeEditor): void { }
B
Benjamin Pasero 已提交
1143
	listCodeEditors(): ICodeEditor[] { return []; }
1144 1145
	addDiffEditor(_editor: IDiffEditor): void { }
	removeDiffEditor(_editor: IDiffEditor): void { }
B
Benjamin Pasero 已提交
1146
	listDiffEditors(): IDiffEditor[] { return []; }
1147
	getFocusedCodeEditor(): ICodeEditor | null { return null; }
1148 1149 1150 1151 1152
	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) { }
1153 1154
	getActiveCodeEditor(): ICodeEditor | null { return null; }
	openCodeEditor(_input: IResourceInput, _source: ICodeEditor, _sideBySide?: boolean): Promise<ICodeEditor | null> { return Promise.resolve(null); }
B
Benjamin Pasero 已提交
1155 1156
}

1157 1158 1159 1160
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

1161
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
S
SteVen Batten 已提交
1162
	onDidChangeMaximize: Event<boolean>;
1163

1164
	hasFocus = true;
1165

1166
	readonly windowId = 0;
S
SteVen Batten 已提交
1167

J
Johannes Rieken 已提交
1168
	isFocused(): Promise<boolean> {
B
Benjamin Pasero 已提交
1169
		return Promise.resolve(false);
1170 1171
	}

J
Johannes Rieken 已提交
1172
	isMaximized(): Promise<boolean> {
B
Benjamin Pasero 已提交
1173
		return Promise.resolve(false);
1174 1175
	}

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

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

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

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

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

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

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

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

M
Matt Bierner 已提交
1208
	enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1209
		return Promise.resolve(undefined);
1210 1211
	}

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

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

J
Johannes Rieken 已提交
1220
	getRecentlyOpened(): Promise<IRecentlyOpened> {
1221 1222 1223 1224
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1225 1226
	}

1227 1228 1229 1230 1231 1232 1233 1234
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
		return Promise.resolve();
	}

	removeFromRecentlyOpened(_paths: URI[]): Promise<void> {
		return Promise.resolve();
	}

J
Johannes Rieken 已提交
1235
	focusWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1236
		return Promise.resolve();
S
SteVen Batten 已提交
1237 1238
	}

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

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

J
Johannes Rieken 已提交
1247
	minimizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1248
		return Promise.resolve();
B
Benjamin Pasero 已提交
1249 1250
	}

M
Martin Aeschlimann 已提交
1251
	openWindow(_uris: IURIToOpen[], _options?: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1252
		return Promise.resolve();
1253 1254
	}

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

J
Johannes Rieken 已提交
1259
	setDocumentEdited(_flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1260
		return Promise.resolve();
1261
	}
1262

J
Johannes Rieken 已提交
1263
	onWindowTitleDoubleClick(): Promise<void> {
B
Benjamin Pasero 已提交
1264
		return Promise.resolve();
J
Joao 已提交
1265 1266
	}

J
Johannes Rieken 已提交
1267
	showMessageBox(_options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
B
Benjamin Pasero 已提交
1268
		return Promise.resolve({ button: 0 });
1269 1270
	}

J
Johannes Rieken 已提交
1271
	showSaveDialog(_options: Electron.SaveDialogOptions): Promise<string> {
1272
		throw new Error('not implemented');
1273
	}
1274

J
Johannes Rieken 已提交
1275
	showOpenDialog(_options: Electron.OpenDialogOptions): Promise<string[]> {
1276
		throw new Error('not implemented');
1277
	}
1278

J
Johannes Rieken 已提交
1279
	updateTouchBar(_items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1280
		return Promise.resolve();
1281
	}
1282 1283

	resolveProxy(url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1284
		return Promise.resolve(undefined);
1285
	}
1286 1287
}

1288 1289
export class TestLifecycleService implements ILifecycleService {

1290
	public _serviceBrand: any;
1291

1292
	public phase: LifecyclePhase;
1293
	public startupKind: StartupKind;
1294

1295
	private _onBeforeShutdown = new Emitter<BeforeShutdownEvent>();
1296
	private _onWillShutdown = new Emitter<WillShutdownEvent>();
1297
	private _onShutdown = new Emitter<void>();
1298

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

1303
	public fireShutdown(reason = ShutdownReason.QUIT): void {
1304
		this._onWillShutdown.fire({
1305 1306 1307
			join: () => { },
			reason
		});
1308 1309
	}

1310 1311 1312 1313 1314 1315
	public fireWillShutdown(event: BeforeShutdownEvent): void {
		this._onBeforeShutdown.fire(event);
	}

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

1318
	public get onWillShutdown(): Event<WillShutdownEvent> {
1319 1320 1321
		return this._onWillShutdown.event;
	}

1322
	public get onShutdown(): Event<void> {
1323 1324
		return this._onShutdown.event;
	}
1325 1326
}

1327 1328 1329 1330
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1331 1332
	public windowCount = 1;

1333 1334
	onWindowOpen: Event<number>;
	onWindowFocus: Event<number>;
1335
	onWindowBlur: Event<number>;
S
SteVen Batten 已提交
1336 1337
	onWindowMaximize: Event<number>;
	onWindowUnmaximize: Event<number>;
S
SteVen Batten 已提交
1338
	onRecentlyOpenedChange: Event<void>;
1339

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

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

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

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

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

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

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

J
Johannes Rieken 已提交
1368
	toggleDevTools(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1369
		return Promise.resolve();
1370
	}
1371

J
Johannes Rieken 已提交
1372
	closeWorkspace(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1373
		return Promise.resolve();
1374
	}
1375

1376
	enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1377
		return Promise.resolve(undefined);
1378 1379
	}

J
Johannes Rieken 已提交
1380
	toggleFullScreen(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1381
		return Promise.resolve();
1382 1383
	}

J
Johannes Rieken 已提交
1384
	setRepresentedFilename(_windowId: number, _fileName: string): Promise<void> {
B
Benjamin Pasero 已提交
1385
		return Promise.resolve();
1386 1387
	}

M
Martin Aeschlimann 已提交
1388
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
B
Benjamin Pasero 已提交
1389
		return Promise.resolve();
1390
	}
1391

J
Johannes Rieken 已提交
1392
	removeFromRecentlyOpened(_paths: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1393
		return Promise.resolve();
1394
	}
1395

J
Johannes Rieken 已提交
1396
	clearRecentlyOpened(): Promise<void> {
B
Benjamin Pasero 已提交
1397
		return Promise.resolve();
1398
	}
1399

J
Johannes Rieken 已提交
1400
	getRecentlyOpened(_windowId: number): Promise<IRecentlyOpened> {
1401 1402 1403 1404
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1405
	}
1406

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

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

J
Johannes Rieken 已提交
1415
	isMaximized(_windowId: number): Promise<boolean> {
1416
		return Promise.resolve(false);
1417
	}
1418

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

J
Johannes Rieken 已提交
1423
	minimizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1424
		return Promise.resolve();
S
SteVen Batten 已提交
1425 1426
	}

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

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

J
Johannes Rieken 已提交
1435
	setDocumentEdited(_windowId: number, _flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1436
		return Promise.resolve();
1437
	}
1438

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

J
Johannes Rieken 已提交
1443
	relaunch(_options: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
B
Benjamin Pasero 已提交
1444
		return Promise.resolve();
J
Johannes Rieken 已提交
1445
	}
1446

J
Johannes Rieken 已提交
1447
	whenSharedProcessReady(): Promise<void> {
B
Benjamin Pasero 已提交
1448
		return Promise.resolve();
1449
	}
1450

J
Johannes Rieken 已提交
1451
	toggleSharedProcess(): Promise<void> {
B
Benjamin Pasero 已提交
1452
		return Promise.resolve();
1453
	}
1454

1455
	// Global methods
M
Martin Aeschlimann 已提交
1456
	openWindow(_windowId: number, _uris: IURIToOpen[], _options: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1457
		return Promise.resolve();
1458
	}
1459

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

1464
	openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
1465 1466 1467
		return Promise.resolve();
	}

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

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

J
Johannes Rieken 已提交
1476
	log(_severity: string, ..._messages: string[]): Promise<void> {
B
Benjamin Pasero 已提交
1477
		return Promise.resolve();
1478
	}
1479

M
Martin Aeschlimann 已提交
1480
	showItemInFolder(_path: URI): Promise<void> {
B
Benjamin Pasero 已提交
1481
		return Promise.resolve();
1482
	}
1483

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

J
Johannes Rieken 已提交
1488
	showPreviousWindowTab(): Promise<void> {
B
Benjamin Pasero 已提交
1489
		return Promise.resolve();
1490 1491
	}

J
Johannes Rieken 已提交
1492
	showNextWindowTab(): Promise<void> {
B
Benjamin Pasero 已提交
1493
		return Promise.resolve();
1494 1495
	}

J
Johannes Rieken 已提交
1496
	moveWindowTabToNewWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1497
		return Promise.resolve();
1498 1499
	}

J
Johannes Rieken 已提交
1500
	mergeAllWindowTabs(): Promise<void> {
B
Benjamin Pasero 已提交
1501
		return Promise.resolve();
1502 1503
	}

J
Johannes Rieken 已提交
1504
	toggleWindowTabsBar(): Promise<void> {
B
Benjamin Pasero 已提交
1505
		return Promise.resolve();
1506 1507
	}

J
Johannes Rieken 已提交
1508
	updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1509
		return Promise.resolve();
1510 1511
	}

J
Johannes Rieken 已提交
1512
	getActiveWindowId(): Promise<number | undefined> {
B
Benjamin Pasero 已提交
1513
		return Promise.resolve(undefined);
J
Joao Moreno 已提交
1514 1515
	}

1516 1517
	// This needs to be handled from browser process to prevent
	// foreground ordering issues on Windows
J
Johannes Rieken 已提交
1518
	openExternal(_url: string): Promise<boolean> {
B
Benjamin Pasero 已提交
1519
		return Promise.resolve(true);
1520 1521 1522
	}

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

J
Johannes Rieken 已提交
1527
	showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
1528
		throw new Error('not implemented');
1529 1530
	}

J
Johannes Rieken 已提交
1531
	showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): Promise<string> {
1532
		throw new Error('not implemented');
1533 1534
	}

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

J
Johannes Rieken 已提交
1539
	openAboutDialog(): Promise<void> {
B
Benjamin Pasero 已提交
1540
		return Promise.resolve();
J
Joao Moreno 已提交
1541
	}
1542 1543

	resolveProxy(windowId: number, url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1544
		return Promise.resolve(undefined);
1545
	}
1546
}
B
Benjamin Pasero 已提交
1547

1548 1549 1550 1551 1552 1553 1554
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1555
	public onDidChangeConfiguration() {
1556 1557 1558
		return { dispose() { } };
	}

1559
	getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
1560 1561
		const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;
		const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
1562
		return this.configurationService.getValue(section, { resource });
1563
	}
B
Benjamin Pasero 已提交
1564 1565
}

S
Sandeep Somavarapu 已提交
1566 1567 1568 1569 1570
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

	_serviceBrand: any;

	constructor(
1571
		@IConfigurationService private readonly configurationService: IConfigurationService,
S
Sandeep Somavarapu 已提交
1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586
	) {
	}

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


1587
export class TestSharedProcessService implements ISharedProcessService {
1588 1589 1590

	_serviceBrand: ServiceIdentifier<any>;

1591 1592 1593
	getChannel(channelName: string): any {
		return undefined;
	}
1594

1595
	registerChannel(channelName: string, channel: any): void { }
1596 1597
}

1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624
export class RemoteFileSystemProvider implements IFileSystemProvider {

	constructor(private readonly diskFileSystemProvider: IFileSystemProvider, private readonly remoteAuthority: string) { }

	readonly capabilities: FileSystemProviderCapabilities = this.diskFileSystemProvider.capabilities;
	readonly onDidChangeCapabilities: Event<void> = this.diskFileSystemProvider.onDidChangeCapabilities;

	readonly onDidChangeFile: Event<IFileChange[]> = Event.map(this.diskFileSystemProvider.onDidChangeFile, changes => changes.map(c => { c.resource = c.resource.with({ scheme: Schemas.vscodeRemote, authority: this.remoteAuthority }); return c; }));
	watch(resource: URI, opts: IWatchOptions): IDisposable { return this.diskFileSystemProvider.watch(this.toFileResource(resource), opts); }

	stat(resource: URI): Promise<IStat> { return this.diskFileSystemProvider.stat(this.toFileResource(resource)); }
	mkdir(resource: URI): Promise<void> { return this.diskFileSystemProvider.mkdir(this.toFileResource(resource)); }
	readdir(resource: URI): Promise<[string, FileType][]> { return this.diskFileSystemProvider.readdir(this.toFileResource(resource)); }
	delete(resource: URI, opts: FileDeleteOptions): Promise<void> { return this.diskFileSystemProvider.delete(this.toFileResource(resource), opts); }

	rename(from: URI, to: URI, opts: FileOverwriteOptions): Promise<void> { return this.diskFileSystemProvider.rename(this.toFileResource(from), this.toFileResource(to), opts); }
	copy(from: URI, to: URI, opts: FileOverwriteOptions): Promise<void> { return this.diskFileSystemProvider.copy!(this.toFileResource(from), this.toFileResource(to), opts); }

	readFile(resource: URI): Promise<Uint8Array> { return this.diskFileSystemProvider.readFile!(this.toFileResource(resource)); }
	writeFile(resource: URI, content: Uint8Array, opts: FileWriteOptions): Promise<void> { return this.diskFileSystemProvider.writeFile!(this.toFileResource(resource), content, opts); }

	open(resource: URI, opts: FileOpenOptions): Promise<number> { return this.diskFileSystemProvider.open!(this.toFileResource(resource), opts); }
	close(fd: number): Promise<void> { return this.diskFileSystemProvider.close!(fd); }
	read(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return this.diskFileSystemProvider.read!(fd, pos, data, offset, length); }
	write(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return this.diskFileSystemProvider.write!(fd, pos, data, offset, length); }

	private toFileResource(resource: URI): URI { return resource.with({ scheme: Schemas.file, authority: '' }); }
1625
}