workbenchTestServices.ts 53.0 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 545
	public getMaximumEditorDimensions(): Dimension { throw new Error('not implemented'); }

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

I
isidor 已提交
549
	public toggleZenMode(): void { }
550

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


555
	public resizePart(_part: Parts, _sizeChange: number): void { }
556 557

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

560
let activeViewlet: Viewlet = {} as any;
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 603 604
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!;
	}
605 606 607 608

	public hideActiveViewlet(): void { }

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

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

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

652 653 654
	public hideActivePanel(): void { }

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

659
export class TestStorageService extends InMemoryStorageService { }
660

661 662
export class TestEditorGroupsService implements IEditorGroupsService {

663 664
	_serviceBrand: ServiceIdentifier<any>;

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

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

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

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

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

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

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

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

700
		return undefined!;
701 702
	}

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

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

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

B
Benjamin Pasero 已提交
715 716 717 718
	restoreGroup(_group: number | IEditorGroup): IEditorGroup {
		throw new Error('not implemented');
	}

719 720
	getSize(_group: number | IEditorGroup): { width: number, height: number } {
		return { width: 100, height: 100 };
721 722
	}

723
	setSize(_group: number | IEditorGroup, _size: { width: number, height: number }): void { }
724

725
	arrangeGroups(_arrangement: GroupsArrangement): void { }
726

727
	applyLayout(_layout: EditorGroupLayout): void { }
728

729
	setGroupOrientation(_orientation: any): void { }
730

731
	addGroup(_location: number | IEditorGroup, _direction: GroupDirection, _options?: IAddGroupOptions): IEditorGroup {
732
		throw new Error('not implemented');
733 734
	}

735
	removeGroup(_group: number | IEditorGroup): void { }
736

737
	moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
738
		throw new Error('not implemented');
739 740
	}

741
	mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup {
742
		throw new Error('not implemented');
743 744
	}

745
	copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
746
		throw new Error('not implemented');
747
	}
748 749 750 751 752 753 754 755 756 757

	centerLayout(active: boolean): void { }

	isLayoutCentered(): boolean {
		return false;
	}

	partOptions: IEditorPartOptions;
	enforcePartOptions(options: IEditorPartOptions): IDisposable {
		return Disposable.None;
758 759 760
	}
}

B
Benjamin Pasero 已提交
761
export class TestEditorGroup implements IEditorGroupView {
762 763 764

	constructor(public id: number) { }

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

781 782 783
	isEmpty = true;
	isMinimized = false;

784
	onWillDispose: Event<void> = Event.None;
785
	onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
B
Benjamin Pasero 已提交
786 787
	onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
788 789
	onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
	onDidOpenEditorFail: Event<IEditorInput> = Event.None;
B
Benjamin Pasero 已提交
790 791
	onDidFocus: Event<void> = Event.None;
	onDidChange: Event<{ width: number; height: number; }> = Event.None;
792

793
	getEditors(_order?: EditorsOrder): ReadonlyArray<IEditorInput> {
B
Benjamin Pasero 已提交
794 795 796
		return [];
	}

797
	getEditor(_index: number): IEditorInput {
798
		throw new Error('not implemented');
799 800
	}

801
	getIndexOfEditor(_editor: IEditorInput): number {
802 803 804
		return -1;
	}

J
Johannes Rieken 已提交
805
	openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditor> {
806
		throw new Error('not implemented');
807 808
	}

J
Johannes Rieken 已提交
809
	openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditor> {
810
		throw new Error('not implemented');
811 812
	}

813
	isOpened(_editor: IEditorInput): boolean {
814 815 816
		return false;
	}

817
	isPinned(_editor: IEditorInput): boolean {
818 819 820
		return false;
	}

821
	isActive(_editor: IEditorInput): boolean {
822 823 824
		return false;
	}

825
	moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
826

827
	copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
828

829
	closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> {
B
Benjamin Pasero 已提交
830
		return Promise.resolve();
831 832
	}

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

J
Johannes Rieken 已提交
837
	closeAllEditors(): Promise<void> {
B
Benjamin Pasero 已提交
838
		return Promise.resolve();
839 840
	}

J
Johannes Rieken 已提交
841
	replaceEditors(_editors: IEditorReplacement[]): Promise<void> {
B
Benjamin Pasero 已提交
842
		return Promise.resolve();
843 844
	}

845
	pinEditor(_editor?: IEditorInput): void { }
846 847 848 849

	focus(): void { }

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

853
	setActive(_isActive: boolean): void { }
B
Benjamin Pasero 已提交
854
	notifyIndexChanged(_index: number): void { }
B
Benjamin Pasero 已提交
855 856
	dispose(): void { }
	toJSON(): object { return Object.create(null); }
857
	layout(_width: number, _height: number): void { }
858
	relayout() { }
859 860
}

B
Benjamin Pasero 已提交
861
export class TestEditorService implements EditorServiceImpl {
862 863 864 865 866

	_serviceBrand: ServiceIdentifier<any>;

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
867
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
868 869
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

870
	activeControl: IVisibleEditor;
871
	activeTextEditorWidget: any;
872
	activeEditor: IEditorInput;
873
	editors: ReadonlyArray<IEditorInput> = [];
M
Matt Bierner 已提交
874
	visibleControls: ReadonlyArray<IVisibleEditor> = [];
875
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
876
	visibleEditors: ReadonlyArray<IEditorInput> = [];
877

878
	overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
R
Rob Lourens 已提交
879
		return toDisposable(() => undefined);
880 881
	}

882 883
	openEditor(_editor: any, _options?: any, _group?: any): Promise<any> {
		throw new Error('not implemented');
884 885
	}

886 887
	openEditors(_editors: any, _group?: any): Promise<IEditor[]> {
		throw new Error('not implemented');
888 889
	}

890
	isOpen(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
891 892 893
		return false;
	}

894
	getOpened(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): IEditorInput {
895
		throw new Error('not implemented');
896 897
	}

898
	replaceEditors(_editors: any, _group: any) {
R
Rob Lourens 已提交
899
		return Promise.resolve(undefined);
900 901
	}

902
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
903
		throw new Error('not implemented');
904 905
	}

906
	createInput(_input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
907
		throw new Error('not implemented');
908 909 910
	}
}

911 912 913 914
export class TestFileService implements IFileService {

	public _serviceBrand: any;

M
Matt Bierner 已提交
915 916
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
917

918
	readonly onWillActivateFileSystemProvider = Event.None;
919
	readonly onError: Event<Error> = Event.None;
920

921
	private content = 'Hello Html';
922
	private lastReadFileUri: URI;
923

924 925 926 927 928
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

929 930 931 932 933 934 935 936
	public setContent(content: string): void {
		this.content = content;
	}

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

937 938 939 940
	public getLastReadFileUri(): URI {
		return this.lastReadFileUri;
	}

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

B
Benjamin Pasero 已提交
971 972
	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 已提交
973 974
	}

B
Benjamin Pasero 已提交
975
	exists(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
976
		return Promise.resolve(true);
977
	}
B
Benjamin Pasero 已提交
978

979
	readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
980 981
		this.lastReadFileUri = resource;

982
		return Promise.resolve({
B
Benjamin Pasero 已提交
983
			resource: resource,
984
			value: VSBuffer.fromString(this.content),
985
			etag: 'index.txt',
B
Benjamin Pasero 已提交
986 987
			encoding: 'utf8',
			mtime: Date.now(),
988 989
			name: resources.basename(resource),
			size: 1
E
Erich Gamma 已提交
990
		});
991
	}
E
Erich Gamma 已提交
992

993
	readFileStream(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileStreamContent> {
994 995
		this.lastReadFileUri = resource;

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

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

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

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

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

1043
	createFolder(_resource: URI): Promise<IFileStatWithMetadata> {
1044
		throw new Error('not implemented');
1045 1046
	}

1047 1048
	onDidChangeFileSystemProviderRegistrations = Event.None;

1049 1050 1051 1052 1053 1054
	private providers = new Map<string, IFileSystemProvider>();

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

		return toDisposable(() => this.providers.delete(scheme));
1055 1056
	}

1057 1058
	activateProvider(_scheme: string): Promise<void> {
		throw new Error('not implemented');
1059 1060
	}

1061
	canHandleResource(resource: URI): boolean {
1062
		return resource.scheme === 'file' || this.providers.has(resource.scheme);
1063 1064
	}

1065
	hasCapability(resource: URI, capability: FileSystemProviderCapabilities): boolean { return false; }
1066

J
Johannes Rieken 已提交
1067
	del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
1068
		return Promise.resolve();
1069 1070
	}

1071 1072
	watch(_resource: URI): IDisposable {
		return Disposable.None;
1073 1074
	}

1075 1076
	getWriteEncoding(_resource: URI): IResourceEncoding {
		return { encoding: 'utf8', hasBOM: false };
1077
	}
D
Daniel Imms 已提交
1078

1079
	dispose(): void {
E
Erich Gamma 已提交
1080
	}
1081
}
1082

1083 1084
export class TestBackupFileService implements IBackupFileService {
	public _serviceBrand: any;
1085

J
Johannes Rieken 已提交
1086
	public hasBackups(): Promise<boolean> {
B
Benjamin Pasero 已提交
1087
		return Promise.resolve(false);
1088 1089
	}

J
Johannes Rieken 已提交
1090
	public hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
1091
		return Promise.resolve(false);
1092 1093
	}

1094 1095 1096 1097
	public hasBackupSync(resource: URI, versionId?: number): boolean {
		return false;
	}

1098
	public loadBackupResource(resource: URI): Promise<URI | undefined> {
B
Benjamin Pasero 已提交
1099 1100
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
1101
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
1102 1103
			}

R
Rob Lourens 已提交
1104
			return undefined;
B
Benjamin Pasero 已提交
1105 1106 1107
		});
	}

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

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

1116
	public toBackupResource(_resource: URI): URI {
1117
		throw new Error('not implemented');
D
Daniel Imms 已提交
1118
	}
1119

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

J
Johannes Rieken 已提交
1124
	public getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
1125
		return Promise.resolve([]);
1126 1127
	}

1128 1129 1130 1131 1132
	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);
1133 1134
	}

1135
	public resolveBackupContent<T extends object>(_backup: URI): Promise<IResolvedBackup<T>> {
1136
		throw new Error('not implemented');
1137 1138
	}

J
Johannes Rieken 已提交
1139
	public discardResourceBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1140
		return Promise.resolve();
1141 1142
	}

J
Johannes Rieken 已提交
1143
	public discardAllWorkspaceBackups(): Promise<void> {
B
Benjamin Pasero 已提交
1144
		return Promise.resolve();
1145
	}
1146
}
D
Daniel Imms 已提交
1147

B
Benjamin Pasero 已提交
1148 1149 1150 1151 1152 1153 1154
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 已提交
1155
	onDidChangeTransientModelProperty: Event<ITextModel> = Event.None;
B
Benjamin Pasero 已提交
1156

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

1173 1174 1175 1176
export class TestWindowService implements IWindowService {

	public _serviceBrand: any;

1177
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
S
SteVen Batten 已提交
1178
	onDidChangeMaximize: Event<boolean>;
1179

1180
	hasFocus = true;
1181

1182
	readonly windowId = 0;
S
SteVen Batten 已提交
1183

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

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

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

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

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

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

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

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

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

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

M
Matt Bierner 已提交
1224
	enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1225
		return Promise.resolve(undefined);
1226 1227
	}

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

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

J
Johannes Rieken 已提交
1236
	getRecentlyOpened(): Promise<IRecentlyOpened> {
1237 1238 1239 1240
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1241 1242
	}

1243 1244 1245 1246 1247 1248 1249 1250
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
		return Promise.resolve();
	}

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

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

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

J
Johannes Rieken 已提交
1259
	unmaximizeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1260
		return Promise.resolve();
S
SteVen Batten 已提交
1261 1262
	}

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

M
Martin Aeschlimann 已提交
1267
	openWindow(_uris: IURIToOpen[], _options?: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1268
		return Promise.resolve();
1269 1270
	}

J
Johannes Rieken 已提交
1271
	closeWindow(): Promise<void> {
B
Benjamin Pasero 已提交
1272
		return Promise.resolve();
1273 1274
	}

J
Johannes Rieken 已提交
1275
	setDocumentEdited(_flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1276
		return Promise.resolve();
1277
	}
1278

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

J
Johannes Rieken 已提交
1283
	showMessageBox(_options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
B
Benjamin Pasero 已提交
1284
		return Promise.resolve({ button: 0 });
1285 1286
	}

J
Johannes Rieken 已提交
1287
	showSaveDialog(_options: Electron.SaveDialogOptions): Promise<string> {
1288
		throw new Error('not implemented');
1289
	}
1290

J
Johannes Rieken 已提交
1291
	showOpenDialog(_options: Electron.OpenDialogOptions): Promise<string[]> {
1292
		throw new Error('not implemented');
1293
	}
1294

J
Johannes Rieken 已提交
1295
	updateTouchBar(_items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1296
		return Promise.resolve();
1297
	}
1298 1299

	resolveProxy(url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1300
		return Promise.resolve(undefined);
1301
	}
1302 1303
}

1304 1305
export class TestLifecycleService implements ILifecycleService {

1306
	public _serviceBrand: any;
1307

1308
	public phase: LifecyclePhase;
1309
	public startupKind: StartupKind;
1310

1311
	private _onBeforeShutdown = new Emitter<BeforeShutdownEvent>();
1312
	private _onWillShutdown = new Emitter<WillShutdownEvent>();
1313
	private _onShutdown = new Emitter<void>();
1314

J
Johannes Rieken 已提交
1315
	when(): Promise<void> {
B
Benjamin Pasero 已提交
1316
		return Promise.resolve();
B
Benjamin Pasero 已提交
1317
	}
1318

1319
	public fireShutdown(reason = ShutdownReason.QUIT): void {
1320
		this._onWillShutdown.fire({
1321 1322 1323
			join: () => { },
			reason
		});
1324 1325
	}

1326 1327 1328 1329 1330 1331
	public fireWillShutdown(event: BeforeShutdownEvent): void {
		this._onBeforeShutdown.fire(event);
	}

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

1334
	public get onWillShutdown(): Event<WillShutdownEvent> {
1335 1336 1337
		return this._onWillShutdown.event;
	}

1338
	public get onShutdown(): Event<void> {
1339 1340
		return this._onShutdown.event;
	}
1341 1342
}

1343 1344 1345 1346
export class TestWindowsService implements IWindowsService {

	_serviceBrand: any;

1347 1348
	public windowCount = 1;

1349 1350 1351 1352 1353 1354
	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;
1355

J
Johannes Rieken 已提交
1356
	isFocused(_windowId: number): Promise<boolean> {
B
Benjamin Pasero 已提交
1357
		return Promise.resolve(false);
1358 1359
	}

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

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

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

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

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

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

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

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

1392
	enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1393
		return Promise.resolve(undefined);
1394 1395
	}

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

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

M
Martin Aeschlimann 已提交
1404
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
B
Benjamin Pasero 已提交
1405
		return Promise.resolve();
1406
	}
1407

J
Johannes Rieken 已提交
1408
	removeFromRecentlyOpened(_paths: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1409
		return Promise.resolve();
1410
	}
1411

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

J
Johannes Rieken 已提交
1416
	getRecentlyOpened(_windowId: number): Promise<IRecentlyOpened> {
1417 1418 1419 1420
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1421
	}
1422

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

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

J
Johannes Rieken 已提交
1431
	isMaximized(_windowId: number): Promise<boolean> {
1432
		return Promise.resolve(false);
1433
	}
1434

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

J
Johannes Rieken 已提交
1439
	minimizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1440
		return Promise.resolve();
S
SteVen Batten 已提交
1441 1442
	}

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

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

J
Johannes Rieken 已提交
1451
	setDocumentEdited(_windowId: number, _flag: boolean): Promise<void> {
B
Benjamin Pasero 已提交
1452
		return Promise.resolve();
1453
	}
1454

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

J
Johannes Rieken 已提交
1459
	relaunch(_options: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
B
Benjamin Pasero 已提交
1460
		return Promise.resolve();
J
Johannes Rieken 已提交
1461
	}
1462

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

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

1471
	// Global methods
M
Martin Aeschlimann 已提交
1472
	openWindow(_windowId: number, _uris: IURIToOpen[], _options: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1473
		return Promise.resolve();
1474
	}
1475

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

1480
	openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
1481 1482 1483
		return Promise.resolve();
	}

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

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

J
Joao Moreno 已提交
1492
	log(_severity: string, _args: string[]): Promise<void> {
B
Benjamin Pasero 已提交
1493
		return Promise.resolve();
1494
	}
1495

M
Martin Aeschlimann 已提交
1496
	showItemInFolder(_path: URI): Promise<void> {
B
Benjamin Pasero 已提交
1497
		return Promise.resolve();
1498
	}
1499

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

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

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

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

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

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

J
Johannes Rieken 已提交
1524
	updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1525
		return Promise.resolve();
1526 1527
	}

J
Johannes Rieken 已提交
1528
	getActiveWindowId(): Promise<number | undefined> {
B
Benjamin Pasero 已提交
1529
		return Promise.resolve(undefined);
J
Joao Moreno 已提交
1530 1531
	}

1532 1533
	// This needs to be handled from browser process to prevent
	// foreground ordering issues on Windows
J
Johannes Rieken 已提交
1534
	openExternal(_url: string): Promise<boolean> {
B
Benjamin Pasero 已提交
1535
		return Promise.resolve(true);
1536 1537 1538
	}

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

J
Johannes Rieken 已提交
1543
	showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
1544
		throw new Error('not implemented');
1545 1546
	}

J
Johannes Rieken 已提交
1547
	showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): Promise<string> {
1548
		throw new Error('not implemented');
1549 1550
	}

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

J
Johannes Rieken 已提交
1555
	openAboutDialog(): Promise<void> {
B
Benjamin Pasero 已提交
1556
		return Promise.resolve();
J
Joao Moreno 已提交
1557
	}
1558 1559

	resolveProxy(windowId: number, url: string): Promise<string | undefined> {
R
Rob Lourens 已提交
1560
		return Promise.resolve(undefined);
1561
	}
1562
}
B
Benjamin Pasero 已提交
1563

1564 1565 1566 1567 1568 1569 1570
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

	_serviceBrand: any;

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

1571
	public onDidChangeConfiguration() {
1572 1573 1574
		return { dispose() { } };
	}

1575
	getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
1576 1577
		const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;
		const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
1578
		return this.configurationService.getValue(section, { resource });
1579
	}
B
Benjamin Pasero 已提交
1580 1581
}

S
Sandeep Somavarapu 已提交
1582 1583 1584 1585 1586
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

	_serviceBrand: any;

	constructor(
1587
		@IConfigurationService private readonly configurationService: IConfigurationService,
S
Sandeep Somavarapu 已提交
1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602
	) {
	}

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


1603
export class TestSharedProcessService implements ISharedProcessService {
1604 1605 1606

	_serviceBrand: ServiceIdentifier<any>;

1607 1608 1609
	getChannel(channelName: string): any {
		return undefined;
	}
1610

1611
	registerChannel(channelName: string, channel: any): void { }
1612 1613
}

1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640
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 已提交
1641
}
1642 1643

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