workbenchTestServices.ts 53.1 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, 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';
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';
B
Benjamin Pasero 已提交
85
import { NodeTextFileService } from 'vs/workbench/services/textfile/node/textFileService';
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';
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, OPTIONS) as IWindowConfiguration, process.execPath);
95

96
export class TestContextService implements IWorkspaceContextService {
97
	public _serviceBrand: undefined;
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);
B
Benjamin Pasero 已提交
109
		this._onDidChangeWorkspaceName = new Emitter<void>();
110
		this._onDidChangeWorkspaceFolders = new Emitter<IWorkspaceFoldersChangeEvent>();
S
Sandeep Somavarapu 已提交
111
		this._onDidChangeWorkbenchState = new Emitter<WorkbenchState>();
112 113
	}

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

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

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

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

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

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

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

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

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

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

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

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

	public updateOptions() {

	}

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

		return false;
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return instantiationService;
}

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

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

export class TestMenuService implements IMenuService {

339
	public _serviceBrand: undefined;
B
Benjamin Pasero 已提交
340

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

B
Benjamin Pasero 已提交
350 351
export class TestHistoryService implements IHistoryService {

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

	constructor(private root?: URI) {
	}

	public reopenLastClosedEditor(): void {
	}

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

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

366 367 368
	public last(): void {
	}

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

	public clear(): void {
	}

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

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

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

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

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

394
export class TestDialogService implements IDialogService {
395

396
	public _serviceBrand: undefined;
E
Erich Gamma 已提交
397

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

402 403
	public show(_severity: Severity, _message: string, _buttons: string[], _options?: IDialogOptions): Promise<IShowResult> {
		return Promise.resolve({ choice: 0 });
404
	}
E
Erich Gamma 已提交
405 406
}

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

409
	public _serviceBrand: undefined;
M
Martin Aeschlimann 已提交
410

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

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

445
	public _serviceBrand: undefined;
E
Erich Gamma 已提交
446

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

545 546
	public getMaximumEditorDimensions(): Dimension { throw new Error('not implemented'); }

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

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

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


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

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

561
let activeViewlet: Viewlet = {} as any;
562

563
export class TestViewletService implements IViewletService {
564
	public _serviceBrand: undefined;
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 605

	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!;
	}
606 607 608 609

	public hideActiveViewlet(): void { }

	public getLastActiveViewletId(): string {
M
Matt Bierner 已提交
610
		return undefined!;
611
	}
612 613 614
}

export class TestPanelService implements IPanelService {
615
	public _serviceBrand: undefined;
616 617 618 619 620 621 622 623

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

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

653 654 655
	public hideActivePanel(): void { }

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

660
export class TestStorageService extends InMemoryStorageService { }
661

662 663
export class TestEditorGroupsService implements IEditorGroupsService {

664
	_serviceBrand: undefined;
665

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

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

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

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

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

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

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

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

701
		return undefined!;
702 703
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	centerLayout(active: boolean): void { }

	isLayoutCentered(): boolean {
		return false;
	}

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

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

	constructor(public id: number) { }

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

782 783 784
	isEmpty = true;
	isMinimized = false;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	focus(): void { }

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

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

B
Benjamin Pasero 已提交
862
export class TestEditorService implements EditorServiceImpl {
863

864
	_serviceBrand: undefined;
865 866 867

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

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

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

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

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

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

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

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

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

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

912 913
export class TestFileService implements IFileService {

914
	public _serviceBrand: undefined;
915

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1048 1049
	onDidChangeFileSystemProviderRegistrations = Event.None;

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

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

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

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

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

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

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

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

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

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

1084
export class TestBackupFileService implements IBackupFileService {
1085
	public _serviceBrand: undefined;
1086

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

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

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

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

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

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

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

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

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

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

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

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

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

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

B
Benjamin Pasero 已提交
1149
export class TestCodeEditorService implements ICodeEditorService {
1150
	_serviceBrand: undefined;
B
Benjamin Pasero 已提交
1151 1152 1153 1154 1155

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

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

1174 1175
export class TestWindowService implements IWindowService {

1176
	public _serviceBrand: undefined;
1177

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

1181
	hasFocus = true;
1182

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1305 1306
export class TestLifecycleService implements ILifecycleService {

1307
	public _serviceBrand: undefined;
1308

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

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

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

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

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

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

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

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

1344 1345
export class TestWindowsService implements IWindowsService {

1346
	_serviceBrand: undefined;
1347

1348 1349
	public windowCount = 1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1565 1566
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {

1567
	_serviceBrand: undefined;
1568 1569 1570 1571

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

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

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

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

1585
	_serviceBrand: undefined;
S
Sandeep Somavarapu 已提交
1586 1587

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

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


1604
export class TestSharedProcessService implements ISharedProcessService {
1605

1606
	_serviceBrand: undefined;
1607

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

1612
	registerChannel(channelName: string, channel: any): void { }
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 1641
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 已提交
1642
}
1643 1644

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