workbenchTestServices.ts 52.4 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 478 479 480
	getDimension(_part: Parts): Dimension {
		return new Dimension(0, 0);
	}

481
	public getContainer(_part: Parts): HTMLElement {
B
Benjamin Pasero 已提交
482
		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 542

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

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

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


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

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

556
let activeViewlet: Viewlet = {} as any;
557

558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
export class TestViewletService implements IViewletService {
	public _serviceBrand: any;

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

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

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

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

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

	public getActiveViewlet(): IViewlet {
		return activeViewlet;
	}

	public dispose() {
	}

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

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

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

	public hideActiveViewlet(): void { }

	public getLastActiveViewletId(): string {
M
Matt Bierner 已提交
605
		return undefined!;
606
	}
607 608 609 610 611 612 613 614 615 616 617 618
}

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 已提交
619 620 621 622
	public getPanel(id: string): any {
		return activeViewlet;
	}

623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
	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 已提交
644 645 646 647
	public getProgressIndicator(id: string) {
		return null!;
	}

648 649 650
	public hideActivePanel(): void { }

	public getLastActivePanelId(): string {
M
Matt Bierner 已提交
651
		return undefined!;
652 653 654
	}
}

655
export class TestStorageService extends InMemoryStorageService { }
656

657 658
export class TestEditorGroupsService implements IEditorGroupsService {

659 660
	_serviceBrand: ServiceIdentifier<any>;

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

663
	onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
B
Benjamin Pasero 已提交
664
	onDidActivateGroup: Event<IEditorGroup> = Event.None;
665 666 667
	onDidAddGroup: Event<IEditorGroup> = Event.None;
	onDidRemoveGroup: Event<IEditorGroup> = Event.None;
	onDidMoveGroup: Event<IEditorGroup> = Event.None;
668
	onDidLayout: Event<IDimension> = Event.None;
669 670

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

J
Joao Moreno 已提交
674
	contentDimension = { width: 800, height: 600 };
675

676
	get activeGroup(): IEditorGroup {
677 678 679 680 681 682 683
		return this.groups[0];
	}

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

684
	getGroups(_order?: GroupsOrder): ReadonlyArray<IEditorGroup> {
685 686 687
		return this.groups;
	}

688
	getGroup(identifier: number): IEditorGroup {
689 690 691
		for (const group of this.groups) {
			if (group.id === identifier) {
				return group;
692 693 694
			}
		}

695
		return undefined!;
696 697
	}

698
	getLabel(_identifier: number): string {
699 700 701
		return 'Group 1';
	}

702
	findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup {
703
		throw new Error('not implemented');
704 705
	}

706
	activateGroup(_group: number | IEditorGroup): IEditorGroup {
707
		throw new Error('not implemented');
708 709
	}

710 711
	getSize(_group: number | IEditorGroup): { width: number, height: number } {
		return { width: 100, height: 100 };
712 713
	}

714
	setSize(_group: number | IEditorGroup, _size: { width: number, height: number }): void { }
715

716
	arrangeGroups(_arrangement: GroupsArrangement): void { }
717

718
	applyLayout(_layout: EditorGroupLayout): void { }
719

720
	setGroupOrientation(_orientation: any): void { }
721

722
	addGroup(_location: number | IEditorGroup, _direction: GroupDirection, _options?: IAddGroupOptions): IEditorGroup {
723
		throw new Error('not implemented');
724 725
	}

726
	removeGroup(_group: number | IEditorGroup): void { }
727

728
	moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
729
		throw new Error('not implemented');
730 731
	}

732
	mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup {
733
		throw new Error('not implemented');
734 735
	}

736
	copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
737
		throw new Error('not implemented');
738
	}
739 740 741 742 743 744 745 746 747 748

	centerLayout(active: boolean): void { }

	isLayoutCentered(): boolean {
		return false;
	}

	partOptions: IEditorPartOptions;
	enforcePartOptions(options: IEditorPartOptions): IDisposable {
		return Disposable.None;
749 750 751
	}
}

B
Benjamin Pasero 已提交
752
export class TestEditorGroup implements IEditorGroupView {
753 754 755

	constructor(public id: number) { }

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

	onWillDispose: Event<void> = Event.None;
773
	onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
B
Benjamin Pasero 已提交
774 775
	onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
776 777
	onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
	onDidOpenEditorFail: Event<IEditorInput> = Event.None;
B
Benjamin Pasero 已提交
778 779
	onDidFocus: Event<void> = Event.None;
	onDidChange: Event<{ width: number; height: number; }> = Event.None;
780

781
	getEditors(_order?: EditorsOrder): ReadonlyArray<IEditorInput> {
B
Benjamin Pasero 已提交
782 783 784
		return [];
	}

785
	getEditor(_index: number): IEditorInput {
786
		throw new Error('not implemented');
787 788
	}

789
	getIndexOfEditor(_editor: IEditorInput): number {
790 791 792
		return -1;
	}

J
Johannes Rieken 已提交
793
	openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditor> {
794
		throw new Error('not implemented');
795 796
	}

J
Johannes Rieken 已提交
797
	openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditor> {
798
		throw new Error('not implemented');
799 800
	}

801
	isOpened(_editor: IEditorInput): boolean {
802 803 804
		return false;
	}

805
	isPinned(_editor: IEditorInput): boolean {
806 807 808
		return false;
	}

809
	isActive(_editor: IEditorInput): boolean {
810 811 812
		return false;
	}

813
	moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
814

815
	copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
816

817
	closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> {
B
Benjamin Pasero 已提交
818
		return Promise.resolve();
819 820
	}

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

J
Johannes Rieken 已提交
825
	closeAllEditors(): Promise<void> {
B
Benjamin Pasero 已提交
826
		return Promise.resolve();
827 828
	}

J
Johannes Rieken 已提交
829
	replaceEditors(_editors: IEditorReplacement[]): Promise<void> {
B
Benjamin Pasero 已提交
830
		return Promise.resolve();
831 832
	}

833
	pinEditor(_editor?: IEditorInput): void { }
834 835 836 837

	focus(): void { }

	invokeWithinContext<T>(fn: (accessor: ServicesAccessor) => T): T {
838
		throw new Error('not implemented');
839
	}
B
Benjamin Pasero 已提交
840 841

	isEmpty(): boolean { return true; }
842
	setActive(_isActive: boolean): void { }
B
Benjamin Pasero 已提交
843
	notifyIndexChanged(_index: number): void { }
B
Benjamin Pasero 已提交
844 845
	dispose(): void { }
	toJSON(): object { return Object.create(null); }
846
	layout(_width: number, _height: number): void { }
847
	relayout() { }
848 849
}

B
Benjamin Pasero 已提交
850
export class TestEditorService implements EditorServiceImpl {
851 852 853 854 855

	_serviceBrand: ServiceIdentifier<any>;

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
856
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
857 858
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

859
	activeControl: IVisibleEditor;
860
	activeTextEditorWidget: any;
861
	activeEditor: IEditorInput;
862
	editors: ReadonlyArray<IEditorInput> = [];
M
Matt Bierner 已提交
863
	visibleControls: ReadonlyArray<IVisibleEditor> = [];
864
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
865
	visibleEditors: ReadonlyArray<IEditorInput> = [];
866

867
	overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
R
Rob Lourens 已提交
868
		return toDisposable(() => undefined);
869 870
	}

871 872
	openEditor(_editor: any, _options?: any, _group?: any): Promise<any> {
		throw new Error('not implemented');
873 874
	}

875 876
	openEditors(_editors: any, _group?: any): Promise<IEditor[]> {
		throw new Error('not implemented');
877 878
	}

879
	isOpen(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
880 881 882
		return false;
	}

883
	getOpened(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): IEditorInput {
884
		throw new Error('not implemented');
885 886
	}

887
	replaceEditors(_editors: any, _group: any) {
R
Rob Lourens 已提交
888
		return Promise.resolve(undefined);
889 890
	}

891
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
892
		throw new Error('not implemented');
893 894
	}

895
	createInput(_input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
896
		throw new Error('not implemented');
897 898 899
	}
}

900 901 902 903
export class TestFileService implements IFileService {

	public _serviceBrand: any;

M
Matt Bierner 已提交
904 905
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
906

907
	readonly onWillActivateFileSystemProvider = Event.None;
908
	readonly onError: Event<Error> = Event.None;
909

910
	private content = 'Hello Html';
911
	private lastReadFileUri: URI;
912

913 914 915 916 917
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

918 919 920 921 922 923 924 925
	public setContent(content: string): void {
		this.content = content;
	}

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

926 927 928 929
	public getLastReadFileUri(): URI {
		return this.lastReadFileUri;
	}

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

B
Benjamin Pasero 已提交
960 961
	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 已提交
962 963
	}

B
Benjamin Pasero 已提交
964
	exists(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
965
		return Promise.resolve(true);
966
	}
B
Benjamin Pasero 已提交
967

968
	readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
969 970
		this.lastReadFileUri = resource;

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

982
	readFileStream(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileStreamContent> {
983 984
		this.lastReadFileUri = resource;

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

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

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

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

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

1032
	createFolder(_resource: URI): Promise<IFileStatWithMetadata> {
1033
		throw new Error('not implemented');
1034 1035
	}

1036 1037
	onDidChangeFileSystemProviderRegistrations = Event.None;

1038 1039 1040 1041 1042 1043
	private providers = new Map<string, IFileSystemProvider>();

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

		return toDisposable(() => this.providers.delete(scheme));
1044 1045
	}

1046 1047
	activateProvider(_scheme: string): Promise<void> {
		throw new Error('not implemented');
1048 1049
	}

1050
	canHandleResource(resource: URI): boolean {
1051
		return resource.scheme === 'file' || this.providers.has(resource.scheme);
1052 1053
	}

1054
	hasCapability(resource: URI, capability: FileSystemProviderCapabilities): boolean { return false; }
1055

J
Johannes Rieken 已提交
1056
	del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
1057
		return Promise.resolve();
1058 1059
	}

1060 1061
	watch(_resource: URI): IDisposable {
		return Disposable.None;
1062 1063
	}

1064 1065
	getWriteEncoding(_resource: URI): IResourceEncoding {
		return { encoding: 'utf8', hasBOM: false };
1066
	}
D
Daniel Imms 已提交
1067

1068
	dispose(): void {
E
Erich Gamma 已提交
1069
	}
1070
}
1071

1072 1073
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
1074

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

J
Johannes Rieken 已提交
1079
	public hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
1080
		return Promise.resolve(false);
1081 1082
	}

1083 1084 1085 1086
	public hasBackupSync(resource: URI, versionId?: number): boolean {
		return false;
	}

1087
	public loadBackupResource(resource: URI): Promise<URI | undefined> {
B
Benjamin Pasero 已提交
1088 1089
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
1090
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
1091 1092
			}

R
Rob Lourens 已提交
1093
			return undefined;
B
Benjamin Pasero 已提交
1094 1095 1096
		});
	}

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

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

1105
	public toBackupResource(_resource: URI): URI {
1106
		throw new Error('not implemented');
D
Daniel Imms 已提交
1107
	}
1108

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

J
Johannes Rieken 已提交
1113
	public getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
1114
		return Promise.resolve([]);
1115 1116
	}

1117 1118 1119 1120 1121
	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);
1122 1123
	}

1124
	public resolveBackupContent<T extends object>(_backup: URI): Promise<IResolvedBackup<T>> {
1125
		throw new Error('not implemented');
1126 1127
	}

J
Johannes Rieken 已提交
1128
	public discardResourceBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1129
		return Promise.resolve();
1130 1131
	}

J
Johannes Rieken 已提交
1132
	public discardAllWorkspaceBackups(): Promise<void> {
B
Benjamin Pasero 已提交
1133
		return Promise.resolve();
1134
	}
1135
}
D
Daniel Imms 已提交
1136

B
Benjamin Pasero 已提交
1137 1138 1139 1140 1141 1142 1143
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 已提交
1144
	onDidChangeTransientModelProperty: Event<ITextModel> = Event.None;
B
Benjamin Pasero 已提交
1145

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

1162 1163 1164 1165
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

1166
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
S
SteVen Batten 已提交
1167
	onDidChangeMaximize: Event<boolean>;
1168

1169
	hasFocus = true;
1170

1171
	readonly windowId = 0;
S
SteVen Batten 已提交
1172

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

J
Johannes Rieken 已提交
1177
	isMaximized(): Promise<boolean> {
B
Benjamin Pasero 已提交
1178
		return Promise.resolve(false);
1179 1180
	}

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

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

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

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

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

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

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

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

M
Matt Bierner 已提交
1213
	enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1214
		return Promise.resolve(undefined);
1215 1216
	}

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

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

J
Johannes Rieken 已提交
1225
	getRecentlyOpened(): Promise<IRecentlyOpened> {
1226 1227 1228 1229
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1230 1231
	}

1232 1233 1234 1235 1236 1237 1238 1239
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
		return Promise.resolve();
	}

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

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

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

J
Johannes Rieken 已提交
1248
	unmaximizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1249
		return Promise.resolve();
S
SteVen Batten 已提交
1250 1251
	}

J
Johannes Rieken 已提交
1252
	minimizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1253
		return Promise.resolve();
B
Benjamin Pasero 已提交
1254 1255
	}

M
Martin Aeschlimann 已提交
1256
	openWindow(_uris: IURIToOpen[], _options?: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1257
		return Promise.resolve();
1258 1259
	}

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

J
Johannes Rieken 已提交
1264
	setDocumentEdited(_flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1265
		return Promise.resolve();
1266
	}
1267

J
Johannes Rieken 已提交
1268
	onWindowTitleDoubleClick(): Promise<void> {
B
Benjamin Pasero 已提交
1269
		return Promise.resolve();
J
Joao 已提交
1270 1271
	}

J
Johannes Rieken 已提交
1272
	showMessageBox(_options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
B
Benjamin Pasero 已提交
1273
		return Promise.resolve({ button: 0 });
1274 1275
	}

J
Johannes Rieken 已提交
1276
	showSaveDialog(_options: Electron.SaveDialogOptions): Promise<string> {
1277
		throw new Error('not implemented');
1278
	}
1279

J
Johannes Rieken 已提交
1280
	showOpenDialog(_options: Electron.OpenDialogOptions): Promise<string[]> {
1281
		throw new Error('not implemented');
1282
	}
1283

J
Johannes Rieken 已提交
1284
	updateTouchBar(_items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1285
		return Promise.resolve();
1286
	}
1287 1288

	resolveProxy(url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1289
		return Promise.resolve(undefined);
1290
	}
1291 1292
}

1293 1294
export class TestLifecycleService implements ILifecycleService {

1295
	public _serviceBrand: any;
1296

1297
	public phase: LifecyclePhase;
1298
	public startupKind: StartupKind;
1299

1300
	private _onBeforeShutdown = new Emitter<BeforeShutdownEvent>();
1301
	private _onWillShutdown = new Emitter<WillShutdownEvent>();
1302
	private _onShutdown = new Emitter<void>();
1303

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

1308
	public fireShutdown(reason = ShutdownReason.QUIT): void {
1309
		this._onWillShutdown.fire({
1310 1311 1312
			join: () => { },
			reason
		});
1313 1314
	}

1315 1316 1317 1318 1319 1320
	public fireWillShutdown(event: BeforeShutdownEvent): void {
		this._onBeforeShutdown.fire(event);
	}

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

1323
	public get onWillShutdown(): Event<WillShutdownEvent> {
1324 1325 1326
		return this._onWillShutdown.event;
	}

1327
	public get onShutdown(): Event<void> {
1328 1329
		return this._onShutdown.event;
	}
1330 1331
}

1332 1333 1334 1335
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1336 1337
	public windowCount = 1;

1338 1339
	onWindowOpen: Event<number>;
	onWindowFocus: Event<number>;
1340
	onWindowBlur: Event<number>;
S
SteVen Batten 已提交
1341 1342
	onWindowMaximize: Event<number>;
	onWindowUnmaximize: Event<number>;
S
SteVen Batten 已提交
1343
	onRecentlyOpenedChange: Event<void>;
1344

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

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

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

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

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

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

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

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

J
Johannes Rieken 已提交
1377
	closeWorkspace(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1378
		return Promise.resolve();
1379
	}
1380

1381
	enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1382
		return Promise.resolve(undefined);
1383 1384
	}

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

J
Johannes Rieken 已提交
1389
	setRepresentedFilename(_windowId: number, _fileName: string): Promise<void> {
B
Benjamin Pasero 已提交
1390
		return Promise.resolve();
1391 1392
	}

M
Martin Aeschlimann 已提交
1393
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
B
Benjamin Pasero 已提交
1394
		return Promise.resolve();
1395
	}
1396

J
Johannes Rieken 已提交
1397
	removeFromRecentlyOpened(_paths: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1398
		return Promise.resolve();
1399
	}
1400

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

J
Johannes Rieken 已提交
1405
	getRecentlyOpened(_windowId: number): Promise<IRecentlyOpened> {
1406 1407 1408 1409
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1410
	}
1411

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

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

J
Johannes Rieken 已提交
1420
	isMaximized(_windowId: number): Promise<boolean> {
1421
		return Promise.resolve(false);
1422
	}
1423

J
Johannes Rieken 已提交
1424
	maximizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1425
		return Promise.resolve();
1426
	}
1427

J
Johannes Rieken 已提交
1428
	minimizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1429
		return Promise.resolve();
S
SteVen Batten 已提交
1430 1431
	}

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

J
Johannes Rieken 已提交
1436
	onWindowTitleDoubleClick(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1437
		return Promise.resolve();
1438
	}
1439

J
Johannes Rieken 已提交
1440
	setDocumentEdited(_windowId: number, _flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1441
		return Promise.resolve();
1442
	}
1443

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

J
Johannes Rieken 已提交
1448
	relaunch(_options: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
B
Benjamin Pasero 已提交
1449
		return Promise.resolve();
J
Johannes Rieken 已提交
1450
	}
1451

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

J
Johannes Rieken 已提交
1456
	toggleSharedProcess(): Promise<void> {
B
Benjamin Pasero 已提交
1457
		return Promise.resolve();
1458
	}
1459

1460
	// Global methods
M
Martin Aeschlimann 已提交
1461
	openWindow(_windowId: number, _uris: IURIToOpen[], _options: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1462
		return Promise.resolve();
1463
	}
1464

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

1469
	openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
1470 1471 1472
		return Promise.resolve();
	}

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

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

J
Joao Moreno 已提交
1481
	log(_severity: string, _args: string[]): Promise<void> {
B
Benjamin Pasero 已提交
1482
		return Promise.resolve();
1483
	}
1484

M
Martin Aeschlimann 已提交
1485
	showItemInFolder(_path: URI): Promise<void> {
B
Benjamin Pasero 已提交
1486
		return Promise.resolve();
1487
	}
1488

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

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

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

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

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

J
Johannes Rieken 已提交
1509
	toggleWindowTabsBar(): Promise<void> {
B
Benjamin Pasero 已提交
1510
		return Promise.resolve();
1511 1512
	}

J
Johannes Rieken 已提交
1513
	updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1514
		return Promise.resolve();
1515 1516
	}

J
Johannes Rieken 已提交
1517
	getActiveWindowId(): Promise<number | undefined> {
B
Benjamin Pasero 已提交
1518
		return Promise.resolve(undefined);
J
Joao Moreno 已提交
1519 1520
	}

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

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

J
Johannes Rieken 已提交
1532
	showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
1533
		throw new Error('not implemented');
1534 1535
	}

J
Johannes Rieken 已提交
1536
	showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): Promise<string> {
1537
		throw new Error('not implemented');
1538 1539
	}

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

J
Johannes Rieken 已提交
1544
	openAboutDialog(): Promise<void> {
B
Benjamin Pasero 已提交
1545
		return Promise.resolve();
J
Joao Moreno 已提交
1546
	}
1547 1548

	resolveProxy(windowId: number, url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1549
		return Promise.resolve(undefined);
1550
	}
1551
}
B
Benjamin Pasero 已提交
1552

1553 1554 1555 1556 1557 1558 1559
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1560
	public onDidChangeConfiguration() {
1561 1562 1563
		return { dispose() { } };
	}

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

S
Sandeep Somavarapu 已提交
1571 1572 1573 1574 1575
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

	_serviceBrand: any;

	constructor(
1576
		@IConfigurationService private readonly configurationService: IConfigurationService,
S
Sandeep Somavarapu 已提交
1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591
	) {
	}

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


1592
export class TestSharedProcessService implements ISharedProcessService {
1593 1594 1595

	_serviceBrand: ServiceIdentifier<any>;

1596 1597 1598
	getChannel(channelName: string): any {
		return undefined;
	}
1599

1600
	registerChannel(channelName: string, channel: any): void { }
1601 1602
}

1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629
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: '' }); }
J
Joao Moreno 已提交
1630
}