workbenchTestServices.ts 56.0 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

6
import 'vs/workbench/contrib/files/browser/files.contribution'; // load our contribution into the test
7
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
8
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
9
import { join } from 'vs/base/common/path';
10
import * as resources from 'vs/base/common/resources';
11
import { URI } from 'vs/base/common/uri';
12 13
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
B
Benjamin Pasero 已提交
14
import { IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledTextResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent, IEditorPartOptions, IRevertOptions, GroupIdentifier, EditorInput, EditorOptions, EditorsOrder } from 'vs/workbench/common/editor';
15
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, IEditorGroupsAccessor } 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, ConfigurationTarget } 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';
24
import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
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, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
37
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
38
import { MenuBarVisibility, IWindowConfiguration, IWindowOpenable, IOpenWindowOptions, IOpenEmptyWindowOptions, IOpenedWindow } 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 } 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';
S
rename  
Sandeep Somavarapu 已提交
45
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
46
import { IPosition, Position as EditorPosition } from 'vs/editor/common/core/position';
47
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
I
isidor 已提交
48
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
B
Benjamin Pasero 已提交
49
import { MockContextKeyService, MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
50
import { ITextBufferFactory, DefaultEndOfLine, EndOfLinePreference, IModelDecorationOptions, ITextModel, ITextSnapshot } from 'vs/editor/common/model';
51
import { Range } from 'vs/editor/common/core/range';
52
import { IConfirmation, IConfirmationResult, IDialogService, IDialogOptions, IPickAndOpenOptions, ISaveDialogOptions, IOpenDialogOptions, IFileDialogService, IShowResult, ConfirmResult } from 'vs/platform/dialogs/common/dialogs';
53 54
import { INotificationService } from 'vs/platform/notification/common/notification';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
55
import { IExtensionService, NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
B
Benjamin Pasero 已提交
56
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
B
Benjamin Pasero 已提交
57
import { IDecorationsService, IResourceDecorationChangeEvent, IDecoration, IDecorationData, IDecorationsProvider } from 'vs/workbench/services/decorations/browser/decorations';
J
Joao Moreno 已提交
58
import { IDisposable, toDisposable, Disposable } from 'vs/base/common/lifecycle';
B
Benjamin Pasero 已提交
59
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, IFindGroupScope, EditorGroupLayout, ICloseEditorOptions } from 'vs/workbench/services/editor/common/editorGroupsService';
60
import { IEditorService, IOpenEditorOverrideHandler, IVisibleEditor, ISaveEditorsOptions, IRevertAllEditorsOptions, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
B
Benjamin Pasero 已提交
61 62 63
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 已提交
64
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
65
import { Dimension } from 'vs/base/browser/dom';
S
Sandeep Somavarapu 已提交
66
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
I
isidor 已提交
67
import { ILabelService } from 'vs/platform/label/common/label';
68
import { timeout } from 'vs/base/common/async';
69
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
70
import { ViewletDescriptor, Viewlet } from 'vs/workbench/browser/viewlet';
71
import { IViewlet } from 'vs/workbench/common/viewlet';
72
import { IStorageService, InMemoryStorageService, IWillSaveStateEvent } from 'vs/platform/storage/common/storage';
A
Andre Weinand 已提交
73
import { isLinux, isMacintosh } from 'vs/base/common/platform';
I
isidor 已提交
74
import { LabelService } from 'vs/workbench/services/label/common/labelService';
B
Benjamin Pasero 已提交
75
import { IDimension } from 'vs/platform/layout/browser/layoutService';
76
import { Part } from 'vs/workbench/browser/part';
77 78 79
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';
80
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
81
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
82
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
83
import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
84
import { NativeTextFileService } from 'vs/workbench/services/textfile/electron-browser/nativeTextFileService';
85
import { Schemas } from 'vs/base/common/network';
86
import { IProductService } from 'vs/platform/product/common/productService';
87
import product from 'vs/platform/product/common/product';
88
import { IHostService } from 'vs/workbench/services/host/browser/host';
89
import { IElectronService } from 'vs/platform/electron/node/electron';
90
import { INativeOpenDialogOptions } from 'vs/platform/dialogs/node/dialogs';
91 92 93
import { IBackupMainService, IWorkspaceBackupInfo } from 'vs/platform/backup/electron-main/backup';
import { IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup';
import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogs';
94
import { find } from 'vs/base/common/arrays';
95
import { WorkingCopyService, IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
96
import { IFilesConfigurationService, FilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
97
import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
B
Benjamin Pasero 已提交
98

S
Sandeep Somavarapu 已提交
99
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
100
	return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined);
S
Sandeep Somavarapu 已提交
101 102
}

103
export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(parseArgs(process.argv, OPTIONS) as IWindowConfiguration, process.execPath, 0);
104

105
export class TestContextService implements IWorkspaceContextService {
B
Benjamin Pasero 已提交
106
	_serviceBrand: undefined;
E
Erich Gamma 已提交
107

S
Sandeep Somavarapu 已提交
108
	private workspace: Workspace;
E
Erich Gamma 已提交
109 110
	private options: any;

M
Matt Bierner 已提交
111 112 113
	private readonly _onDidChangeWorkspaceName: Emitter<void>;
	private readonly _onDidChangeWorkspaceFolders: Emitter<IWorkspaceFoldersChangeEvent>;
	private readonly _onDidChangeWorkbenchState: Emitter<WorkbenchState>;
114

115
	constructor(workspace: any = TestWorkspace, options: any = null) {
E
Erich Gamma 已提交
116
		this.workspace = workspace;
117
		this.options = options || Object.create(null);
B
Benjamin Pasero 已提交
118
		this._onDidChangeWorkspaceName = new Emitter<void>();
119
		this._onDidChangeWorkspaceFolders = new Emitter<IWorkspaceFoldersChangeEvent>();
S
Sandeep Somavarapu 已提交
120
		this._onDidChangeWorkbenchState = new Emitter<WorkbenchState>();
121 122
	}

B
Benjamin Pasero 已提交
123
	get onDidChangeWorkspaceName(): Event<void> {
S
Sandeep Somavarapu 已提交
124 125 126
		return this._onDidChangeWorkspaceName.event;
	}

B
Benjamin Pasero 已提交
127
	get onDidChangeWorkspaceFolders(): Event<IWorkspaceFoldersChangeEvent> {
S
Sandeep Somavarapu 已提交
128
		return this._onDidChangeWorkspaceFolders.event;
129 130
	}

B
Benjamin Pasero 已提交
131
	get onDidChangeWorkbenchState(): Event<WorkbenchState> {
132 133 134
		return this._onDidChangeWorkbenchState.event;
	}

B
Benjamin Pasero 已提交
135
	getFolders(): IWorkspaceFolder[] {
S
Sandeep Somavarapu 已提交
136
		return this.workspace ? this.workspace.folders : [];
E
Erich Gamma 已提交
137 138
	}

B
Benjamin Pasero 已提交
139
	getWorkbenchState(): WorkbenchState {
B
Benjamin Pasero 已提交
140 141 142 143 144
		if (this.workspace.configuration) {
			return WorkbenchState.WORKSPACE;
		}

		if (this.workspace.folders.length) {
145
			return WorkbenchState.FOLDER;
146
		}
B
Benjamin Pasero 已提交
147

148
		return WorkbenchState.EMPTY;
S
Sandeep Somavarapu 已提交
149 150
	}

151 152 153 154
	getCompleteWorkspace(): Promise<IWorkbenchWorkspace> {
		return Promise.resolve(this.getWorkspace());
	}

B
Benjamin Pasero 已提交
155
	getWorkspace(): IWorkbenchWorkspace {
B
Benjamin Pasero 已提交
156
		return this.workspace;
157 158
	}

B
Benjamin Pasero 已提交
159
	getWorkspaceFolder(resource: URI): IWorkspaceFolder | null {
S
Sandeep Somavarapu 已提交
160
		return this.workspace.getFolder(resource);
161 162
	}

B
Benjamin Pasero 已提交
163
	setWorkspace(workspace: any): void {
D
Daniel Imms 已提交
164 165 166
		this.workspace = workspace;
	}

B
Benjamin Pasero 已提交
167
	getOptions() {
E
Erich Gamma 已提交
168 169 170
		return this.options;
	}

B
Benjamin Pasero 已提交
171
	updateOptions() {
E
Erich Gamma 已提交
172 173 174

	}

B
Benjamin Pasero 已提交
175
	isInsideWorkspace(resource: URI): boolean {
E
Erich Gamma 已提交
176
		if (resource && this.workspace) {
177
			return resources.isEqualOrParent(resource, this.workspace.folders[0].uri);
E
Erich Gamma 已提交
178 179 180 181 182
		}

		return false;
	}

B
Benjamin Pasero 已提交
183
	toResource(workspaceRelativePath: string): URI {
184
		return URI.file(join('C:\\', workspaceRelativePath));
E
Erich Gamma 已提交
185
	}
186

B
Benjamin Pasero 已提交
187
	isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean {
188
		return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && resources.isEqual(this.workspace.folders[0].uri, workspaceIdentifier);
189
	}
E
Erich Gamma 已提交
190 191
}

192
export class TestTextFileService extends NativeTextFileService {
193 194
	private promptPath!: URI;
	private resolveTextContentError!: FileOperationError | null;
A
Alex Dima 已提交
195 196

	constructor(
197
		@IFileService protected fileService: IFileService,
198
		@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService,
199
		@ILifecycleService lifecycleService: ILifecycleService,
200
		@IInstantiationService instantiationService: IInstantiationService,
201
		@IModelService modelService: IModelService,
202
		@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
I
isidor 已提交
203
		@IHistoryService historyService: IHistoryService,
204 205
		@IDialogService dialogService: IDialogService,
		@IFileDialogService fileDialogService: IFileDialogService,
B
Benjamin Pasero 已提交
206
		@IEditorService editorService: IEditorService,
S
rename  
Sandeep Somavarapu 已提交
207
		@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,
208
		@IProductService productService: IProductService,
209
		@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService,
210 211
		@ITextModelService textModelService: ITextModelService,
		@ICodeEditorService codeEditorService: ICodeEditorService
A
Alex Dima 已提交
212
	) {
213 214
		super(
			fileService,
215
			untitledTextEditorService,
216 217 218 219 220 221 222
			lifecycleService,
			instantiationService,
			modelService,
			environmentService,
			historyService,
			dialogService,
			fileDialogService,
B
Benjamin Pasero 已提交
223
			editorService,
224
			textResourceConfigurationService,
225
			productService,
226
			filesConfigurationService,
227 228
			textModelService,
			codeEditorService
229
		);
A
Alex Dima 已提交
230
	}
231

B
Benjamin Pasero 已提交
232
	setPromptPath(path: URI): void {
233 234 235
		this.promptPath = path;
	}

B
Benjamin Pasero 已提交
236
	setResolveTextContentErrorOnce(error: FileOperationError): void {
237 238 239
		this.resolveTextContentError = error;
	}

B
Benjamin Pasero 已提交
240
	async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {
241 242 243 244
		if (this.resolveTextContentError) {
			const error = this.resolveTextContentError;
			this.resolveTextContentError = null;

B
Benjamin Pasero 已提交
245
			throw error;
246 247
		}

B
Benjamin Pasero 已提交
248 249 250 251 252 253 254 255 256 257 258
		const content = await this.fileService.readFileStream(resource, options);
		return {
			resource: content.resource,
			name: content.name,
			mtime: content.mtime,
			ctime: content.ctime,
			etag: content.etag,
			encoding: 'utf8',
			value: await createTextBufferFactoryFromStream(content.value),
			size: 10
		};
259
	}
260

B
Benjamin Pasero 已提交
261
	promptForPath(_resource: URI, _defaultPath: URI): Promise<URI> {
B
Benjamin Pasero 已提交
262
		return Promise.resolve(this.promptPath);
263
	}
A
Alex Dima 已提交
264 265
}

266 267 268 269 270
export interface ITestInstantiationService extends IInstantiationService {
	stub<T>(service: ServiceIdentifier<T>, ctor: any): T;
}

export function workbenchInstantiationService(): ITestInstantiationService {
271
	let instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
272
	instantiationService.stub(IEnvironmentService, TestEnvironmentService);
273 274
	const contextKeyService = <IContextKeyService>instantiationService.createInstance(MockContextKeyService);
	instantiationService.stub(IContextKeyService, contextKeyService);
I
isidor 已提交
275 276
	const workspaceContextService = new TestContextService(TestWorkspace);
	instantiationService.stub(IWorkspaceContextService, workspaceContextService);
277 278
	const configService = new TestConfigurationService();
	instantiationService.stub(IConfigurationService, configService);
279
	instantiationService.stub(IFilesConfigurationService, new TestFilesConfigurationService(contextKeyService, configService, TestEnvironmentService));
S
rename  
Sandeep Somavarapu 已提交
280
	instantiationService.stub(ITextResourceConfigurationService, new TestTextResourceConfigurationService(configService));
281
	instantiationService.stub(IUntitledTextEditorService, instantiationService.createInstance(UntitledTextEditorService));
282
	instantiationService.stub(IStorageService, new TestStorageService());
283
	instantiationService.stub(IWorkbenchLayoutService, new TestLayoutService());
284
	instantiationService.stub(IDialogService, new TestDialogService());
285
	instantiationService.stub(IAccessibilityService, new TestAccessibilityService());
286
	instantiationService.stub(IFileDialogService, new TestFileDialogService());
287
	instantiationService.stub(IElectronService, new TestElectronService());
J
Johannes Rieken 已提交
288
	instantiationService.stub(IModeService, instantiationService.createInstance(ModeServiceImpl));
B
Benjamin Pasero 已提交
289
	instantiationService.stub(IHistoryService, new TestHistoryService());
S
Sandeep Somavarapu 已提交
290
	instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(configService));
S
Sandeep Somavarapu 已提交
291
	instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl));
292
	instantiationService.stub(IFileService, new TestFileService());
293
	instantiationService.stub(IBackupFileService, new TestBackupFileService());
294
	instantiationService.stub(ITelemetryService, NullTelemetryService);
295
	instantiationService.stub(INotificationService, new TestNotificationService());
296
	instantiationService.stub(IUntitledTextEditorService, instantiationService.createInstance(UntitledTextEditorService));
B
Benjamin Pasero 已提交
297 298 299 300
	instantiationService.stub(IMenuService, new TestMenuService());
	instantiationService.stub(IKeybindingService, new MockKeybindingService());
	instantiationService.stub(IDecorationsService, new TestDecorationsService());
	instantiationService.stub(IExtensionService, new TestExtensionService());
301
	instantiationService.stub(IHostService, <IHostService>instantiationService.createInstance(TestHostService));
302
	instantiationService.stub(ITextFileService, <ITextFileService>instantiationService.createInstance(TestTextFileService));
303
	instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
B
Benjamin Pasero 已提交
304
	instantiationService.stub(IThemeService, new TestThemeService());
S
Sandeep Somavarapu 已提交
305
	instantiationService.stub(ILogService, new NullLogService());
306 307
	const editorGroupService = new TestEditorGroupsService([new TestEditorGroupView(0)]);
	instantiationService.stub(IEditorGroupsService, editorGroupService);
M
Martin Aeschlimann 已提交
308
	instantiationService.stub(ILabelService, <ILabelService>instantiationService.createInstance(LabelService));
309
	const editorService = new TestEditorService(editorGroupService);
310
	instantiationService.stub(IEditorService, editorService);
B
Benjamin Pasero 已提交
311
	instantiationService.stub(ICodeEditorService, new TestCodeEditorService());
312
	instantiationService.stub(IViewletService, new TestViewletService());
313
	instantiationService.stub(IWorkingCopyService, new TestWorkingCopyService());
314 315 316 317

	return instantiationService;
}

318 319 320 321 322 323 324 325 326 327 328
export class TestAccessibilityService implements IAccessibilityService {

	_serviceBrand: undefined;

	onDidChangeAccessibilitySupport = Event.None;

	alwaysUnderlineAccessKeys(): Promise<boolean> { return Promise.resolve(false); }
	getAccessibilitySupport(): AccessibilitySupport { return AccessibilitySupport.Unknown; }
	setAccessibilitySupport(accessibilitySupport: AccessibilitySupport): void { }
}

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

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

export class TestMenuService implements IMenuService {

B
Benjamin Pasero 已提交
340
	_serviceBrand: undefined;
B
Benjamin Pasero 已提交
341

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

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

353
	_serviceBrand: undefined;
B
Benjamin Pasero 已提交
354

355 356 357 358 359 360 361 362 363
	constructor(private root?: URI) { }

	reopenLastClosedEditor(): void { }
	forward(): void { }
	back(): void { }
	last(): void { }
	remove(_input: IEditorInput | IResourceInput): void { }
	clear(): void { }
	clearRecentlyOpened(): void { }
364
	getHistory(): ReadonlyArray<IEditorInput | IResourceInput> { return []; }
365 366 367 368 369
	openNextRecentlyUsedEditor(group?: GroupIdentifier): void { }
	openPreviouslyUsedEditor(group?: GroupIdentifier): void { }
	getLastActiveWorkspaceRoot(_schemeFilter: string): URI | undefined { return this.root; }
	getLastActiveFile(_schemeFilter: string): URI | undefined { return undefined; }
	openLastEditLocation(): void { }
B
Benjamin Pasero 已提交
370 371
}

372
export class TestDialogService implements IDialogService {
373

B
Benjamin Pasero 已提交
374
	_serviceBrand: undefined;
E
Erich Gamma 已提交
375

B
Benjamin Pasero 已提交
376
	confirm(_confirmation: IConfirmation): Promise<IConfirmationResult> {
B
Benjamin Pasero 已提交
377
		return Promise.resolve({ confirmed: false });
378
	}
379

B
Benjamin Pasero 已提交
380
	show(_severity: Severity, _message: string, _buttons: string[], _options?: IDialogOptions): Promise<IShowResult> {
381
		return Promise.resolve({ choice: 0 });
382
	}
383

B
Benjamin Pasero 已提交
384
	about(): Promise<void> {
385 386
		return Promise.resolve();
	}
E
Erich Gamma 已提交
387 388
}

M
Martin Aeschlimann 已提交
389 390
export class TestFileDialogService implements IFileDialogService {

B
Benjamin Pasero 已提交
391
	_serviceBrand: undefined;
M
Martin Aeschlimann 已提交
392

393 394
	private confirmResult!: ConfirmResult;

B
Benjamin Pasero 已提交
395
	defaultFilePath(_schemeFilter?: string): URI | undefined {
R
Rob Lourens 已提交
396
		return undefined;
M
Martin Aeschlimann 已提交
397
	}
B
Benjamin Pasero 已提交
398
	defaultFolderPath(_schemeFilter?: string): URI | undefined {
R
Rob Lourens 已提交
399
		return undefined;
M
Martin Aeschlimann 已提交
400
	}
B
Benjamin Pasero 已提交
401
	defaultWorkspacePath(_schemeFilter?: string): URI | undefined {
R
Rob Lourens 已提交
402
		return undefined;
M
Martin Aeschlimann 已提交
403
	}
B
Benjamin Pasero 已提交
404
	pickFileFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
405
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
406
	}
B
Benjamin Pasero 已提交
407
	pickFileAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
408
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
409
	}
B
Benjamin Pasero 已提交
410
	pickFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
411
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
412
	}
B
Benjamin Pasero 已提交
413
	pickWorkspaceAndOpen(_options: IPickAndOpenOptions): Promise<any> {
B
Benjamin Pasero 已提交
414
		return Promise.resolve(0);
M
Martin Aeschlimann 已提交
415
	}
416
	pickFileToSave(defaultUri: URI, availableFileSystems?: string[]): Promise<URI | undefined> {
417 418
		return Promise.resolve(undefined);
	}
B
Benjamin Pasero 已提交
419
	showSaveDialog(_options: ISaveDialogOptions): Promise<URI | undefined> {
J
Johannes Rieken 已提交
420
		return Promise.resolve(undefined);
M
Martin Aeschlimann 已提交
421
	}
B
Benjamin Pasero 已提交
422
	showOpenDialog(_options: IOpenDialogOptions): Promise<URI[] | undefined> {
J
Johannes Rieken 已提交
423
		return Promise.resolve(undefined);
M
Martin Aeschlimann 已提交
424
	}
B
Benjamin Pasero 已提交
425
	setConfirmResult(result: ConfirmResult): void {
426 427
		this.confirmResult = result;
	}
B
Benjamin Pasero 已提交
428
	showSaveConfirm(fileNamesOrResources: (string | URI)[]): Promise<ConfirmResult> {
429 430
		return Promise.resolve(this.confirmResult);
	}
M
Martin Aeschlimann 已提交
431 432
}

433
export class TestLayoutService implements IWorkbenchLayoutService {
B
Benjamin Pasero 已提交
434

B
Benjamin Pasero 已提交
435
	_serviceBrand: undefined;
E
Erich Gamma 已提交
436

437 438
	dimension: IDimension = { width: 800, height: 600 };

439 440
	container: HTMLElement = window.document.body;

B
Benjamin Pasero 已提交
441
	onZenModeChange: Event<boolean> = Event.None;
S
SteVen Batten 已提交
442 443
	onCenteredLayoutChange: Event<boolean> = Event.None;
	onFullscreenChange: Event<boolean> = Event.None;
444
	onMaximizeChange: Event<boolean> = Event.None;
445
	onPanelPositionChange: Event<string> = Event.None;
446
	onPartVisibilityChange: Event<void> = Event.None;
447
	onLayout = Event.None;
B
Benjamin Pasero 已提交
448

449
	private readonly _onMenubarVisibilityChange = new Emitter<Dimension>();
450

B
Benjamin Pasero 已提交
451
	get onMenubarVisibilityChange(): Event<Dimension> {
452 453 454
		return this._onMenubarVisibilityChange.event;
	}

B
Benjamin Pasero 已提交
455
	isRestored(): boolean {
E
Erich Gamma 已提交
456 457 458
		return true;
	}

B
Benjamin Pasero 已提交
459
	hasFocus(_part: Parts): boolean {
E
Erich Gamma 已提交
460 461 462
		return false;
	}

B
Benjamin Pasero 已提交
463
	hasWindowBorder(): boolean {
E
Eric Amodio 已提交
464 465 466
		return false;
	}

B
Benjamin Pasero 已提交
467
	getWindowBorderRadius(): string | undefined {
E
Eric Amodio 已提交
468 469 470
		return undefined;
	}

B
Benjamin Pasero 已提交
471
	isVisible(_part: Parts): boolean {
E
Erich Gamma 已提交
472 473 474
		return true;
	}

475 476 477 478
	getDimension(_part: Parts): Dimension {
		return new Dimension(0, 0);
	}

B
Benjamin Pasero 已提交
479
	getContainer(_part: Parts): HTMLElement {
B
Benjamin Pasero 已提交
480
		return null!;
481 482
	}

B
Benjamin Pasero 已提交
483
	isTitleBarHidden(): boolean {
B
Benjamin Pasero 已提交
484 485 486
		return false;
	}

B
Benjamin Pasero 已提交
487
	getTitleBarOffset(): number {
488 489 490
		return 0;
	}

B
Benjamin Pasero 已提交
491
	isStatusBarHidden(): boolean {
492 493 494
		return false;
	}

B
Benjamin Pasero 已提交
495
	isActivityBarHidden(): boolean {
S
Sanders Lauture 已提交
496 497 498
		return false;
	}

B
Benjamin Pasero 已提交
499
	setActivityBarHidden(_hidden: boolean): void { }
S
Sanders Lauture 已提交
500

B
Benjamin Pasero 已提交
501
	isSideBarHidden(): boolean {
E
Erich Gamma 已提交
502 503 504
		return false;
	}

B
Benjamin Pasero 已提交
505
	setEditorHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
S
SteVen Batten 已提交
506

B
Benjamin Pasero 已提交
507
	setSideBarHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
E
Erich Gamma 已提交
508

B
Benjamin Pasero 已提交
509
	isPanelHidden(): boolean {
I
isidor 已提交
510 511 512
		return false;
	}

B
Benjamin Pasero 已提交
513
	setPanelHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
I
isidor 已提交
514

B
Benjamin Pasero 已提交
515
	toggleMaximizedPanel(): void { }
I
isidor 已提交
516

B
Benjamin Pasero 已提交
517
	isPanelMaximized(): boolean {
B
Benjamin Pasero 已提交
518 519 520
		return false;
	}

B
Benjamin Pasero 已提交
521
	getMenubarVisibility(): MenuBarVisibility {
522
		throw new Error('not implemented');
S
SteVen Batten 已提交
523 524
	}

B
Benjamin Pasero 已提交
525
	getSideBarPosition() {
E
Erich Gamma 已提交
526 527 528
		return 0;
	}

B
Benjamin Pasero 已提交
529
	getPanelPosition() {
I
isidor 已提交
530 531 532
		return 0;
	}

B
Benjamin Pasero 已提交
533
	setPanelPosition(_position: PartPosition): Promise<void> {
534
		return Promise.resolve();
I
isidor 已提交
535 536
	}

B
Benjamin Pasero 已提交
537 538
	addClass(_clazz: string): void { }
	removeClass(_clazz: string): void { }
539

B
Benjamin Pasero 已提交
540
	getMaximumEditorDimensions(): Dimension { throw new Error('not implemented'); }
541

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

B
Benjamin Pasero 已提交
545
	toggleZenMode(): void { }
546

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


B
Benjamin Pasero 已提交
551
	resizePart(_part: Parts, _sizeChange: number): void { }
552

B
Benjamin Pasero 已提交
553
	registerPart(part: Part): void { }
554 555 556 557 558

	isWindowMaximized() {
		return false;
	}

B
Benjamin Pasero 已提交
559
	updateWindowMaximizedState(maximized: boolean): void { }
E
Erich Gamma 已提交
560 561
}

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

564
export class TestViewletService implements IViewletService {
B
Benjamin Pasero 已提交
565
	_serviceBrand: undefined;
566 567 568 569 570 571 572 573 574 575 576

	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;

B
Benjamin Pasero 已提交
577
	openViewlet(id: string, focus?: boolean): Promise<IViewlet | undefined> {
B
Benjamin Pasero 已提交
578
		return Promise.resolve(undefined);
579 580
	}

B
Benjamin Pasero 已提交
581
	getViewlets(): ViewletDescriptor[] {
582 583 584
		return [];
	}

B
Benjamin Pasero 已提交
585
	getAllViewlets(): ViewletDescriptor[] {
586 587 588
		return [];
	}

B
Benjamin Pasero 已提交
589
	getActiveViewlet(): IViewlet {
590 591 592
		return activeViewlet;
	}

B
Benjamin Pasero 已提交
593
	dispose() {
594 595
	}

B
Benjamin Pasero 已提交
596
	getDefaultViewletId(): string {
597 598 599
		return 'workbench.view.explorer';
	}

B
Benjamin Pasero 已提交
600
	getViewlet(id: string): ViewletDescriptor | undefined {
601 602 603
		return undefined;
	}

B
Benjamin Pasero 已提交
604
	getProgressIndicator(id: string) {
B
Benjamin Pasero 已提交
605
		return undefined;
606
	}
607

B
Benjamin Pasero 已提交
608
	hideActiveViewlet(): void { }
609

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

export class TestPanelService implements IPanelService {
B
Benjamin Pasero 已提交
616
	_serviceBrand: undefined;
617 618 619 620

	onDidPanelOpen = new Emitter<{ panel: IPanel, focus: boolean }>().event;
	onDidPanelClose = new Emitter<IPanel>().event;

B
Benjamin Pasero 已提交
621
	openPanel(id: string, focus?: boolean): undefined {
622
		return undefined;
623 624
	}

B
Benjamin Pasero 已提交
625
	getPanel(id: string): any {
B
Benjamin Pasero 已提交
626 627 628
		return activeViewlet;
	}

B
Benjamin Pasero 已提交
629
	getPanels() {
630 631 632
		return [];
	}

B
Benjamin Pasero 已提交
633
	getPinnedPanels() {
634 635 636
		return [];
	}

B
Benjamin Pasero 已提交
637
	getActivePanel(): IViewlet {
638 639 640
		return activeViewlet;
	}

B
Benjamin Pasero 已提交
641
	setPanelEnablement(id: string, enabled: boolean): void { }
642

B
Benjamin Pasero 已提交
643
	dispose() {
644 645
	}

B
Benjamin Pasero 已提交
646
	showActivity(panelId: string, badge: IBadge, clazz?: string): IDisposable {
647 648 649
		throw new Error('Method not implemented.');
	}

B
Benjamin Pasero 已提交
650
	getProgressIndicator(id: string) {
B
Benjamin Pasero 已提交
651 652 653
		return null!;
	}

B
Benjamin Pasero 已提交
654
	hideActivePanel(): void { }
655

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

661
export class TestStorageService extends InMemoryStorageService {
B
Benjamin Pasero 已提交
662 663
	readonly _onWillSaveState = this._register(new Emitter<IWillSaveStateEvent>());
	readonly onWillSaveState = this._onWillSaveState.event;
664
}
665

666 667
export class TestEditorGroupsService implements IEditorGroupsService {

668
	_serviceBrand: undefined;
669

670
	constructor(public groups: TestEditorGroupView[] = []) { }
671

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

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

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

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

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

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

699 700
	getGroup(identifier: number): IEditorGroup | undefined {
		return find(this.groups, group => group.id === identifier);
701 702
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	centerLayout(active: boolean): void { }

	isLayoutCentered(): boolean {
		return false;
	}

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

761
export class TestEditorGroupView implements IEditorGroupView {
762 763 764

	constructor(public id: number) { }

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

781 782 783
	isEmpty = true;
	isMinimized = false;

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

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

B
Benjamin Pasero 已提交
797
	getEditorByIndex(_index: number): IEditorInput {
798
		throw new Error('not implemented');
799 800
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

	focus(): void { }

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

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

861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882
export class TestEditorGroupAccessor implements IEditorGroupsAccessor {

	groups: IEditorGroupView[] = [];
	activeGroup!: IEditorGroupView;

	partOptions: IEditorPartOptions = {};

	onDidEditorPartOptionsChange = Event.None;
	onDidVisibilityChange = Event.None;

	getGroup(identifier: number): IEditorGroupView | undefined { throw new Error('Method not implemented.'); }
	getGroups(order: GroupsOrder): IEditorGroupView[] { throw new Error('Method not implemented.'); }
	activateGroup(identifier: number | IEditorGroupView): IEditorGroupView { throw new Error('Method not implemented.'); }
	restoreGroup(identifier: number | IEditorGroupView): IEditorGroupView { throw new Error('Method not implemented.'); }
	addGroup(location: number | IEditorGroupView, direction: GroupDirection, options?: IAddGroupOptions | undefined): IEditorGroupView { throw new Error('Method not implemented.'); }
	mergeGroup(group: number | IEditorGroupView, target: number | IEditorGroupView, options?: IMergeGroupOptions | undefined): IEditorGroupView { throw new Error('Method not implemented.'); }
	moveGroup(group: number | IEditorGroupView, location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }
	copyGroup(group: number | IEditorGroupView, location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }
	removeGroup(group: number | IEditorGroupView): void { throw new Error('Method not implemented.'); }
	arrangeGroups(arrangement: GroupsArrangement, target?: number | IEditorGroupView | undefined): void { throw new Error('Method not implemented.'); }
}

B
Benjamin Pasero 已提交
883
export class TestEditorService implements EditorServiceImpl {
884

885
	_serviceBrand: undefined;
886 887 888

	onDidActiveEditorChange: Event<void> = Event.None;
	onDidVisibleEditorsChange: Event<void> = Event.None;
B
Benjamin Pasero 已提交
889
	onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
890
	onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;
891
	onDidMostRecentlyActiveEditorsChange: Event<void> = Event.None;
892

893
	activeControl!: IVisibleEditor;
894
	activeTextEditorWidget: any;
895
	activeTextEditorMode: any;
896
	activeEditor!: IEditorInput;
897
	editors: ReadonlyArray<IEditorInput> = [];
898
	mostRecentlyActiveEditors: ReadonlyArray<IEditorIdentifier> = [];
M
Matt Bierner 已提交
899
	visibleControls: ReadonlyArray<IVisibleEditor> = [];
900
	visibleTextEditorWidgets = [];
B
Benjamin Pasero 已提交
901
	visibleEditors: ReadonlyArray<IEditorInput> = [];
B
Benjamin Pasero 已提交
902
	count = this.editors.length;
903

B
Benjamin Pasero 已提交
904
	constructor(private editorGroupService?: IEditorGroupsService) { }
905

B
Benjamin Pasero 已提交
906 907
	getEditors() { return []; }

908
	overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
R
Rob Lourens 已提交
909
		return toDisposable(() => undefined);
910 911
	}

912 913
	openEditor(_editor: any, _options?: any, _group?: any): Promise<any> {
		throw new Error('not implemented');
914 915
	}

916
	doResolveEditorOpenRequest(editor: IEditorInput | IResourceEditor): [IEditorGroup, EditorInput, EditorOptions | undefined] | undefined {
B
Benjamin Pasero 已提交
917 918 919 920
		if (!this.editorGroupService) {
			return undefined;
		}

921 922 923
		return [this.editorGroupService.activeGroup, editor as EditorInput, undefined];
	}

924 925
	openEditors(_editors: any, _group?: any): Promise<IEditor[]> {
		throw new Error('not implemented');
926 927
	}

928
	isOpen(_editor: IEditorInput | IResourceInput | IUntitledTextResourceInput): boolean {
929 930 931
		return false;
	}

932
	getOpened(_editor: IEditorInput | IResourceInput | IUntitledTextResourceInput): IEditorInput {
933
		throw new Error('not implemented');
934 935
	}

936
	replaceEditors(_editors: any, _group: any) {
R
Rob Lourens 已提交
937
		return Promise.resolve(undefined);
938 939
	}

940
	invokeWithinEditorContext<T>(fn: (accessor: ServicesAccessor) => T): T {
941
		throw new Error('not implemented');
942 943
	}

944
	createInput(_input: IResourceInput | IUntitledTextResourceInput | IResourceDiffInput | IResourceSideBySideInput): IEditorInput {
945
		throw new Error('not implemented');
946
	}
947 948 949 950 951 952 953 954 955

	save(editors: IEditorIdentifier[], options?: ISaveEditorsOptions): Promise<boolean> {
		throw new Error('Method not implemented.');
	}

	saveAll(options?: ISaveEditorsOptions): Promise<boolean> {
		throw new Error('Method not implemented.');
	}

B
Benjamin Pasero 已提交
956 957 958 959 960
	revert(editors: IEditorIdentifier[], options?: IRevertOptions): Promise<boolean> {
		throw new Error('Method not implemented.');
	}

	revertAll(options?: IRevertAllEditorsOptions): Promise<boolean> {
961 962
		throw new Error('Method not implemented.');
	}
963 964
}

965 966
export class TestFileService implements IFileService {

B
Benjamin Pasero 已提交
967
	_serviceBrand: undefined;
968

M
Matt Bierner 已提交
969 970
	private readonly _onFileChanges: Emitter<FileChangesEvent>;
	private readonly _onAfterOperation: Emitter<FileOperationEvent>;
971

972
	readonly onWillActivateFileSystemProvider = Event.None;
973
	readonly onDidChangeFileSystemProviderCapabilities = Event.None;
974
	readonly onError: Event<Error> = Event.None;
975

976
	private content = 'Hello Html';
977
	private lastReadFileUri!: URI;
978

979 980 981 982 983
	constructor() {
		this._onFileChanges = new Emitter<FileChangesEvent>();
		this._onAfterOperation = new Emitter<FileOperationEvent>();
	}

B
Benjamin Pasero 已提交
984
	setContent(content: string): void {
985 986 987
		this.content = content;
	}

B
Benjamin Pasero 已提交
988
	getContent(): string {
989 990 991
		return this.content;
	}

B
Benjamin Pasero 已提交
992
	getLastReadFileUri(): URI {
993 994 995
		return this.lastReadFileUri;
	}

B
Benjamin Pasero 已提交
996
	get onFileChanges(): Event<FileChangesEvent> {
997 998 999
		return this._onFileChanges.event;
	}

B
Benjamin Pasero 已提交
1000
	fireFileChanges(event: FileChangesEvent): void {
1001 1002 1003
		this._onFileChanges.fire(event);
	}

B
Benjamin Pasero 已提交
1004
	get onAfterOperation(): Event<FileOperationEvent> {
1005 1006 1007
		return this._onAfterOperation.event;
	}

B
Benjamin Pasero 已提交
1008
	fireAfterOperation(event: FileOperationEvent): void {
1009 1010 1011
		this._onAfterOperation.fire(event);
	}

B
Benjamin Pasero 已提交
1012 1013 1014
	resolve(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat>;
	resolve(resource: URI, _options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
	resolve(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat> {
B
Benjamin Pasero 已提交
1015
		return Promise.resolve({
1016 1017
			resource,
			etag: Date.now().toString(),
B
Benjamin Pasero 已提交
1018
			encoding: 'utf8',
B
Benjamin Pasero 已提交
1019
			mtime: Date.now(),
1020
			size: 42,
1021
			isFile: true,
1022
			isDirectory: false,
1023
			isSymbolicLink: false,
B
Benjamin Pasero 已提交
1024
			name: resources.basename(resource)
B
Benjamin Pasero 已提交
1025
		});
1026
	}
B
Benjamin Pasero 已提交
1027

B
Benjamin Pasero 已提交
1028 1029 1030 1031
	async resolveAll(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
		const stats = await Promise.all(toResolve.map(resourceAndOption => this.resolve(resourceAndOption.resource, resourceAndOption.options)));

		return stats.map(stat => ({ stat, success: true }));
I
isidor 已提交
1032 1033
	}

B
Benjamin Pasero 已提交
1034 1035
	async exists(_resource: URI): Promise<boolean> {
		return true;
1036
	}
B
Benjamin Pasero 已提交
1037

1038
	readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
1039 1040
		this.lastReadFileUri = resource;

1041
		return Promise.resolve({
B
Benjamin Pasero 已提交
1042
			resource: resource,
1043
			value: VSBuffer.fromString(this.content),
1044
			etag: 'index.txt',
B
Benjamin Pasero 已提交
1045 1046
			encoding: 'utf8',
			mtime: Date.now(),
1047
			ctime: Date.now(),
1048 1049
			name: resources.basename(resource),
			size: 1
E
Erich Gamma 已提交
1050
		});
1051
	}
E
Erich Gamma 已提交
1052

1053
	readFileStream(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileStreamContent> {
1054 1055
		this.lastReadFileUri = resource;

1056
		return Promise.resolve({
A
Alex Dima 已提交
1057 1058
			resource: resource,
			value: {
1059
				on: (event: string, callback: Function): void => {
A
Alex Dima 已提交
1060
					if (event === 'data') {
1061
						callback(this.content);
A
Alex Dima 已提交
1062 1063 1064 1065
					}
					if (event === 'end') {
						callback();
					}
B
Benjamin Pasero 已提交
1066 1067 1068 1069
				},
				resume: () => { },
				pause: () => { },
				destroy: () => { }
A
Alex Dima 已提交
1070 1071 1072
			},
			etag: 'index.txt',
			encoding: 'utf8',
B
Benjamin Pasero 已提交
1073
			mtime: Date.now(),
1074
			ctime: Date.now(),
1075 1076
			size: 1,
			name: resources.basename(resource)
A
Alex Dima 已提交
1077
		});
1078 1079
	}

B
Benjamin Pasero 已提交
1080 1081 1082 1083
	async writeFile(resource: URI, bufferOrReadable: VSBuffer | VSBufferReadable, options?: IWriteFileOptions): Promise<IFileStatWithMetadata> {
		await timeout(0);

		return ({
1084 1085 1086
			resource,
			etag: 'index.txt',
			mtime: Date.now(),
1087
			ctime: Date.now(),
1088
			size: 42,
1089
			isFile: true,
1090
			isDirectory: false,
1091
			isSymbolicLink: false,
B
Benjamin Pasero 已提交
1092
			name: resources.basename(resource)
B
Benjamin Pasero 已提交
1093
		});
1094
	}
D
Daniel Imms 已提交
1095

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

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

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

1108
	createFolder(_resource: URI): Promise<IFileStatWithMetadata> {
1109
		throw new Error('not implemented');
1110 1111
	}

1112 1113
	onDidChangeFileSystemProviderRegistrations = Event.None;

1114 1115 1116 1117 1118 1119
	private providers = new Map<string, IFileSystemProvider>();

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

		return toDisposable(() => this.providers.delete(scheme));
1120 1121
	}

1122 1123
	activateProvider(_scheme: string): Promise<void> {
		throw new Error('not implemented');
1124 1125
	}

1126
	canHandleResource(resource: URI): boolean {
1127
		return resource.scheme === 'file' || this.providers.has(resource.scheme);
1128 1129
	}

1130 1131 1132 1133 1134 1135 1136
	hasCapability(resource: URI, capability: FileSystemProviderCapabilities): boolean {
		if (capability === FileSystemProviderCapabilities.PathCaseSensitive && isLinux) {
			return true;
		}

		return false;
	}
1137

J
Johannes Rieken 已提交
1138
	del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> {
1139
		return Promise.resolve();
1140 1141
	}

1142 1143
	watch(_resource: URI): IDisposable {
		return Disposable.None;
1144 1145
	}

1146 1147
	getWriteEncoding(_resource: URI): IResourceEncoding {
		return { encoding: 'utf8', hasBOM: false };
1148
	}
D
Daniel Imms 已提交
1149

1150
	dispose(): void {
E
Erich Gamma 已提交
1151
	}
1152
}
1153

1154
export class TestBackupFileService implements IBackupFileService {
B
Benjamin Pasero 已提交
1155
	_serviceBrand: undefined;
1156

B
Benjamin Pasero 已提交
1157
	hasBackups(): Promise<boolean> {
B
Benjamin Pasero 已提交
1158
		return Promise.resolve(false);
1159 1160
	}

B
Benjamin Pasero 已提交
1161
	hasBackup(_resource: URI): Promise<boolean> {
B
Benjamin Pasero 已提交
1162
		return Promise.resolve(false);
1163 1164
	}

B
Benjamin Pasero 已提交
1165
	hasBackupSync(resource: URI, versionId?: number): boolean {
1166 1167 1168
		return false;
	}

B
Benjamin Pasero 已提交
1169 1170 1171 1172 1173
	async loadBackupResource(resource: URI): Promise<URI | undefined> {
		const hasBackup = await this.hasBackup(resource);
		if (hasBackup) {
			return this.toBackupResource(resource);
		}
B
Benjamin Pasero 已提交
1174

B
Benjamin Pasero 已提交
1175
		return undefined;
B
Benjamin Pasero 已提交
1176 1177
	}

B
Benjamin Pasero 已提交
1178
	registerResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1179
		return Promise.resolve();
D
Daniel Imms 已提交
1180 1181
	}

B
Benjamin Pasero 已提交
1182
	deregisterResourceForBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1183
		return Promise.resolve();
D
Daniel Imms 已提交
1184 1185
	}

B
Benjamin Pasero 已提交
1186
	toBackupResource(_resource: URI): URI {
1187
		throw new Error('not implemented');
D
Daniel Imms 已提交
1188
	}
1189

B
Benjamin Pasero 已提交
1190
	backupResource<T extends object>(_resource: URI, _content: ITextSnapshot, versionId?: number, meta?: T): Promise<void> {
B
Benjamin Pasero 已提交
1191
		return Promise.resolve();
1192 1193
	}

B
Benjamin Pasero 已提交
1194
	getWorkspaceFileBackups(): Promise<URI[]> {
B
Benjamin Pasero 已提交
1195
		return Promise.resolve([]);
1196 1197
	}

B
Benjamin Pasero 已提交
1198
	parseBackupContent(textBufferFactory: ITextBufferFactory): string {
1199 1200 1201 1202
		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);
1203 1204
	}

B
Benjamin Pasero 已提交
1205
	resolveBackupContent<T extends object>(_backup: URI): Promise<IResolvedBackup<T>> {
1206
		throw new Error('not implemented');
1207 1208
	}

B
Benjamin Pasero 已提交
1209
	discardResourceBackup(_resource: URI): Promise<void> {
B
Benjamin Pasero 已提交
1210
		return Promise.resolve();
1211 1212
	}

1213 1214
	didDiscardAllWorkspaceBackups = false;

B
Benjamin Pasero 已提交
1215
	discardAllWorkspaceBackups(): Promise<void> {
1216 1217
		this.didDiscardAllWorkspaceBackups = true;

B
Benjamin Pasero 已提交
1218
		return Promise.resolve();
1219
	}
1220
}
D
Daniel Imms 已提交
1221

B
Benjamin Pasero 已提交
1222
export class TestCodeEditorService implements ICodeEditorService {
1223
	_serviceBrand: undefined;
B
Benjamin Pasero 已提交
1224 1225 1226 1227 1228

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

1231 1232
	addCodeEditor(_editor: ICodeEditor): void { }
	removeCodeEditor(_editor: ICodeEditor): void { }
B
Benjamin Pasero 已提交
1233
	listCodeEditors(): ICodeEditor[] { return []; }
1234 1235
	addDiffEditor(_editor: IDiffEditor): void { }
	removeDiffEditor(_editor: IDiffEditor): void { }
B
Benjamin Pasero 已提交
1236
	listDiffEditors(): IDiffEditor[] { return []; }
1237
	getFocusedCodeEditor(): ICodeEditor | null { return null; }
1238 1239 1240 1241 1242
	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) { }
1243
	getTransientModelProperties(_model: ITextModel) { return undefined; }
1244 1245
	getActiveCodeEditor(): ICodeEditor | null { return null; }
	openCodeEditor(_input: IResourceInput, _source: ICodeEditor, _sideBySide?: boolean): Promise<ICodeEditor | null> { return Promise.resolve(null); }
B
Benjamin Pasero 已提交
1246 1247
}

1248 1249
export class TestLifecycleService implements ILifecycleService {

B
Benjamin Pasero 已提交
1250
	_serviceBrand: undefined;
1251

B
Benjamin Pasero 已提交
1252 1253
	phase!: LifecyclePhase;
	startupKind!: StartupKind;
1254

1255 1256 1257
	private readonly _onBeforeShutdown = new Emitter<BeforeShutdownEvent>();
	private readonly _onWillShutdown = new Emitter<WillShutdownEvent>();
	private readonly _onShutdown = new Emitter<void>();
1258

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

B
Benjamin Pasero 已提交
1263
	fireShutdown(reason = ShutdownReason.QUIT): void {
1264
		this._onWillShutdown.fire({
1265 1266 1267
			join: () => { },
			reason
		});
1268 1269
	}

B
Benjamin Pasero 已提交
1270
	fireWillShutdown(event: BeforeShutdownEvent): void {
1271 1272 1273
		this._onBeforeShutdown.fire(event);
	}

B
Benjamin Pasero 已提交
1274
	get onBeforeShutdown(): Event<BeforeShutdownEvent> {
1275
		return this._onBeforeShutdown.event;
1276 1277
	}

B
Benjamin Pasero 已提交
1278
	get onWillShutdown(): Event<WillShutdownEvent> {
1279 1280 1281
		return this._onWillShutdown.event;
	}

B
Benjamin Pasero 已提交
1282
	get onShutdown(): Event<void> {
1283 1284
		return this._onShutdown.event;
	}
1285 1286
}

S
rename  
Sandeep Somavarapu 已提交
1287
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {
1288

1289
	_serviceBrand: undefined;
1290 1291 1292 1293

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

B
Benjamin Pasero 已提交
1294
	onDidChangeConfiguration() {
1295 1296 1297
		return { dispose() { } };
	}

1298
	getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
1299 1300
		const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;
		const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
1301
		return this.configurationService.getValue(section, { resource });
1302
	}
1303 1304 1305 1306

	updateValue(resource: URI, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise<void> {
		return this.configurationService.updateValue(key, value);
	}
B
Benjamin Pasero 已提交
1307 1308
}

S
Sandeep Somavarapu 已提交
1309 1310
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {

1311
	_serviceBrand: undefined;
S
Sandeep Somavarapu 已提交
1312 1313

	constructor(
1314
		@IConfigurationService private readonly configurationService: IConfigurationService,
S
Sandeep Somavarapu 已提交
1315 1316 1317
	) {
	}

1318 1319 1320 1321
	getEOL(resource: URI, language?: string): string {
		const eol = this.configurationService.getValue<string>('files.eol', { overrideIdentifier: language, resource });
		if (eol && eol !== 'auto') {
			return eol;
S
Sandeep Somavarapu 已提交
1322 1323 1324 1325 1326 1327
		}
		return (isLinux || isMacintosh) ? '\n' : '\r\n';
	}
}


1328
export class TestSharedProcessService implements ISharedProcessService {
1329

1330
	_serviceBrand: undefined;
1331

1332 1333 1334
	getChannel(channelName: string): any {
		return undefined;
	}
1335

1336
	registerChannel(channelName: string, channel: any): void { }
1337 1338 1339

	async toggleSharedProcessWindow(): Promise<void> { }
	async whenSharedProcessReady(): Promise<void> { }
1340 1341
}

1342 1343 1344 1345 1346 1347 1348
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;

M
Matt Bierner 已提交
1349 1350 1351 1352 1353 1354
	readonly onDidChangeFile: Event<readonly IFileChange[]> = Event.map(this.diskFileSystemProvider.onDidChangeFile, changes => changes.map((c): IFileChange => {
		return {
			type: c.type,
			resource: c.resource.with({ scheme: Schemas.vscodeRemote, authority: this.remoteAuthority }),
		};
	}));
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373
	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 已提交
1374
}
1375 1376

export const productService: IProductService = { _serviceBrand: undefined, ...product };
1377 1378 1379 1380 1381

export class TestHostService implements IHostService {

	_serviceBrand: undefined;

1382 1383 1384
	readonly hasFocus: boolean = true;
	readonly onDidChangeFocus: Event<boolean> = Event.None;

1385 1386
	async restart(): Promise<void> { }
	async reload(): Promise<void> { }
1387

1388 1389
	async focus(): Promise<void> { }

1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414
	async openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> { }

	async toggleFullScreen(): Promise<void> { }
}

export class TestElectronService implements IElectronService {
	_serviceBrand: undefined;

	onWindowOpen: Event<number> = Event.None;
	onWindowMaximize: Event<number> = Event.None;
	onWindowUnmaximize: Event<number> = Event.None;
	onWindowFocus: Event<number> = Event.None;
	onWindowBlur: Event<number> = Event.None;

	windowCount = Promise.resolve(1);
	getWindowCount(): Promise<number> { return this.windowCount; }

	async getWindows(): Promise<IOpenedWindow[]> { return []; }
	async getActiveWindowId(): Promise<number | undefined> { return undefined; }

	openWindow(options?: IOpenEmptyWindowOptions): Promise<void>;
	openWindow(toOpen: IWindowOpenable[], options?: IOpenWindowOptions): Promise<void>;
	openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> {
		throw new Error('Method not implemented.');
	}
1415

1416
	async toggleFullScreen(): Promise<void> { }
1417 1418 1419 1420 1421 1422 1423
	async handleTitleDoubleClick(): Promise<void> { }
	async isMaximized(): Promise<boolean> { return true; }
	async maximizeWindow(): Promise<void> { }
	async unmaximizeWindow(): Promise<void> { }
	async minimizeWindow(): Promise<void> { }
	async isWindowFocused(): Promise<boolean> { return true; }
	async focusWindow(options?: { windowId?: number | undefined; } | undefined): Promise<void> { }
1424 1425 1426
	async showMessageBox(options: Electron.MessageBoxOptions): Promise<Electron.MessageBoxReturnValue> { throw new Error('Method not implemented.'); }
	async showSaveDialog(options: Electron.SaveDialogOptions): Promise<Electron.SaveDialogReturnValue> { throw new Error('Method not implemented.'); }
	async showOpenDialog(options: Electron.OpenDialogOptions): Promise<Electron.OpenDialogReturnValue> { throw new Error('Method not implemented.'); }
1427 1428 1429 1430 1431 1432 1433 1434
	async pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> { }
	async pickFileAndOpen(options: INativeOpenDialogOptions): Promise<void> { }
	async pickFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> { }
	async pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise<void> { }
	async showItemInFolder(path: string): Promise<void> { }
	async setRepresentedFilename(path: string): Promise<void> { }
	async setDocumentEdited(edited: boolean): Promise<void> { }
	async openExternal(url: string): Promise<boolean> { return false; }
1435
	async updateTouchBar(): Promise<void> { }
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449
	async newWindowTab(): Promise<void> { }
	async showPreviousWindowTab(): Promise<void> { }
	async showNextWindowTab(): Promise<void> { }
	async moveWindowTabToNewWindow(): Promise<void> { }
	async mergeAllWindowTabs(): Promise<void> { }
	async toggleWindowTabsBar(): Promise<void> { }
	async relaunch(options?: { addArgs?: string[] | undefined; removeArgs?: string[] | undefined; } | undefined): Promise<void> { }
	async reload(): Promise<void> { }
	async closeWindow(): Promise<void> { }
	async quit(): Promise<void> { }
	async openDevTools(options?: Electron.OpenDevToolsOptions | undefined): Promise<void> { }
	async toggleDevTools(): Promise<void> { }
	async startCrashReporter(options: Electron.CrashReporterStartOptions): Promise<void> { }
	async resolveProxy(url: string): Promise<string | undefined> { return undefined; }
1450
}
1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 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 1510 1511 1512 1513 1514

export class TestBackupMainService implements IBackupMainService {
	_serviceBrand: undefined;

	isHotExitEnabled(): boolean {
		throw new Error('Method not implemented.');
	}

	getWorkspaceBackups(): IWorkspaceBackupInfo[] {
		throw new Error('Method not implemented.');
	}

	getFolderBackupPaths(): URI[] {
		throw new Error('Method not implemented.');
	}

	getEmptyWindowBackupPaths(): IEmptyWindowBackupInfo[] {
		throw new Error('Method not implemented.');
	}

	registerWorkspaceBackupSync(workspace: IWorkspaceBackupInfo, migrateFrom?: string | undefined): string {
		throw new Error('Method not implemented.');
	}

	registerFolderBackupSync(folderUri: URI): string {
		throw new Error('Method not implemented.');
	}

	registerEmptyWindowBackupSync(backupFolder?: string | undefined, remoteAuthority?: string | undefined): string {
		throw new Error('Method not implemented.');
	}

	unregisterWorkspaceBackupSync(workspace: IWorkspaceIdentifier): void {
		throw new Error('Method not implemented.');
	}

	unregisterFolderBackupSync(folderUri: URI): void {
		throw new Error('Method not implemented.');
	}

	unregisterEmptyWindowBackupSync(backupFolder: string): void {
		throw new Error('Method not implemented.');
	}
}

export class TestDialogMainService implements IDialogMainService {
	_serviceBrand: undefined;

	pickFileFolder(options: INativeOpenDialogOptions, window?: Electron.BrowserWindow | undefined): Promise<string[] | undefined> {
		throw new Error('Method not implemented.');
	}

	pickFolder(options: INativeOpenDialogOptions, window?: Electron.BrowserWindow | undefined): Promise<string[] | undefined> {
		throw new Error('Method not implemented.');
	}

	pickFile(options: INativeOpenDialogOptions, window?: Electron.BrowserWindow | undefined): Promise<string[] | undefined> {
		throw new Error('Method not implemented.');
	}

	pickWorkspace(options: INativeOpenDialogOptions, window?: Electron.BrowserWindow | undefined): Promise<string[] | undefined> {
		throw new Error('Method not implemented.');
	}

1515
	showMessageBox(options: Electron.MessageBoxOptions, window?: Electron.BrowserWindow | undefined): Promise<Electron.MessageBoxReturnValue> {
1516 1517 1518
		throw new Error('Method not implemented.');
	}

1519
	showSaveDialog(options: Electron.SaveDialogOptions, window?: Electron.BrowserWindow | undefined): Promise<Electron.SaveDialogReturnValue> {
1520 1521 1522
		throw new Error('Method not implemented.');
	}

1523
	showOpenDialog(options: Electron.OpenDialogOptions, window?: Electron.BrowserWindow | undefined): Promise<Electron.OpenDialogReturnValue> {
1524 1525 1526
		throw new Error('Method not implemented.');
	}
}
1527

1528
export class TestWorkingCopyService extends WorkingCopyService { }
1529 1530 1531 1532 1533 1534 1535

export class TestFilesConfigurationService extends FilesConfigurationService {

	onFilesConfigurationChange(configuration: any): void {
		super.onFilesConfigurationChange(configuration);
	}
}