workbenchTestServices.ts 50.5 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';
33
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
J
Johannes Rieken 已提交
34 35
import { IModeService } from 'vs/editor/common/services/modeService';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
36
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
37
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
38
import { IWindowsService, IWindowService, IEnterWorkspaceResult, MenuBarVisibility, IURIToOpen, IOpenSettings, IWindowConfiguration, CrashReporterStartOptions } 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';
53
import { IConfirmation, IConfirmationResult, IDialogService, IDialogOptions, IPickAndOpenOptions, ISaveDialogOptions, IOpenDialogOptions, IFileDialogService, IShowResult } 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';
85
import { NativeTextFileService } from 'vs/workbench/services/textfile/electron-browser/nativeTextFileService';
86
import { Schemas } from 'vs/base/common/network';
87
import { IProductService } from 'vs/platform/product/common/productService';
88
import product from 'vs/platform/product/common/product';
89
import { IHostService } from 'vs/workbench/services/host/browser/host';
B
Benjamin Pasero 已提交
90

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

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

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

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

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

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

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

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

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

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

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

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

140
		return WorkbenchState.EMPTY;
S
Sandeep Somavarapu 已提交
141 142
	}

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

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

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

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

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

	public updateOptions() {

	}

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

		return false;
	}

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

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

184
export class TestTextFileService extends NativeTextFileService {
185 186
	public cleanupBackupsBeforeShutdownCalled: boolean;

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

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

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

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

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

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

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

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

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

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

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

278 279
	public onFilesConfigurationChange(configuration: any): void {
		super.onFilesConfigurationChange(configuration);
280 281
	}

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

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

	return instantiationService;
}

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

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

export class TestMenuService implements IMenuService {

341
	public _serviceBrand: undefined;
B
Benjamin Pasero 已提交
342

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

B
Benjamin Pasero 已提交
352 353
export class TestHistoryService implements IHistoryService {

354
	public _serviceBrand: undefined;
B
Benjamin Pasero 已提交
355 356 357 358 359 360 361

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

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

365
	public back(_acrossEditors?: boolean): void {
B
Benjamin Pasero 已提交
366 367
	}

368 369 370
	public last(): void {
	}

371
	public remove(_input: IEditorInput | IResourceInput): void {
B
Benjamin Pasero 已提交
372 373 374 375 376
	}

	public clear(): void {
	}

B
Benjamin Pasero 已提交
377 378 379
	public clearRecentlyOpened(): void {
	}

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

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

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

	public openLastEditLocation(): void {
	}
B
Benjamin Pasero 已提交
394 395
}

396
export class TestDialogService implements IDialogService {
397

398
	public _serviceBrand: undefined;
E
Erich Gamma 已提交
399

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

404 405
	public show(_severity: Severity, _message: string, _buttons: string[], _options?: IDialogOptions): Promise<IShowResult> {
		return Promise.resolve({ choice: 0 });
406
	}
407 408 409 410

	public about(): Promise<void> {
		return Promise.resolve();
	}
E
Erich Gamma 已提交
411 412
}

M
Martin Aeschlimann 已提交
413 414
export class TestFileDialogService implements IFileDialogService {

415
	public _serviceBrand: undefined;
M
Martin Aeschlimann 已提交
416

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

449
export class TestLayoutService implements IWorkbenchLayoutService {
B
Benjamin Pasero 已提交
450

451
	public _serviceBrand: undefined;
E
Erich Gamma 已提交
452

453 454
	dimension: IDimension = { width: 800, height: 600 };

455 456
	container: HTMLElement = window.document.body;

B
Benjamin Pasero 已提交
457
	onZenModeChange: Event<boolean> = Event.None;
S
SteVen Batten 已提交
458 459
	onCenteredLayoutChange: Event<boolean> = Event.None;
	onFullscreenChange: Event<boolean> = Event.None;
460
	onPanelPositionChange: Event<string> = Event.None;
461
	onLayout = Event.None;
B
Benjamin Pasero 已提交
462

463
	private _onTitleBarVisibilityChange = new Emitter<void>();
464
	private _onMenubarVisibilityChange = new Emitter<Dimension>();
465 466 467 468 469

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

470 471 472 473
	public get onMenubarVisibilityChange(): Event<Dimension> {
		return this._onMenubarVisibilityChange.event;
	}

B
Benjamin Pasero 已提交
474
	public isRestored(): boolean {
E
Erich Gamma 已提交
475 476 477
		return true;
	}

478
	public hasFocus(_part: Parts): boolean {
E
Erich Gamma 已提交
479 480 481
		return false;
	}

482
	public isVisible(_part: Parts): boolean {
E
Erich Gamma 已提交
483 484 485
		return true;
	}

486 487 488 489
	getDimension(_part: Parts): Dimension {
		return new Dimension(0, 0);
	}

490
	public getContainer(_part: Parts): HTMLElement {
B
Benjamin Pasero 已提交
491
		return null!;
492 493
	}

B
Benjamin Pasero 已提交
494 495 496 497
	public isTitleBarHidden(): boolean {
		return false;
	}

498 499 500 501
	public getTitleBarOffset(): number {
		return 0;
	}

502 503 504 505
	public isStatusBarHidden(): boolean {
		return false;
	}

S
Sanders Lauture 已提交
506 507 508 509
	public isActivityBarHidden(): boolean {
		return false;
	}

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

E
Erich Gamma 已提交
512 513 514 515
	public isSideBarHidden(): boolean {
		return false;
	}

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

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

I
isidor 已提交
520
	public isPanelHidden(): boolean {
I
isidor 已提交
521 522 523
		return false;
	}

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

I
isidor 已提交
526 527
	public toggleMaximizedPanel(): void { }

B
Benjamin Pasero 已提交
528 529 530 531
	public isPanelMaximized(): boolean {
		return false;
	}

S
SteVen Batten 已提交
532
	public getMenubarVisibility(): MenuBarVisibility {
533
		throw new Error('not implemented');
S
SteVen Batten 已提交
534 535
	}

E
Erich Gamma 已提交
536 537 538 539
	public getSideBarPosition() {
		return 0;
	}

I
isidor 已提交
540 541 542 543
	public getPanelPosition() {
		return 0;
	}

J
Johannes Rieken 已提交
544
	public setPanelPosition(_position: PartPosition): Promise<void> {
545
		return Promise.resolve();
I
isidor 已提交
546 547
	}

548 549
	public addClass(_clazz: string): void { }
	public removeClass(_clazz: string): void { }
550

551 552
	public getMaximumEditorDimensions(): Dimension { throw new Error('not implemented'); }

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

I
isidor 已提交
556
	public toggleZenMode(): void { }
557

B
Benjamin Pasero 已提交
558
	public isEditorLayoutCentered(): boolean { return false; }
559
	public centerEditorLayout(_active: boolean): void { }
S
SrTobi 已提交
560 561


562
	public resizePart(_part: Parts, _sizeChange: number): void { }
563 564

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

567
let activeViewlet: Viewlet = {} as any;
568

569
export class TestViewletService implements IViewletService {
570
	public _serviceBrand: undefined;
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 605 606 607 608 609 610 611

	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!;
	}
612 613 614 615

	public hideActiveViewlet(): void { }

	public getLastActiveViewletId(): string {
M
Matt Bierner 已提交
616
		return undefined!;
617
	}
618 619 620
}

export class TestPanelService implements IPanelService {
621
	public _serviceBrand: undefined;
622 623 624 625 626 627 628 629

	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 已提交
630 631 632 633
	public getPanel(id: string): any {
		return activeViewlet;
	}

634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
	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 已提交
655 656 657 658
	public getProgressIndicator(id: string) {
		return null!;
	}

659 660 661
	public hideActivePanel(): void { }

	public getLastActivePanelId(): string {
M
Matt Bierner 已提交
662
		return undefined!;
663 664 665
	}
}

666
export class TestStorageService extends InMemoryStorageService { }
667

668 669
export class TestEditorGroupsService implements IEditorGroupsService {

670
	_serviceBrand: undefined;
671

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

674
	onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
B
Benjamin Pasero 已提交
675
	onDidActivateGroup: Event<IEditorGroup> = Event.None;
676 677 678
	onDidAddGroup: Event<IEditorGroup> = Event.None;
	onDidRemoveGroup: Event<IEditorGroup> = Event.None;
	onDidMoveGroup: Event<IEditorGroup> = Event.None;
679
	onDidGroupIndexChange: Event<IEditorGroup> = Event.None;
680
	onDidLayout: Event<IDimension> = Event.None;
681 682

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

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

688
	get activeGroup(): IEditorGroup {
689 690 691 692 693 694 695
		return this.groups[0];
	}

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

696
	getGroups(_order?: GroupsOrder): ReadonlyArray<IEditorGroup> {
697 698 699
		return this.groups;
	}

700
	getGroup(identifier: number): IEditorGroup {
701 702 703
		for (const group of this.groups) {
			if (group.id === identifier) {
				return group;
704 705 706
			}
		}

707
		return undefined!;
708 709
	}

710
	getLabel(_identifier: number): string {
711 712 713
		return 'Group 1';
	}

714
	findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup {
715
		throw new Error('not implemented');
716 717
	}

718
	activateGroup(_group: number | IEditorGroup): IEditorGroup {
719
		throw new Error('not implemented');
720 721
	}

B
Benjamin Pasero 已提交
722 723 724 725
	restoreGroup(_group: number | IEditorGroup): IEditorGroup {
		throw new Error('not implemented');
	}

726 727
	getSize(_group: number | IEditorGroup): { width: number, height: number } {
		return { width: 100, height: 100 };
728 729
	}

730
	setSize(_group: number | IEditorGroup, _size: { width: number, height: number }): void { }
731

732
	arrangeGroups(_arrangement: GroupsArrangement): void { }
733

734
	applyLayout(_layout: EditorGroupLayout): void { }
735

736
	setGroupOrientation(_orientation: any): void { }
737

738
	addGroup(_location: number | IEditorGroup, _direction: GroupDirection, _options?: IAddGroupOptions): IEditorGroup {
739
		throw new Error('not implemented');
740 741
	}

742
	removeGroup(_group: number | IEditorGroup): void { }
743

744
	moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
745
		throw new Error('not implemented');
746 747
	}

748
	mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup {
749
		throw new Error('not implemented');
750 751
	}

752
	copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
753
		throw new Error('not implemented');
754
	}
755 756 757 758 759 760 761 762 763 764

	centerLayout(active: boolean): void { }

	isLayoutCentered(): boolean {
		return false;
	}

	partOptions: IEditorPartOptions;
	enforcePartOptions(options: IEditorPartOptions): IDisposable {
		return Disposable.None;
765 766 767
	}
}

B
Benjamin Pasero 已提交
768
export class TestEditorGroup implements IEditorGroupView {
769 770 771

	constructor(public id: number) { }

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

788 789 790
	isEmpty = true;
	isMinimized = false;

791
	onWillDispose: Event<void> = Event.None;
792
	onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
B
Benjamin Pasero 已提交
793 794
	onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
795 796
	onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
	onDidOpenEditorFail: Event<IEditorInput> = Event.None;
B
Benjamin Pasero 已提交
797 798
	onDidFocus: Event<void> = Event.None;
	onDidChange: Event<{ width: number; height: number; }> = Event.None;
799

800
	getEditors(_order?: EditorsOrder): ReadonlyArray<IEditorInput> {
B
Benjamin Pasero 已提交
801 802 803
		return [];
	}

804
	getEditor(_index: number): IEditorInput {
805
		throw new Error('not implemented');
806 807
	}

808
	getIndexOfEditor(_editor: IEditorInput): number {
809 810 811
		return -1;
	}

J
Johannes Rieken 已提交
812
	openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditor> {
813
		throw new Error('not implemented');
814 815
	}

J
Johannes Rieken 已提交
816
	openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditor> {
817
		throw new Error('not implemented');
818 819
	}

820
	isOpened(_editor: IEditorInput): boolean {
821 822 823
		return false;
	}

824
	isPinned(_editor: IEditorInput): boolean {
825 826 827
		return false;
	}

828
	isActive(_editor: IEditorInput): boolean {
829 830 831
		return false;
	}

832
	moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
833

834
	copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
835

836
	closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> {
B
Benjamin Pasero 已提交
837
		return Promise.resolve();
838 839
	}

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

J
Johannes Rieken 已提交
844
	closeAllEditors(): Promise<void> {
B
Benjamin Pasero 已提交
845
		return Promise.resolve();
846 847
	}

J
Johannes Rieken 已提交
848
	replaceEditors(_editors: IEditorReplacement[]): Promise<void> {
B
Benjamin Pasero 已提交
849
		return Promise.resolve();
850 851
	}

852
	pinEditor(_editor?: IEditorInput): void { }
853 854 855 856

	focus(): void { }

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

860
	setActive(_isActive: boolean): void { }
B
Benjamin Pasero 已提交
861
	notifyIndexChanged(_index: number): void { }
B
Benjamin Pasero 已提交
862 863
	dispose(): void { }
	toJSON(): object { return Object.create(null); }
864
	layout(_width: number, _height: number): void { }
865
	relayout() { }
866 867
}

B
Benjamin Pasero 已提交
868
export class TestEditorService implements EditorServiceImpl {
869

870
	_serviceBrand: undefined;
871 872 873

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
874
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
875 876
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;

877
	activeControl: IVisibleEditor;
878
	activeTextEditorWidget: any;
879
	activeEditor: IEditorInput;
880
	editors: ReadonlyArray<IEditorInput> = [];
M
Matt Bierner 已提交
881
	visibleControls: ReadonlyArray<IVisibleEditor> = [];
882
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
883
	visibleEditors: ReadonlyArray<IEditorInput> = [];
884

885
	overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
R
Rob Lourens 已提交
886
		return toDisposable(() => undefined);
887 888
	}

889 890
	openEditor(_editor: any, _options?: any, _group?: any): Promise<any> {
		throw new Error('not implemented');
891 892
	}

893 894
	openEditors(_editors: any, _group?: any): Promise<IEditor[]> {
		throw new Error('not implemented');
895 896
	}

897
	isOpen(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): boolean {
898 899 900
		return false;
	}

901
	getOpened(_editor: IEditorInput | IResourceInput | IUntitledResourceInput): IEditorInput {
902
		throw new Error('not implemented');
903 904
	}

905
	replaceEditors(_editors: any, _group: any) {
R
Rob Lourens 已提交
906
		return Promise.resolve(undefined);
907 908
	}

909
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
910
		throw new Error('not implemented');
911 912
	}

913
	createInput(_input: IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
914
		throw new Error('not implemented');
915 916 917
	}
}

918 919
export class TestFileService implements IFileService {

920
	public _serviceBrand: undefined;
921

M
Matt Bierner 已提交
922 923
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
924

925
	readonly onWillActivateFileSystemProvider = Event.None;
926
	readonly onError: Event<Error> = Event.None;
927

928
	private content = 'Hello Html';
929
	private lastReadFileUri: URI;
930

931 932 933 934 935
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

936 937 938 939 940 941 942 943
	public setContent(content: string): void {
		this.content = content;
	}

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

944 945 946 947
	public getLastReadFileUri(): URI {
		return this.lastReadFileUri;
	}

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

B
Benjamin Pasero 已提交
978 979
	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 已提交
980 981
	}

B
Benjamin Pasero 已提交
982
	exists(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
983
		return Promise.resolve(true);
984
	}
B
Benjamin Pasero 已提交
985

986
	readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
987 988
		this.lastReadFileUri = resource;

989
		return Promise.resolve({
B
Benjamin Pasero 已提交
990
			resource: resource,
991
			value: VSBuffer.fromString(this.content),
992
			etag: 'index.txt',
B
Benjamin Pasero 已提交
993 994
			encoding: 'utf8',
			mtime: Date.now(),
995 996
			name: resources.basename(resource),
			size: 1
E
Erich Gamma 已提交
997
		});
998
	}
E
Erich Gamma 已提交
999

1000
	readFileStream(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileStreamContent> {
1001 1002
		this.lastReadFileUri = resource;

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

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

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

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

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

1050
	createFolder(_resource: URI): Promise<IFileStatWithMetadata> {
1051
		throw new Error('not implemented');
1052 1053
	}

1054 1055
	onDidChangeFileSystemProviderRegistrations = Event.None;

1056 1057 1058 1059 1060 1061
	private providers = new Map<string, IFileSystemProvider>();

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

		return toDisposable(() => this.providers.delete(scheme));
1062 1063
	}

1064 1065
	activateProvider(_scheme: string): Promise<void> {
		throw new Error('not implemented');
1066 1067
	}

1068
	canHandleResource(resource: URI): boolean {
1069
		return resource.scheme === 'file' || this.providers.has(resource.scheme);
1070 1071
	}

1072
	hasCapability(resource: URI, capability: FileSystemProviderCapabilities): boolean { return false; }
1073

J
Johannes Rieken 已提交
1074
	del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
1075
		return Promise.resolve();
1076 1077
	}

1078 1079
	watch(_resource: URI): IDisposable {
		return Disposable.None;
1080 1081
	}

1082 1083
	getWriteEncoding(_resource: URI): IResourceEncoding {
		return { encoding: 'utf8', hasBOM: false };
1084
	}
D
Daniel Imms 已提交
1085

1086
	dispose(): void {
E
Erich Gamma 已提交
1087
	}
1088
}
1089

1090
export class TestBackupFileService implements IBackupFileService {
1091
	public _serviceBrand: undefined;
1092

J
Johannes Rieken 已提交
1093
	public hasBackups(): Promise<boolean> {
B
Benjamin Pasero 已提交
1094
		return Promise.resolve(false);
1095 1096
	}

J
Johannes Rieken 已提交
1097
	public hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
1098
		return Promise.resolve(false);
1099 1100
	}

1101 1102 1103 1104
	public hasBackupSync(resource: URI, versionId?: number): boolean {
		return false;
	}

1105
	public loadBackupResource(resource: URI): Promise<URI | undefined> {
B
Benjamin Pasero 已提交
1106 1107
		return this.hasBackup(resource).then(hasBackup => {
			if (hasBackup) {
1108
				return this.toBackupResource(resource);
B
Benjamin Pasero 已提交
1109 1110
			}

R
Rob Lourens 已提交
1111
			return undefined;
B
Benjamin Pasero 已提交
1112 1113 1114
		});
	}

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

J
Johannes Rieken 已提交
1119
	public deregisterResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1120
		return Promise.resolve();
D
Daniel Imms 已提交
1121 1122
	}

1123
	public toBackupResource(_resource: URI): URI {
1124
		throw new Error('not implemented');
D
Daniel Imms 已提交
1125
	}
1126

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

J
Johannes Rieken 已提交
1131
	public getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
1132
		return Promise.resolve([]);
1133 1134
	}

1135 1136 1137 1138 1139
	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);
1140 1141
	}

1142
	public resolveBackupContent<T extends object>(_backup: URI): Promise<IResolvedBackup<T>> {
1143
		throw new Error('not implemented');
1144 1145
	}

J
Johannes Rieken 已提交
1146
	public discardResourceBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1147
		return Promise.resolve();
1148 1149
	}

J
Johannes Rieken 已提交
1150
	public discardAllWorkspaceBackups(): Promise<void> {
B
Benjamin Pasero 已提交
1151
		return Promise.resolve();
1152
	}
1153
}
D
Daniel Imms 已提交
1154

B
Benjamin Pasero 已提交
1155
export class TestCodeEditorService implements ICodeEditorService {
1156
	_serviceBrand: undefined;
B
Benjamin Pasero 已提交
1157 1158 1159 1160 1161

	onCodeEditorAdd: Event<ICodeEditor> = Event.None;
	onCodeEditorRemove: Event<ICodeEditor> = Event.None;
	onDiffEditorAdd: Event<IDiffEditor> = Event.None;
	onDiffEditorRemove: Event<IDiffEditor> = Event.None;
A
Alex Dima 已提交
1162
	onDidChangeTransientModelProperty: Event<ITextModel> = Event.None;
B
Benjamin Pasero 已提交
1163

1164 1165
	addCodeEditor(_editor: ICodeEditor): void { }
	removeCodeEditor(_editor: ICodeEditor): void { }
B
Benjamin Pasero 已提交
1166
	listCodeEditors(): ICodeEditor[] { return []; }
1167 1168
	addDiffEditor(_editor: IDiffEditor): void { }
	removeDiffEditor(_editor: IDiffEditor): void { }
B
Benjamin Pasero 已提交
1169
	listDiffEditors(): IDiffEditor[] { return []; }
1170
	getFocusedCodeEditor(): ICodeEditor | undefined { return undefined; }
1171 1172 1173 1174 1175
	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) { }
1176
	getActiveCodeEditor(): ICodeEditor | undefined { return undefined; }
1177
	openCodeEditor(_input: IResourceInput, _source: ICodeEditor, _sideBySide?: boolean): Promise<ICodeEditor | undefined> { return Promise.resolve(undefined); }
B
Benjamin Pasero 已提交
1178 1179
}

1180 1181
export class TestWindowService implements IWindowService {

1182
	public _serviceBrand: undefined;
1183

1184
	onDidChangeFocus: Event<boolean> = new Emitter<boolean>().event;
S
SteVen Batten 已提交
1185
	onDidChangeMaximize: Event<boolean>;
1186

1187
	hasFocus = true;
1188

1189
	readonly windowId = 0;
S
SteVen Batten 已提交
1190

J
Johannes Rieken 已提交
1191
	isFocused(): Promise<boolean> {
B
Benjamin Pasero 已提交
1192
		return Promise.resolve(false);
1193 1194
	}

J
Johannes Rieken 已提交
1195
	isMaximized(): Promise<boolean> {
B
Benjamin Pasero 已提交
1196
		return Promise.resolve(false);
1197 1198
	}

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

M
Matt Bierner 已提交
1203
	enterWorkspace(_path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1204
		return Promise.resolve(undefined);
1205 1206
	}

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

1214 1215 1216 1217 1218 1219 1220 1221
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
		return Promise.resolve();
	}

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

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

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

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

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

M
Martin Aeschlimann 已提交
1238
	openWindow(_uris: IURIToOpen[], _options?: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1239
		return Promise.resolve();
1240 1241
	}

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

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

J
Johannes Rieken 已提交
1250
	updateTouchBar(_items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1251
		return Promise.resolve();
1252
	}
1253 1254
}

1255 1256
export class TestLifecycleService implements ILifecycleService {

1257
	public _serviceBrand: undefined;
1258

1259
	public phase: LifecyclePhase;
1260
	public startupKind: StartupKind;
1261

1262
	private _onBeforeShutdown = new Emitter<BeforeShutdownEvent>();
1263
	private _onWillShutdown = new Emitter<WillShutdownEvent>();
1264
	private _onShutdown = new Emitter<void>();
1265

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

1270
	public fireShutdown(reason = ShutdownReason.QUIT): void {
1271
		this._onWillShutdown.fire({
1272 1273 1274
			join: () => { },
			reason
		});
1275 1276
	}

1277 1278 1279 1280 1281 1282
	public fireWillShutdown(event: BeforeShutdownEvent): void {
		this._onBeforeShutdown.fire(event);
	}

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

1285
	public get onWillShutdown(): Event<WillShutdownEvent> {
1286 1287 1288
		return this._onWillShutdown.event;
	}

1289
	public get onShutdown(): Event<void> {
1290 1291
		return this._onShutdown.event;
	}
1292 1293
}

1294 1295
export class TestWindowsService implements IWindowsService {

1296
	_serviceBrand: undefined;
1297

1298 1299 1300 1301 1302 1303
	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;
1304

J
Johannes Rieken 已提交
1305
	isFocused(_windowId: number): Promise<boolean> {
B
Benjamin Pasero 已提交
1306
		return Promise.resolve(false);
1307 1308
	}

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

1313
	enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult | undefined> {
J
Johannes Rieken 已提交
1314
		return Promise.resolve(undefined);
1315 1316
	}

M
Martin Aeschlimann 已提交
1317
	addRecentlyOpened(_recents: IRecent[]): Promise<void> {
B
Benjamin Pasero 已提交
1318
		return Promise.resolve();
1319
	}
1320

J
Johannes Rieken 已提交
1321
	removeFromRecentlyOpened(_paths: URI[]): Promise<void> {
B
Benjamin Pasero 已提交
1322
		return Promise.resolve();
1323
	}
1324

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

J
Johannes Rieken 已提交
1329
	getRecentlyOpened(_windowId: number): Promise<IRecentlyOpened> {
1330 1331 1332 1333
		return Promise.resolve({
			workspaces: [],
			files: []
		});
1334
	}
1335

J
Johannes Rieken 已提交
1336
	focusWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1337
		return Promise.resolve();
1338
	}
1339

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

J
Johannes Rieken 已提交
1344
	isMaximized(_windowId: number): Promise<boolean> {
1345
		return Promise.resolve(false);
1346
	}
1347

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

J
Johannes Rieken 已提交
1352
	minimizeWindow(_windowId: number): Promise<void> {
B
Benjamin Pasero 已提交
1353
		return Promise.resolve();
S
SteVen Batten 已提交
1354 1355
	}

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

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

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

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

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

1376
	// Global methods
M
Martin Aeschlimann 已提交
1377
	openWindow(_windowId: number, _uris: IURIToOpen[], _options: IOpenSettings): Promise<void> {
B
Benjamin Pasero 已提交
1378
		return Promise.resolve();
1379
	}
1380

1381
	openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise<void> {
1382 1383 1384
		return Promise.resolve();
	}

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

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

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

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

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

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

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

J
Johannes Rieken 已提交
1413
	updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): Promise<void> {
B
Benjamin Pasero 已提交
1414
		return Promise.resolve();
1415 1416
	}

J
Johannes Rieken 已提交
1417
	getActiveWindowId(): Promise<number | undefined> {
B
Benjamin Pasero 已提交
1418
		return Promise.resolve(undefined);
J
Joao Moreno 已提交
1419 1420
	}

1421 1422
	// This needs to be handled from browser process to prevent
	// foreground ordering issues on Windows
J
Johannes Rieken 已提交
1423
	openExternal(_url: string): Promise<boolean> {
B
Benjamin Pasero 已提交
1424
		return Promise.resolve(true);
1425 1426 1427
	}

	// TODO: this is a bit backwards
1428
	startCrashReporter(_config: CrashReporterStartOptions): Promise<void> {
B
Benjamin Pasero 已提交
1429
		return Promise.resolve();
1430
	}
1431
}
B
Benjamin Pasero 已提交
1432

1433 1434
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

1435
	_serviceBrand: undefined;
1436 1437 1438 1439

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

1440
	public onDidChangeConfiguration() {
1441 1442 1443
		return { dispose() { } };
	}

1444
	getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
1445 1446
		const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;
		const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
1447
		return this.configurationService.getValue(section, { resource });
1448
	}
B
Benjamin Pasero 已提交
1449 1450
}

S
Sandeep Somavarapu 已提交
1451 1452
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

1453
	_serviceBrand: undefined;
S
Sandeep Somavarapu 已提交
1454 1455

	constructor(
1456
		@IConfigurationService private readonly configurationService: IConfigurationService,
S
Sandeep Somavarapu 已提交
1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471
	) {
	}

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


1472
export class TestSharedProcessService implements ISharedProcessService {
1473

1474
	_serviceBrand: undefined;
1475

1476 1477 1478
	getChannel(channelName: string): any {
		return undefined;
	}
1479

1480
	registerChannel(channelName: string, channel: any): void { }
1481 1482
}

1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509
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 已提交
1510
}
1511 1512

export const productService: IProductService = { _serviceBrand: undefined, ...product };
1513 1514 1515 1516 1517 1518

export class TestHostService implements IHostService {

	_serviceBrand: undefined;

	windowCount = Promise.resolve(1);
1519

1520
	restart(): Promise<void> { return Promise.resolve(); }
1521
	reload(): Promise<void> { return Promise.resolve(); }
1522

1523
	openEmptyWindow(options?: { reuse?: boolean, remoteAuthority?: string }): Promise<void> { return Promise.resolve(); }
1524

1525
	toggleFullScreen(): Promise<void> { return Promise.resolve(); }
1526
}