workbenchTestServices.ts 52.8 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';
87 88
import { IProductService } from 'vs/platform/product/common/product';
import product from 'vs/platform/product/node/product';
B
Benjamin Pasero 已提交
89

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

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

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

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

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

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

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

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

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

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

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

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

138
		return WorkbenchState.EMPTY;
S
Sandeep Somavarapu 已提交
139 140
	}

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

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

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

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

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

	public updateOptions() {

	}

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

		return false;
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

276 277
	public onFilesConfigurationChange(configuration: any): void {
		super.onFilesConfigurationChange(configuration);
278 279
	}

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

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

	return instantiationService;
}

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

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

export class TestMenuService implements IMenuService {

	public _serviceBrand: any;

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

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

	public _serviceBrand: any;

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

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

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

365 366 367
	public last(): void {
	}

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

	public clear(): void {
	}

B
Benjamin Pasero 已提交
374 375 376
	public clearRecentlyOpened(): void {
	}

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

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

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

	public openLastEditLocation(): void {
	}
B
Benjamin Pasero 已提交
391 392
}

393
export class TestDialogService implements IDialogService {
394 395

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

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

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

M
Martin Aeschlimann 已提交
406 407 408 409
export class TestFileDialogService implements IFileDialogService {

	public _serviceBrand: any;

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

442
export class TestLayoutService implements IWorkbenchLayoutService {
B
Benjamin Pasero 已提交
443

444
	public _serviceBrand: any;
E
Erich Gamma 已提交
445

446 447
	dimension: IDimension = { width: 800, height: 600 };

448 449
	container: HTMLElement = window.document.body;

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

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

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

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

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

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

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

479 480 481 482
	getDimension(_part: Parts): Dimension {
		return new Dimension(0, 0);
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

541 542
	public addClass(_clazz: string): void { }
	public removeClass(_clazz: string): void { }
543 544

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

I
isidor 已提交
547
	public toggleZenMode(): void { }
548

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


553
	public resizePart(_part: Parts, _sizeChange: number): void { }
554 555

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

558
let activeViewlet: Viewlet = {} as any;
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 601 602
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!;
	}
603 604 605 606

	public hideActiveViewlet(): void { }

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

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

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

650 651 652
	public hideActivePanel(): void { }

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

657
export class TestStorageService extends InMemoryStorageService { }
658

659 660
export class TestEditorGroupsService implements IEditorGroupsService {

661 662
	_serviceBrand: ServiceIdentifier<any>;

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

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

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

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

679
	get activeGroup(): IEditorGroup {
680 681 682 683 684 685 686
		return this.groups[0];
	}

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

687
	getGroups(_order?: GroupsOrder): ReadonlyArray<IEditorGroup> {
688 689 690
		return this.groups;
	}

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

698
		return undefined!;
699 700
	}

701
	getLabel(_identifier: number): string {
702 703 704
		return 'Group 1';
	}

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

709
	activateGroup(_group: number | IEditorGroup): IEditorGroup {
710
		throw new Error('not implemented');
711 712
	}

713 714
	getSize(_group: number | IEditorGroup): { width: number, height: number } {
		return { width: 100, height: 100 };
715 716
	}

717
	setSize(_group: number | IEditorGroup, _size: { width: number, height: number }): void { }
718

719
	arrangeGroups(_arrangement: GroupsArrangement): void { }
720

721
	applyLayout(_layout: EditorGroupLayout): void { }
722

723
	setGroupOrientation(_orientation: any): void { }
724

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

729
	removeGroup(_group: number | IEditorGroup): void { }
730

731
	moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
732
		throw new Error('not implemented');
733 734
	}

735
	mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup {
736
		throw new Error('not implemented');
737 738
	}

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

	centerLayout(active: boolean): void { }

	isLayoutCentered(): boolean {
		return false;
	}

	partOptions: IEditorPartOptions;
	enforcePartOptions(options: IEditorPartOptions): IDisposable {
		return Disposable.None;
752 753 754
	}
}

B
Benjamin Pasero 已提交
755
export class TestEditorGroup implements IEditorGroupView {
756 757 758

	constructor(public id: number) { }

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

775 776 777
	isEmpty = true;
	isMinimized = false;

778
	onWillDispose: Event<void> = Event.None;
779
	onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
B
Benjamin Pasero 已提交
780 781
	onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
782 783
	onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
	onDidOpenEditorFail: Event<IEditorInput> = Event.None;
B
Benjamin Pasero 已提交
784 785
	onDidFocus: Event<void> = Event.None;
	onDidChange: Event<{ width: number; height: number; }> = Event.None;
786

787
	getEditors(_order?: EditorsOrder): ReadonlyArray<IEditorInput> {
B
Benjamin Pasero 已提交
788 789 790
		return [];
	}

791
	getEditor(_index: number): IEditorInput {
792
		throw new Error('not implemented');
793 794
	}

795
	getIndexOfEditor(_editor: IEditorInput): number {
796 797 798
		return -1;
	}

J
Johannes Rieken 已提交
799
	openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditor> {
800
		throw new Error('not implemented');
801 802
	}

J
Johannes Rieken 已提交
803
	openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditor> {
804
		throw new Error('not implemented');
805 806
	}

807
	isOpened(_editor: IEditorInput): boolean {
808 809 810
		return false;
	}

811
	isPinned(_editor: IEditorInput): boolean {
812 813 814
		return false;
	}

815
	isActive(_editor: IEditorInput): boolean {
816 817 818
		return false;
	}

819
	moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
820

821
	copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
822

823
	closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> {
B
Benjamin Pasero 已提交
824
		return Promise.resolve();
825 826
	}

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

J
Johannes Rieken 已提交
831
	closeAllEditors(): Promise<void> {
B
Benjamin Pasero 已提交
832
		return Promise.resolve();
833 834
	}

J
Johannes Rieken 已提交
835
	replaceEditors(_editors: IEditorReplacement[]): Promise<void> {
B
Benjamin Pasero 已提交
836
		return Promise.resolve();
837 838
	}

839
	pinEditor(_editor?: IEditorInput): void { }
840 841 842 843

	focus(): void { }

	invokeWithinContext<T>(fn: (accessor: ServicesAccessor) => T): T {
844
		throw new Error('not implemented');
845
	}
B
Benjamin Pasero 已提交
846

847
	setActive(_isActive: boolean): void { }
B
Benjamin Pasero 已提交
848
	notifyIndexChanged(_index: number): void { }
B
Benjamin Pasero 已提交
849 850
	dispose(): void { }
	toJSON(): object { return Object.create(null); }
851
	layout(_width: number, _height: number): void { }
852
	relayout() { }
853 854
}

B
Benjamin Pasero 已提交
855
export class TestEditorService implements EditorServiceImpl {
856 857 858 859 860

	_serviceBrand: ServiceIdentifier<any>;

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
861
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
862 863
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

864
	activeControl: IVisibleEditor;
865
	activeTextEditorWidget: any;
866
	activeEditor: IEditorInput;
867
	editors: ReadonlyArray<IEditorInput> = [];
M
Matt Bierner 已提交
868
	visibleControls: ReadonlyArray<IVisibleEditor> = [];
869
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
870
	visibleEditors: ReadonlyArray<IEditorInput> = [];
871

872
	overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
R
Rob Lourens 已提交
873
		return toDisposable(() => undefined);
874 875
	}

876 877
	openEditor(_editor: any, _options?: any, _group?: any): Promise<any> {
		throw new Error('not implemented');
878 879
	}

880 881
	openEditors(_editors: any, _group?: any): Promise<IEditor[]> {
		throw new Error('not implemented');
882 883
	}

884
	isOpen(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
885 886 887
		return false;
	}

888
	getOpened(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): IEditorInput {
889
		throw new Error('not implemented');
890 891
	}

892
	replaceEditors(_editors: any, _group: any) {
R
Rob Lourens 已提交
893
		return Promise.resolve(undefined);
894 895
	}

896
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
897
		throw new Error('not implemented');
898 899
	}

900
	createInput(_input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
901
		throw new Error('not implemented');
902 903 904
	}
}

905 906 907 908
export class TestFileService implements IFileService {

	public _serviceBrand: any;

M
Matt Bierner 已提交
909 910
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
911

912
	readonly onWillActivateFileSystemProvider = Event.None;
913
	readonly onError: Event<Error> = Event.None;
914

915
	private content = 'Hello Html';
916
	private lastReadFileUri: URI;
917

918 919 920 921 922
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

923 924 925 926 927 928 929 930
	public setContent(content: string): void {
		this.content = content;
	}

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

931 932 933 934
	public getLastReadFileUri(): URI {
		return this.lastReadFileUri;
	}

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

B
Benjamin Pasero 已提交
965 966
	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 已提交
967 968
	}

B
Benjamin Pasero 已提交
969
	exists(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
970
		return Promise.resolve(true);
971
	}
B
Benjamin Pasero 已提交
972

973
	readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
974 975
		this.lastReadFileUri = resource;

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

987
	readFileStream(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileStreamContent> {
988 989
		this.lastReadFileUri = resource;

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

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

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

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

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

1037
	createFolder(_resource: URI): Promise<IFileStatWithMetadata> {
1038
		throw new Error('not implemented');
1039 1040
	}

1041 1042
	onDidChangeFileSystemProviderRegistrations = Event.None;

1043 1044 1045 1046 1047 1048
	private providers = new Map<string, IFileSystemProvider>();

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

		return toDisposable(() => this.providers.delete(scheme));
1049 1050
	}

1051 1052
	activateProvider(_scheme: string): Promise<void> {
		throw new Error('not implemented');
1053 1054
	}

1055
	canHandleResource(resource: URI): boolean {
1056
		return resource.scheme === 'file' || this.providers.has(resource.scheme);
1057 1058
	}

1059
	hasCapability(resource: URI, capability: FileSystemProviderCapabilities): boolean { return false; }
1060

J
Johannes Rieken 已提交
1061
	del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
1062
		return Promise.resolve();
1063 1064
	}

1065 1066
	watch(_resource: URI): IDisposable {
		return Disposable.None;
1067 1068
	}

1069 1070
	getWriteEncoding(_resource: URI): IResourceEncoding {
		return { encoding: 'utf8', hasBOM: false };
1071
	}
D
Daniel Imms 已提交
1072

1073
	dispose(): void {
E
Erich Gamma 已提交
1074
	}
1075
}
1076

1077 1078
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
1079

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

J
Johannes Rieken 已提交
1084
	public hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
1085
		return Promise.resolve(false);
1086 1087
	}

1088 1089 1090 1091
	public hasBackupSync(resource: URI, versionId?: number): boolean {
		return false;
	}

1092
	public loadBackupResource(resource: URI): Promise<URI | undefined> {
B
Benjamin Pasero 已提交
1093 1094
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
1095
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
1096 1097
			}

R
Rob Lourens 已提交
1098
			return undefined;
B
Benjamin Pasero 已提交
1099 1100 1101
		});
	}

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

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

1110
	public toBackupResource(_resource: URI): URI {
1111
		throw new Error('not implemented');
D
Daniel Imms 已提交
1112
	}
1113

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

J
Johannes Rieken 已提交
1118
	public getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
1119
		return Promise.resolve([]);
1120 1121
	}

1122 1123 1124 1125 1126
	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);
1127 1128
	}

1129
	public resolveBackupContent<T extends object>(_backup: URI): Promise<IResolvedBackup<T>> {
1130
		throw new Error('not implemented');
1131 1132
	}

J
Johannes Rieken 已提交
1133
	public discardResourceBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1134
		return Promise.resolve();
1135 1136
	}

J
Johannes Rieken 已提交
1137
	public discardAllWorkspaceBackups(): Promise<void> {
B
Benjamin Pasero 已提交
1138
		return Promise.resolve();
1139
	}
1140
}
D
Daniel Imms 已提交
1141

B
Benjamin Pasero 已提交
1142 1143 1144 1145 1146 1147 1148
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 已提交
1149
	onDidChangeTransientModelProperty: Event<ITextModel> = Event.None;
B
Benjamin Pasero 已提交
1150

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

1167 1168 1169 1170
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

1171
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
S
SteVen Batten 已提交
1172
	onDidChangeMaximize: Event<boolean>;
1173

1174
	hasFocus = true;
1175

1176
	readonly windowId = 0;
S
SteVen Batten 已提交
1177

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

J
Johannes Rieken 已提交
1182
	isMaximized(): Promise<boolean> {
B
Benjamin Pasero 已提交
1183
		return Promise.resolve(false);
1184 1185
	}

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

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

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

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

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

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

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

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

M
Matt Bierner 已提交
1218
	enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1219
		return Promise.resolve(undefined);
1220 1221
	}

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

J
Johannes Rieken 已提交
1226
	setRepresentedFilename(_fileName: string): Promise<void> {
B
Benjamin Pasero 已提交
1227
		return Promise.resolve();
1228 1229
	}

J
Johannes Rieken 已提交
1230
	getRecentlyOpened(): Promise<IRecentlyOpened> {
1231 1232 1233 1234
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1235 1236
	}

1237 1238 1239 1240 1241 1242 1243 1244
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
		return Promise.resolve();
	}

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

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

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

J
Johannes Rieken 已提交
1253
	unmaximizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1254
		return Promise.resolve();
S
SteVen Batten 已提交
1255 1256
	}

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

M
Martin Aeschlimann 已提交
1261
	openWindow(_uris: IURIToOpen[], _options?: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1262
		return Promise.resolve();
1263 1264
	}

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

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

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

J
Johannes Rieken 已提交
1277
	showMessageBox(_options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
B
Benjamin Pasero 已提交
1278
		return Promise.resolve({ button: 0 });
1279 1280
	}

J
Johannes Rieken 已提交
1281
	showSaveDialog(_options: Electron.SaveDialogOptions): Promise<string> {
1282
		throw new Error('not implemented');
1283
	}
1284

J
Johannes Rieken 已提交
1285
	showOpenDialog(_options: Electron.OpenDialogOptions): Promise<string[]> {
1286
		throw new Error('not implemented');
1287
	}
1288

J
Johannes Rieken 已提交
1289
	updateTouchBar(_items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1290
		return Promise.resolve();
1291
	}
1292 1293

	resolveProxy(url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1294
		return Promise.resolve(undefined);
1295
	}
1296 1297
}

1298 1299
export class TestLifecycleService implements ILifecycleService {

1300
	public _serviceBrand: any;
1301

1302
	public phase: LifecyclePhase;
1303
	public startupKind: StartupKind;
1304

1305
	private _onBeforeShutdown = new Emitter<BeforeShutdownEvent>();
1306
	private _onWillShutdown = new Emitter<WillShutdownEvent>();
1307
	private _onShutdown = new Emitter<void>();
1308

J
Johannes Rieken 已提交
1309
	when(): Promise<void> {
B
Benjamin Pasero 已提交
1310
		return Promise.resolve();
B
Benjamin Pasero 已提交
1311
	}
1312

1313
	public fireShutdown(reason = ShutdownReason.QUIT): void {
1314
		this._onWillShutdown.fire({
1315 1316 1317
			join: () => { },
			reason
		});
1318 1319
	}

1320 1321 1322 1323 1324 1325
	public fireWillShutdown(event: BeforeShutdownEvent): void {
		this._onBeforeShutdown.fire(event);
	}

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

1328
	public get onWillShutdown(): Event<WillShutdownEvent> {
1329 1330 1331
		return this._onWillShutdown.event;
	}

1332
	public get onShutdown(): Event<void> {
1333 1334
		return this._onShutdown.event;
	}
1335 1336
}

1337 1338 1339 1340
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1341 1342
	public windowCount = 1;

1343 1344 1345 1346 1347 1348
	readonly onWindowOpen: Event<number> = Event.None;
	readonly onWindowFocus: Event<number> = Event.None;
	readonly onWindowBlur: Event<number> = Event.None;
	readonly onWindowMaximize: Event<number> = Event.None;
	readonly onWindowUnmaximize: Event<number> = Event.None;
	readonly onRecentlyOpenedChange: Event<void> = Event.None;
1349

J
Johannes Rieken 已提交
1350
	isFocused(_windowId: number): Promise<boolean> {
B
Benjamin Pasero 已提交
1351
		return Promise.resolve(false);
1352 1353
	}

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

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

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

J
Johannes Rieken 已提交
1366
	pickWorkspaceAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
B
Benjamin Pasero 已提交
1367
		return Promise.resolve();
1368 1369
	}

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

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

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

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

1386
	enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1387
		return Promise.resolve(undefined);
1388 1389
	}

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

J
Johannes Rieken 已提交
1394
	setRepresentedFilename(_windowId: number, _fileName: string): Promise<void> {
B
Benjamin Pasero 已提交
1395
		return Promise.resolve();
1396 1397
	}

M
Martin Aeschlimann 已提交
1398
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
B
Benjamin Pasero 已提交
1399
		return Promise.resolve();
1400
	}
1401

J
Johannes Rieken 已提交
1402
	removeFromRecentlyOpened(_paths: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1403
		return Promise.resolve();
1404
	}
1405

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

J
Johannes Rieken 已提交
1410
	getRecentlyOpened(_windowId: number): Promise<IRecentlyOpened> {
1411 1412 1413 1414
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1415
	}
1416

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

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

J
Johannes Rieken 已提交
1425
	isMaximized(_windowId: number): Promise<boolean> {
1426
		return Promise.resolve(false);
1427
	}
1428

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

J
Johannes Rieken 已提交
1433
	minimizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1434
		return Promise.resolve();
S
SteVen Batten 已提交
1435 1436
	}

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

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

J
Johannes Rieken 已提交
1445
	setDocumentEdited(_windowId: number, _flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1446
		return Promise.resolve();
1447
	}
1448

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

J
Johannes Rieken 已提交
1453
	relaunch(_options: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
B
Benjamin Pasero 已提交
1454
		return Promise.resolve();
J
Johannes Rieken 已提交
1455
	}
1456

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

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

1465
	// Global methods
M
Martin Aeschlimann 已提交
1466
	openWindow(_windowId: number, _uris: IURIToOpen[], _options: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1467
		return Promise.resolve();
1468
	}
1469

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

1474
	openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
1475 1476 1477
		return Promise.resolve();
	}

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

J
Johannes Rieken 已提交
1482
	getWindowCount(): Promise<number> {
B
Benjamin Pasero 已提交
1483
		return Promise.resolve(this.windowCount);
1484
	}
1485

J
Joao Moreno 已提交
1486
	log(_severity: string, _args: string[]): Promise<void> {
B
Benjamin Pasero 已提交
1487
		return Promise.resolve();
1488
	}
1489

M
Martin Aeschlimann 已提交
1490
	showItemInFolder(_path: URI): Promise<void> {
B
Benjamin Pasero 已提交
1491
		return Promise.resolve();
1492
	}
1493

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

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

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

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

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

J
Johannes Rieken 已提交
1514
	toggleWindowTabsBar(): Promise<void> {
B
Benjamin Pasero 已提交
1515
		return Promise.resolve();
1516 1517
	}

J
Johannes Rieken 已提交
1518
	updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1519
		return Promise.resolve();
1520 1521
	}

J
Johannes Rieken 已提交
1522
	getActiveWindowId(): Promise<number | undefined> {
B
Benjamin Pasero 已提交
1523
		return Promise.resolve(undefined);
J
Joao Moreno 已提交
1524 1525
	}

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

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

J
Johannes Rieken 已提交
1537
	showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
1538
		throw new Error('not implemented');
1539 1540
	}

J
Johannes Rieken 已提交
1541
	showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): Promise<string> {
1542
		throw new Error('not implemented');
1543 1544
	}

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

J
Johannes Rieken 已提交
1549
	openAboutDialog(): Promise<void> {
B
Benjamin Pasero 已提交
1550
		return Promise.resolve();
J
Joao Moreno 已提交
1551
	}
1552 1553

	resolveProxy(windowId: number, url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1554
		return Promise.resolve(undefined);
1555
	}
1556
}
B
Benjamin Pasero 已提交
1557

1558 1559 1560 1561 1562 1563 1564
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1565
	public onDidChangeConfiguration() {
1566 1567 1568
		return { dispose() { } };
	}

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

S
Sandeep Somavarapu 已提交
1576 1577 1578 1579 1580
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

	_serviceBrand: any;

	constructor(
1581
		@IConfigurationService private readonly configurationService: IConfigurationService,
S
Sandeep Somavarapu 已提交
1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596
	) {
	}

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


1597
export class TestSharedProcessService implements ISharedProcessService {
1598 1599 1600

	_serviceBrand: ServiceIdentifier<any>;

1601 1602 1603
	getChannel(channelName: string): any {
		return undefined;
	}
1604

1605
	registerChannel(channelName: string, channel: any): void { }
1606 1607
}

1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634
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 已提交
1635
}
1636 1637

export const productService: IProductService = { _serviceBrand: undefined, ...product };