Merge from vscode 718331d6f3ebd1b571530ab499edb266ddd493d5

This commit is contained in:
ADS Merger
2020-02-08 04:50:58 +00:00
parent 8c61538a27
commit 2af13c18d2
752 changed files with 16458 additions and 10063 deletions

View File

@@ -5,7 +5,6 @@
import * as assert from 'assert';
import { setUnexpectedErrorHandler, errorHandler } from 'vs/base/common/errors';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { URI } from 'vs/base/common/uri';
import * as types from 'vs/workbench/api/common/extHostTypes';
import { TextModel as EditorModel } from 'vs/editor/common/model/textModel';
@@ -28,11 +27,26 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import 'vs/workbench/contrib/search/browser/search.contribution';
import { NullLogService } from 'vs/platform/log/common/log';
import { ITextModel } from 'vs/editor/common/model';
import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
import { nullExtensionDescription, IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { dispose } from 'vs/base/common/lifecycle';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { NullApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import 'vs/editor/contrib/codeAction/codeAction';
import 'vs/editor/contrib/codelens/codelens';
import 'vs/editor/contrib/colorPicker/color';
import 'vs/editor/contrib/format/format';
import 'vs/editor/contrib/gotoSymbol/goToCommands';
import 'vs/editor/contrib/hover/getHover';
import 'vs/editor/contrib/links/getLinks';
import 'vs/editor/contrib/parameterHints/provideSignatureHelp';
import 'vs/editor/contrib/quickOpen/quickOpen';
import 'vs/editor/contrib/smartSelect/smartSelect';
import 'vs/editor/contrib/suggest/suggest';
const defaultSelector = { scheme: 'far' };
const model: ITextModel = EditorModel.createFromString(
@@ -64,42 +78,37 @@ suite('ExtHostLanguageFeatureCommands', function () {
setUnexpectedErrorHandler(() => { });
// Use IInstantiationService to get typechecking when instantiating
let inst: IInstantiationService;
{
let instantiationService = new TestInstantiationService();
rpcProtocol = new TestRPCProtocol();
instantiationService.stub(ICommandService, {
_serviceBrand: undefined,
executeCommand(id: string, ...args: any): any {
const command = CommandsRegistry.getCommands().get(id);
if (!command) {
return Promise.reject(new Error(id + ' NOT known'));
}
const { handler } = command;
return Promise.resolve(instantiationService.invokeFunction(handler, ...args));
let insta: IInstantiationService;
rpcProtocol = new TestRPCProtocol();
const services = new ServiceCollection();
services.set(IExtensionService, new class extends mock<IExtensionService>() {
async activateByEvent() {
}
});
services.set(ICommandService, new SyncDescriptor(class extends mock<ICommandService>() {
executeCommand(id: string, ...args: any): any {
const command = CommandsRegistry.getCommands().get(id);
if (!command) {
return Promise.reject(new Error(id + ' NOT known'));
}
});
instantiationService.stub(IMarkerService, new MarkerService());
instantiationService.stub(IModelService, <IModelService>{
_serviceBrand: undefined,
getModel(): any { return model; },
createModel() { throw new Error(); },
updateModel() { throw new Error(); },
setMode() { throw new Error(); },
destroyModel() { throw new Error(); },
getModels() { throw new Error(); },
onModelAdded: undefined!,
onModelModeChanged: undefined!,
onModelRemoved: undefined!,
getCreationOptions() { throw new Error(); }
});
instantiationService.stub(IEditorWorkerService, new class extends mock<IEditorWorkerService>() {
async computeMoreMinimalEdits(_uri: any, edits: any) {
return edits || undefined;
}
});
inst = instantiationService;
}
const { handler } = command;
return Promise.resolve(insta.invokeFunction(handler, ...args));
}
}));
services.set(IMarkerService, new MarkerService());
services.set(IModelService, new class extends mock<IModelService>() {
getModel() { return model; }
});
services.set(IEditorWorkerService, new class extends mock<IEditorWorkerService>() {
async computeMoreMinimalEdits(_uri: any, edits: any) {
return edits || undefined;
}
});
insta = new InstantiationService(services);
const extHostDocumentsAndEditors = new ExtHostDocumentsAndEditors(rpcProtocol, new NullLogService());
extHostDocumentsAndEditors.$acceptDocumentsAndEditorsDelta({
@@ -117,7 +126,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
commands = new ExtHostCommands(rpcProtocol, new NullLogService());
rpcProtocol.set(ExtHostContext.ExtHostCommands, commands);
rpcProtocol.set(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, rpcProtocol));
rpcProtocol.set(MainContext.MainThreadCommands, insta.createInstance(MainThreadCommands, rpcProtocol));
ExtHostApiCommands.register(commands);
const diagnostics = new ExtHostDiagnostics(rpcProtocol, new NullLogService());
@@ -126,7 +135,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, diagnostics, new NullLogService(), NullApiDeprecationService);
rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, extHost);
mainThread = rpcProtocol.set(MainContext.MainThreadLanguageFeatures, inst.createInstance(MainThreadLanguageFeatures, rpcProtocol));
mainThread = rpcProtocol.set(MainContext.MainThreadLanguageFeatures, insta.createInstance(MainThreadLanguageFeatures, rpcProtocol));
return rpcProtocol.sync();
});

View File

@@ -8,7 +8,7 @@ import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
import { MainThreadCommandsShape } from 'vs/workbench/api/common/extHost.protocol';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { SingleProxyRPCProtocol } from './testRPCProtocol';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { NullLogService } from 'vs/platform/log/common/log';
suite('ExtHostCommands', function () {

View File

@@ -8,9 +8,9 @@ import { URI, UriComponents } from 'vs/base/common/uri';
import { ExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
import { ExtHostConfigProvider } from 'vs/workbench/api/common/extHostConfiguration';
import { MainThreadConfigurationShape, IConfigurationInitData } from 'vs/workbench/api/common/extHost.protocol';
import { ConfigurationModel } from 'vs/platform/configuration/common/configurationModels';
import { ConfigurationModel, ConfigurationModelParser } from 'vs/platform/configuration/common/configurationModels';
import { TestRPCProtocol } from './testRPCProtocol';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { IWorkspaceFolder, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { ConfigurationTarget, IConfigurationModel, IConfigurationChange } from 'vs/platform/configuration/common/configuration';
import { NullLogService } from 'vs/platform/log/common/log';
@@ -476,6 +476,76 @@ suite('ExtHostConfiguration', function () {
assert.equal(actual2.workspaceFolderValue, undefined);
});
test('inspect with language overrides', function () {
const firstRoot = URI.file('foo1');
const secondRoot = URI.file('foo2');
const folders: [UriComponents, IConfigurationModel][] = [];
folders.push([firstRoot, toConfigurationModel({
'editor.wordWrap': 'bounded',
'[typescript]': {
'editor.wordWrap': 'unbounded',
}
})]);
folders.push([secondRoot, toConfigurationModel({})]);
const extHostWorkspace = createExtHostWorkspace();
extHostWorkspace.$initializeWorkspace({
'id': 'foo',
'folders': [aWorkspaceFolder(firstRoot, 0), aWorkspaceFolder(secondRoot, 1)],
'name': 'foo'
});
const testObject = new ExtHostConfigProvider(
new class extends mock<MainThreadConfigurationShape>() { },
extHostWorkspace,
{
defaults: toConfigurationModel({
'editor.wordWrap': 'off',
'[markdown]': {
'editor.wordWrap': 'bounded',
}
}),
user: toConfigurationModel({
'editor.wordWrap': 'bounded',
'[typescript]': {
'editor.lineNumbers': 'off',
}
}),
workspace: toConfigurationModel({
'[typescript]': {
'editor.wordWrap': 'unbounded',
'editor.lineNumbers': 'off',
}
}),
folders,
configurationScopes: []
},
new NullLogService()
);
let actual = testObject.getConfiguration(undefined, { uri: firstRoot, languageId: 'typescript' }).inspect('editor.wordWrap')!;
assert.equal(actual.defaultValue, 'off');
assert.equal(actual.globalValue, 'bounded');
assert.equal(actual.workspaceValue, undefined);
assert.equal(actual.workspaceFolderValue, 'bounded');
assert.equal(actual.defaultLanguageValue, undefined);
assert.equal(actual.globalLanguageValue, undefined);
assert.equal(actual.workspaceLanguageValue, 'unbounded');
assert.equal(actual.workspaceFolderLanguageValue, 'unbounded');
assert.deepEqual(actual.languageIds, ['markdown', 'typescript']);
actual = testObject.getConfiguration(undefined, { uri: secondRoot, languageId: 'typescript' }).inspect('editor.wordWrap')!;
assert.equal(actual.defaultValue, 'off');
assert.equal(actual.globalValue, 'bounded');
assert.equal(actual.workspaceValue, undefined);
assert.equal(actual.workspaceFolderValue, undefined);
assert.equal(actual.defaultLanguageValue, undefined);
assert.equal(actual.globalLanguageValue, undefined);
assert.equal(actual.workspaceLanguageValue, 'unbounded');
assert.equal(actual.workspaceFolderLanguageValue, undefined);
assert.deepEqual(actual.languageIds, ['markdown', 'typescript']);
});
test('getConfiguration vs get', function () {
const all = createExtHostConfiguration({
@@ -654,4 +724,11 @@ suite('ExtHostConfiguration', function () {
function aWorkspaceFolder(uri: URI, index: number, name: string = ''): IWorkspaceFolder {
return new WorkspaceFolder({ uri, name, index });
}
function toConfigurationModel(obj: any): ConfigurationModel {
const parser = new ConfigurationModelParser('test');
parser.parseContent(JSON.stringify(obj));
return parser.configurationModel;
}
});

View File

@@ -9,7 +9,7 @@ import { DiagnosticCollection, ExtHostDiagnostics } from 'vs/workbench/api/commo
import { Diagnostic, DiagnosticSeverity, Range, DiagnosticRelatedInformation, Location } from 'vs/workbench/api/common/extHostTypes';
import { MainThreadDiagnosticsShape, IMainContext } from 'vs/workbench/api/common/extHost.protocol';
import { IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { Emitter, Event } from 'vs/base/common/event';
import { NullLogService } from 'vs/platform/log/common/log';

View File

@@ -10,7 +10,7 @@ import { Position } from 'vs/workbench/api/common/extHostTypes';
import { Range } from 'vs/editor/common/core/range';
import { MainThreadDocumentsShape } from 'vs/workbench/api/common/extHost.protocol';
import { IModelChangedEvent } from 'vs/editor/common/model/mirrorTextModel';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
suite('ExtHostDocumentData', () => {

View File

@@ -12,7 +12,7 @@ import { ExtHostDocumentSaveParticipant } from 'vs/workbench/api/common/extHostD
import { SingleProxyRPCProtocol } from './testRPCProtocol';
import { SaveReason } from 'vs/workbench/common/editor';
import type * as vscode from 'vscode';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { NullLogService } from 'vs/platform/log/common/log';
import { timeout } from 'vs/base/common/async';
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';

View File

@@ -6,7 +6,7 @@
import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
import { TestRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
import { TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
import { NullLogService } from 'vs/platform/log/common/log';
suite('ExtHostDocumentsAndEditors', () => {

View File

@@ -43,7 +43,7 @@ import { getColors } from 'vs/editor/contrib/colorPicker/color';
import { CancellationToken } from 'vs/base/common/cancellation';
import { nullExtensionDescription as defaultExtension } from 'vs/workbench/services/extensions/common/extensions';
import { provideSelectionRanges } from 'vs/editor/contrib/smartSelect/smartSelect';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { dispose } from 'vs/base/common/lifecycle';
import { withNullAsUndefined } from 'vs/base/common/types';

View File

@@ -8,8 +8,9 @@ import { MainThreadMessageService } from 'vs/workbench/api/browser/mainThreadMes
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { INotificationService, INotification, NoOpNotification, INotificationHandle, Severity, IPromptChoice, IPromptOptions, IStatusMessageOptions, NotificationsFilter } from 'vs/platform/notification/common/notification';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import * as platform from 'vs/base/common/platform';
const emptyDialogService = new class implements IDialogService {
_serviceBrand: undefined;
@@ -97,7 +98,7 @@ suite('ExtHostMessageService', function () {
let service = new MainThreadMessageService(null!, new EmptyNotificationService(notification => {
assert.equal(notification.actions!.primary!.length, 1);
setImmediate(() => notification.actions!.primary![0].run());
platform.setImmediate(() => notification.actions!.primary![0].run());
}), emptyCommandService, emptyDialogService);
const handle = await service.$showMessage(1, 'h', {}, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]);

View File

@@ -9,7 +9,7 @@ import { MainThreadTextEditorsShape, IResolvedTextEditorConfiguration, ITextEdit
import { ExtHostTextEditorOptions, ExtHostTextEditor } from 'vs/workbench/api/common/extHostTextEditor';
import { ExtHostDocumentData } from 'vs/workbench/api/common/extHostDocumentData';
import { URI } from 'vs/base/common/uri';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { NullLogService } from 'vs/platform/log/common/log';
suite('ExtHostTextEditor', () => {

View File

@@ -6,9 +6,9 @@ import * as assert from 'assert';
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
import { MainContext, MainThreadTextEditorsShape, IWorkspaceEditDto } from 'vs/workbench/api/common/extHost.protocol';
import { URI } from 'vs/base/common/uri';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
import { SingleProxyRPCProtocol, TestRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
import { SingleProxyRPCProtocol, TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
import { ExtHostEditors } from 'vs/workbench/api/common/extHostTextEditors';
import { WorkspaceTextEdit } from 'vs/editor/common/modes';
import { NullLogService } from 'vs/platform/log/common/log';

View File

@@ -14,7 +14,7 @@ import { TestRPCProtocol } from './testRPCProtocol';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { TreeItemCollapsibleState, ITreeItem } from 'vs/workbench/common/views';
import { NullLogService } from 'vs/platform/log/common/log';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';

View File

@@ -3,6 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type * as vscode from 'vscode';
import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
@@ -10,8 +11,7 @@ import { NullLogService } from 'vs/platform/log/common/log';
import { MainThreadWebviews } from 'vs/workbench/api/browser/mainThreadWebview';
import { ExtHostWebviews } from 'vs/workbench/api/common/extHostWebview';
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import type * as vscode from 'vscode';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { SingleProxyRPCProtocol } from './testRPCProtocol';
suite('ExtHostWebview', () => {

View File

@@ -14,7 +14,7 @@ import { MainThreadWorkspace } from 'vs/workbench/api/browser/mainThreadWorkspac
import { IMainContext, IWorkspaceData, MainContext, ITextSearchComplete } from 'vs/workbench/api/common/extHost.protocol';
import { RelativePattern } from 'vs/workbench/api/common/extHostTypes';
import { ExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { TestRPCProtocol } from './testRPCProtocol';
import { ExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';

View File

@@ -8,7 +8,7 @@ import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands'
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
import { SingleProxyRPCProtocol } from './testRPCProtocol';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
suite('MainThreadCommands', function () {

View File

@@ -7,10 +7,10 @@ import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { MainThreadDocumentContentProviders } from 'vs/workbench/api/browser/mainThreadDocumentContentProviders';
import { TextModel } from 'vs/editor/common/model/textModel';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { TestRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
import { TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
import { TextEdit } from 'vs/editor/common/modes';
suite('MainThreadDocumentContentProviders', function () {

View File

@@ -12,8 +12,8 @@ import { TestCodeEditorService } from 'vs/editor/test/browser/editorTestServices
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ExtHostDocumentsAndEditorsShape, IDocumentsAndEditorsDelta } from 'vs/workbench/api/common/extHost.protocol';
import { createTestCodeEditor, TestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { TestEditorService, TestEditorGroupsService, TestTextResourcePropertiesService, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { TestEditorService, TestEditorGroupsService, TestTextResourcePropertiesService, TestEnvironmentService } from 'vs/workbench/test/browser/workbenchTestServices';
import { Event } from 'vs/base/common/event';
import { ITextModel } from 'vs/editor/common/model';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';

View File

@@ -11,7 +11,7 @@ import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { TestCodeEditorService } from 'vs/editor/test/browser/editorTestServices';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ExtHostDocumentsAndEditorsShape, ExtHostContext, ExtHostDocumentsShape, IWorkspaceTextEditDto } from 'vs/workbench/api/common/extHost.protocol';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { Event } from 'vs/base/common/event';
import { MainThreadTextEditors } from 'vs/workbench/api/browser/mainThreadEditors';
import { URI } from 'vs/base/common/uri';
@@ -19,15 +19,27 @@ import { Range } from 'vs/editor/common/core/range';
import { Position } from 'vs/editor/common/core/position';
import { IModelService } from 'vs/editor/common/services/modelService';
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService, TestContextService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService, TestContextService, TestTextResourcePropertiesService } from 'vs/workbench/test/browser/workbenchTestServices';
import { BulkEditService } from 'vs/workbench/services/bulkEdit/browser/bulkEditService';
import { NullLogService } from 'vs/platform/log/common/log';
import { NullLogService, ILogService } from 'vs/platform/log/common/log';
import { ITextModelService, IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
import { IReference, ImmortalReference } from 'vs/base/common/lifecycle';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { LabelService } from 'vs/workbench/services/label/common/labelService';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { IFileService } from 'vs/platform/files/common/files';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { ILabelService } from 'vs/platform/label/common/label';
suite('MainThreadEditors', () => {
@@ -42,18 +54,30 @@ suite('MainThreadEditors', () => {
const deletedResources = new Set<URI>();
setup(() => {
const configService = new TestConfigurationService();
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService(), new NullLogService());
const codeEditorService = new TestCodeEditorService();
movedResources.clear();
copiedResources.clear();
createdResources.clear();
deletedResources.clear();
const fileService = new TestFileService();
const textFileService = new class extends mock<ITextFileService>() {
const configService = new TestConfigurationService();
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService(), new NullLogService());
const services = new ServiceCollection();
services.set(IBulkEditService, new SyncDescriptor(BulkEditService));
services.set(ILabelService, new SyncDescriptor(LabelService));
services.set(ILogService, new NullLogService());
services.set(IWorkspaceContextService, new TestContextService());
services.set(IWorkbenchEnvironmentService, TestEnvironmentService);
services.set(IConfigurationService, configService);
services.set(IModelService, modelService);
services.set(ICodeEditorService, new TestCodeEditorService());
services.set(IFileService, new TestFileService());
services.set(IEditorService, new TestEditorService());
services.set(IEditorGroupsService, new TestEditorGroupsService());
services.set(ITextFileService, new class extends mock<ITextFileService>() {
isDirty() { return false; }
create(uri: URI, contents?: string, options?: any) {
createdResources.add(uri);
@@ -76,10 +100,8 @@ suite('MainThreadEditors', () => {
onDidRevert: Event.None,
onDidChangeDirty: Event.None
};
};
const workbenchEditorService = new TestEditorService();
const editorGroupService = new TestEditorGroupsService();
const textModelService = new class extends mock<ITextModelService>() {
});
services.set(ITextModelService, new class extends mock<ITextModelService>() {
createModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
const textEditorModel = new class extends mock<IResolvedTextEditorModel>() {
textEditorModel = modelService.getModel(resource)!;
@@ -87,13 +109,20 @@ suite('MainThreadEditors', () => {
textEditorModel.isReadonly = () => false;
return Promise.resolve(new ImmortalReference(textEditorModel));
}
};
});
services.set(IEditorWorkerService, new class extends mock<IEditorWorkerService>() {
const editorWorkerService = new class extends mock<IEditorWorkerService>() {
});
services.set(IPanelService, new class extends mock<IPanelService>() implements IPanelService {
_serviceBrand: undefined;
onDidPanelOpen = Event.None;
onDidPanelClose = Event.None;
getActivePanel() {
return undefined;
}
});
};
const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), editorWorkerService, textModelService, new TestFileService(), textFileService, new LabelService(TestEnvironmentService, new TestContextService()), configService);
const instaService = new InstantiationService(services);
const rpcProtocol = new TestRPCProtocol();
rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock<ExtHostDocumentsShape>() {
@@ -105,35 +134,9 @@ suite('MainThreadEditors', () => {
}
});
const documentAndEditor = new MainThreadDocumentsAndEditors(
rpcProtocol,
modelService,
textFileService,
workbenchEditorService,
codeEditorService,
fileService,
null!,
editorGroupService,
bulkEditService,
new class extends mock<IPanelService>() implements IPanelService {
_serviceBrand: undefined;
onDidPanelOpen = Event.None;
onDidPanelClose = Event.None;
getActivePanel() {
return undefined;
}
},
TestEnvironmentService
);
const documentAndEditor = instaService.createInstance(MainThreadDocumentsAndEditors, rpcProtocol);
editors = new MainThreadTextEditors(
documentAndEditor,
SingleProxyRPCProtocol(null),
codeEditorService,
bulkEditService,
workbenchEditorService,
editorGroupService,
);
editors = instaService.createInstance(MainThreadTextEditors, documentAndEditor, SingleProxyRPCProtocol(null));
});
test(`applyWorkspaceEdit returns false if model is changed by user`, () => {

View File

@@ -8,7 +8,7 @@ import { Part } from 'vs/workbench/browser/part';
import * as Types from 'vs/base/common/types';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { append, $, hide } from 'vs/base/browser/dom';
import { TestStorageService, TestLayoutService } from 'vs/workbench/test/workbenchTestServices';
import { TestStorageService, TestLayoutService } from 'vs/workbench/test/browser/workbenchTestServices';
import { StorageScope } from 'vs/platform/storage/common/storage';
class SimplePart extends Part {

View File

@@ -11,7 +11,7 @@ import * as Platform from 'vs/platform/registry/common/platform';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { workbenchInstantiationService, TestEditorGroupView, TestEditorGroupsService, TestStorageService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService, TestEditorGroupView, TestEditorGroupsService, TestStorageService } from 'vs/workbench/test/browser/workbenchTestServices';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { URI } from 'vs/base/common/uri';

View File

@@ -7,7 +7,7 @@ import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { Workspace, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { EditorBreadcrumbsModel, FileElement } from 'vs/workbench/browser/parts/editor/breadcrumbsModel';
import { TestContextService } from 'vs/workbench/test/workbenchTestServices';
import { TestContextService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { FileKind } from 'vs/platform/files/common/files';

View File

@@ -10,7 +10,7 @@ import { IEditorModel } from 'vs/platform/editor/common/editor';
import { URI } from 'vs/base/common/uri';
import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { Schemas } from 'vs/base/common/network';
class ServiceAccessor {

View File

@@ -11,8 +11,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { URI } from 'vs/base/common/uri';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { TestTextFileService, workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { ITextModel } from 'vs/editor/common/model';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -21,7 +20,6 @@ class ServiceAccessor {
@ITextModelService public textModelResolverService: ITextModelService,
@IModelService public modelService: IModelService,
@IModeService public modeService: IModeService,
@ITextFileService public textFileService: TestTextFileService
) {
}
}

View File

@@ -7,7 +7,7 @@ import * as assert from 'assert';
import { EditorGroup, ISerializedEditorGroup, EditorCloseEvent } from 'vs/workbench/common/editor/editorGroup';
import { Extensions as EditorExtensions, IEditorInputFactoryRegistry, EditorInput, IFileEditorInput, IEditorInputFactory, CloseDirection, EditorsOrder } from 'vs/workbench/common/editor';
import { URI } from 'vs/base/common/uri';
import { TestLifecycleService, TestContextService, TestStorageService } from 'vs/workbench/test/workbenchTestServices';
import { TestLifecycleService, TestContextService, TestStorageService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -61,13 +61,12 @@ function groupListener(group: EditorGroup): GroupEvents {
disposed: []
};
group.onDidEditorOpen(e => groupEvents.opened.push(e));
group.onDidEditorClose(e => groupEvents.closed.push(e));
group.onDidEditorActivate(e => groupEvents.activated.push(e));
group.onDidEditorPin(e => groupEvents.pinned.push(e));
group.onDidEditorUnpin(e => groupEvents.unpinned.push(e));
group.onDidEditorMove(e => groupEvents.moved.push(e));
group.onDidEditorDispose(e => groupEvents.disposed.push(e));
group.onDidOpenEditor(e => groupEvents.opened.push(e));
group.onDidCloseEditor(e => groupEvents.closed.push(e));
group.onDidActivateEditor(e => groupEvents.activated.push(e));
group.onDidChangeEditorPinned(e => group.isPinned(e) ? groupEvents.pinned.push(e) : groupEvents.unpinned.push(e));
group.onDidMoveEditor(e => groupEvents.moved.push(e));
group.onDidDisposeEditor(e => groupEvents.disposed.push(e));
return groupEvents;
}
@@ -1340,12 +1339,12 @@ suite('Workbench editor groups', () => {
group2.openEditor(input2, { pinned: true, active: true });
let dirty1Counter = 0;
group1.onDidEditorBecomeDirty(() => {
group1.onDidChangeEditorDirty(() => {
dirty1Counter++;
});
let dirty2Counter = 0;
group2.onDidEditorBecomeDirty(() => {
group2.onDidChangeEditorDirty(() => {
dirty2Counter++;
});

View File

@@ -17,7 +17,7 @@ import { ITextBufferFactory } from 'vs/editor/common/model';
import { URI } from 'vs/base/common/uri';
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
import { TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
import { TestTextResourcePropertiesService } from 'vs/workbench/test/browser/workbenchTestServices';
class MyEditorModel extends EditorModel { }
class MyTextEditorModel extends BaseTextEditorModel {

View File

@@ -6,7 +6,7 @@
import * as assert from 'assert';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { URI } from 'vs/base/common/uri';
import { workbenchInstantiationService, TestEditorService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService, TestEditorService } from 'vs/workbench/test/browser/workbenchTestServices';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService';
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';

View File

@@ -8,7 +8,7 @@ import { URI } from 'vs/base/common/uri';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { ResourceEditorModel } from 'vs/workbench/common/editor/resourceEditorModel';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService';
import { snapshotToString } from 'vs/workbench/services/textfile/common/textfiles';
@@ -21,7 +21,7 @@ class ServiceAccessor {
) { }
}
suite('Workbench resource editor input', () => {
suite('Resource text editors', () => {
let instantiationService: IInstantiationService;
let accessor: ServiceAccessor;
@@ -59,4 +59,4 @@ suite('Workbench resource editor input', () => {
input.setMode('text');
assert.equal(model.textEditorModel.getModeId(), PLAINTEXT_MODE_ID);
});
});
});

View File

@@ -9,7 +9,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { workbenchInstantiationService, TestEditorService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService, TestEditorService } from 'vs/workbench/test/browser/workbenchTestServices';
import { IModeService } from 'vs/editor/common/services/modeService';
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
import { snapshotToString } from 'vs/workbench/services/textfile/common/textfiles';
@@ -29,7 +29,7 @@ class ServiceAccessor {
) { }
}
suite('Workbench untitled text editors', () => {
suite('Untitled text editors', () => {
let instantiationService: IInstantiationService;
let accessor: ServiceAccessor;
@@ -394,23 +394,29 @@ suite('Workbench untitled text editors', () => {
model.textEditorModel.setValue('foo');
assert.equal(input.getName(), 'foo');
assert.equal(model.name, 'foo');
assert.equal(counter, 1);
model.textEditorModel.setValue('bar');
assert.equal(input.getName(), 'bar');
assert.equal(model.name, 'bar');
assert.equal(counter, 2);
model.textEditorModel.setValue('');
assert.equal(input.getName(), 'Untitled-1');
assert.equal(model.name, 'Untitled-1');
model.textEditorModel.setValue(' ');
assert.equal(input.getName(), 'Untitled-1');
assert.equal(model.name, 'Untitled-1');
model.textEditorModel.setValue('([]}'); // require actual words
assert.equal(input.getName(), 'Untitled-1');
assert.equal(model.name, 'Untitled-1');
model.textEditorModel.setValue('([]}hello '); // require actual words
assert.equal(input.getName(), '([]}hello');
assert.equal(model.name, '([]}hello');
assert.equal(counter, 4);
@@ -467,4 +473,24 @@ suite('Workbench untitled text editors', () => {
input.dispose();
model.dispose();
});
test('model#onDidChangeEncoding', async function () {
const service = accessor.untitledTextEditorService;
const input = service.create();
let counter = 0;
const model = await input.resolve();
model.onDidChangeEncoding(() => counter++);
model.setEncoding('utf16');
assert.equal(counter, 1, 'Dirty model should trigger event');
model.setEncoding('utf16');
assert.equal(counter, 1, 'Another change to same encoding does not fire event');
input.dispose();
model.dispose();
});
});

View File

@@ -5,17 +5,18 @@
import * as assert from 'assert';
import { ContributableViewsModel, IViewState } from 'vs/workbench/browser/parts/views/views';
import { IViewsRegistry, IViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions, IViewDescriptorService, ViewContainerLocation } from 'vs/workbench/common/views';
import { IViewsRegistry, IViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions, IViewDescriptorService, ViewContainerLocation, ViewContainer } from 'vs/workbench/common/views';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { move } from 'vs/base/common/arrays';
import { Registry } from 'vs/platform/registry/common/platform';
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
import sinon = require('sinon');
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ViewDescriptorService } from 'vs/workbench/services/views/browser/viewDescriptorService';
import { assertIsDefined } from 'vs/base/common/types';
const container = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({ id: 'test', name: 'test', ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Sidebar);
const ViewsRegistry = Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry);
@@ -374,3 +375,254 @@ suite('ContributableViewsModel', () => {
});
});
const sidebarContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({ id: 'testSidebar', name: 'test', ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Sidebar);
const panelContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({ id: 'testPanel', name: 'test', ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Panel);
suite('ViewDescriptorService', () => {
let viewDescriptorService: IViewDescriptorService;
setup(() => {
const instantiationService: TestInstantiationService = <TestInstantiationService>workbenchInstantiationService();
viewDescriptorService = instantiationService.createInstance(ViewDescriptorService);
});
teardown(() => {
ViewsRegistry.deregisterViews(ViewsRegistry.getViews(sidebarContainer), sidebarContainer);
ViewsRegistry.deregisterViews(ViewsRegistry.getViews(panelContainer), panelContainer);
});
test('Empty Containers', function () {
const sidebarViews = viewDescriptorService.getViewDescriptors(sidebarContainer);
const panelViews = viewDescriptorService.getViewDescriptors(panelContainer);
assert.equal(sidebarViews.allViewDescriptors.length, 0, 'The sidebar container should have no views yet.');
assert.equal(panelViews.allViewDescriptors.length, 0, 'The panel container should have no views yet.');
});
test('Register/Deregister', () => {
const viewDescriptors: IViewDescriptor[] = [
{
id: 'view1',
ctorDescriptor: null!,
name: 'Test View 1',
canMoveView: true
},
{
id: 'view2',
ctorDescriptor: null!,
name: 'Test View 2',
canMoveView: true
},
{
id: 'view3',
ctorDescriptor: null!,
name: 'Test View 3',
canMoveView: true
}
];
ViewsRegistry.registerViews(viewDescriptors.slice(0, 2), sidebarContainer);
ViewsRegistry.registerViews(viewDescriptors.slice(2), panelContainer);
let sidebarViews = viewDescriptorService.getViewDescriptors(sidebarContainer);
let panelViews = viewDescriptorService.getViewDescriptors(panelContainer);
assert.equal(sidebarViews.activeViewDescriptors.length, 2, 'Sidebar should have 2 views');
assert.equal(panelViews.activeViewDescriptors.length, 1, 'Panel should have 1 view');
ViewsRegistry.deregisterViews(viewDescriptors.slice(0, 2), sidebarContainer);
ViewsRegistry.deregisterViews(viewDescriptors.slice(2), panelContainer);
sidebarViews = viewDescriptorService.getViewDescriptors(sidebarContainer);
panelViews = viewDescriptorService.getViewDescriptors(panelContainer);
assert.equal(sidebarViews.activeViewDescriptors.length, 0, 'Sidebar should have no views');
assert.equal(panelViews.activeViewDescriptors.length, 0, 'Panel should have no views');
});
test('move views to existing containers', async function () {
const viewDescriptors: IViewDescriptor[] = [
{
id: 'view1',
ctorDescriptor: null!,
name: 'Test View 1',
canMoveView: true
},
{
id: 'view2',
ctorDescriptor: null!,
name: 'Test View 2',
canMoveView: true
},
{
id: 'view3',
ctorDescriptor: null!,
name: 'Test View 3',
canMoveView: true
}
];
ViewsRegistry.registerViews(viewDescriptors.slice(0, 2), sidebarContainer);
ViewsRegistry.registerViews(viewDescriptors.slice(2), panelContainer);
viewDescriptorService.moveViewsToContainer(viewDescriptors.slice(2), sidebarContainer);
viewDescriptorService.moveViewsToContainer(viewDescriptors.slice(0, 2), panelContainer);
let sidebarViews = viewDescriptorService.getViewDescriptors(sidebarContainer);
let panelViews = viewDescriptorService.getViewDescriptors(panelContainer);
assert.equal(sidebarViews.activeViewDescriptors.length, 1, 'Sidebar should have 2 views');
assert.equal(panelViews.activeViewDescriptors.length, 2, 'Panel should have 1 view');
assert.notEqual(sidebarViews.activeViewDescriptors.indexOf(viewDescriptors[2]), -1, `Sidebar should have ${viewDescriptors[2].name}`);
assert.notEqual(panelViews.activeViewDescriptors.indexOf(viewDescriptors[0]), -1, `Panel should have ${viewDescriptors[0].name}`);
assert.notEqual(panelViews.activeViewDescriptors.indexOf(viewDescriptors[1]), -1, `Panel should have ${viewDescriptors[1].name}`);
});
test('move views to generated containers', async function () {
const viewDescriptors: IViewDescriptor[] = [
{
id: 'view1',
ctorDescriptor: null!,
name: 'Test View 1',
canMoveView: true
},
{
id: 'view2',
ctorDescriptor: null!,
name: 'Test View 2',
canMoveView: true
},
{
id: 'view3',
ctorDescriptor: null!,
name: 'Test View 3',
canMoveView: true
}
];
ViewsRegistry.registerViews(viewDescriptors.slice(0, 2), sidebarContainer);
ViewsRegistry.registerViews(viewDescriptors.slice(2), panelContainer);
viewDescriptorService.moveViewToLocation(viewDescriptors[0], ViewContainerLocation.Panel);
viewDescriptorService.moveViewToLocation(viewDescriptors[2], ViewContainerLocation.Sidebar);
let sidebarViews = viewDescriptorService.getViewDescriptors(sidebarContainer);
let panelViews = viewDescriptorService.getViewDescriptors(panelContainer);
assert.equal(sidebarViews.activeViewDescriptors.length, 1, 'Sidebar container should have 1 view');
assert.equal(panelViews.activeViewDescriptors.length, 0, 'Panel container should have no views');
const generatedPanel = assertIsDefined(viewDescriptorService.getViewContainer(viewDescriptors[0].id));
const generatedSidebar = assertIsDefined(viewDescriptorService.getViewContainer(viewDescriptors[2].id));
assert.equal(viewDescriptorService.getViewContainerLocation(generatedPanel), ViewContainerLocation.Panel, 'Generated Panel should be in located in the panel');
assert.equal(viewDescriptorService.getViewContainerLocation(generatedSidebar), ViewContainerLocation.Sidebar, 'Generated Sidebar should be in located in the sidebar');
assert.equal(viewDescriptorService.getViewContainerLocation(generatedPanel), viewDescriptorService.getViewLocation(viewDescriptors[0].id), 'Panel view location and container location should match');
assert.equal(viewDescriptorService.getViewContainerLocation(generatedSidebar), viewDescriptorService.getViewLocation(viewDescriptors[2].id), 'Sidebar view location and container location should match');
assert.equal(viewDescriptorService.getDefaultContainer(viewDescriptors[2].id), panelContainer, `${viewDescriptors[2].name} has wrong default container`);
assert.equal(viewDescriptorService.getDefaultContainer(viewDescriptors[0].id), sidebarContainer, `${viewDescriptors[0].name} has wrong default container`);
viewDescriptorService.moveViewToLocation(viewDescriptors[0], ViewContainerLocation.Sidebar);
viewDescriptorService.moveViewToLocation(viewDescriptors[2], ViewContainerLocation.Panel);
sidebarViews = viewDescriptorService.getViewDescriptors(sidebarContainer);
panelViews = viewDescriptorService.getViewDescriptors(panelContainer);
assert.equal(sidebarViews.activeViewDescriptors.length, 2, 'Sidebar should have 2 views');
assert.equal(panelViews.activeViewDescriptors.length, 1, 'Panel should have 1 view');
assert.equal(viewDescriptorService.getViewLocation(viewDescriptors[0].id), ViewContainerLocation.Sidebar, 'View should be located in the sidebar');
assert.equal(viewDescriptorService.getViewLocation(viewDescriptors[2].id), ViewContainerLocation.Panel, 'View should be located in the panel');
});
test('move view events', async function () {
const viewDescriptors: IViewDescriptor[] = [
{
id: 'view1',
ctorDescriptor: null!,
name: 'Test View 1',
canMoveView: true
},
{
id: 'view2',
ctorDescriptor: null!,
name: 'Test View 2',
canMoveView: true
},
{
id: 'view3',
ctorDescriptor: null!,
name: 'Test View 3',
canMoveView: true
}
];
let expectedSequence = '';
let actualSequence = '';
const disposables = [];
const containerMoveString = (view: IViewDescriptor, from: ViewContainer, to: ViewContainer) => {
return `Moved ${view.id} from ${from.id} to ${to.id}\n`;
};
const locationMoveString = (view: IViewDescriptor, from: ViewContainerLocation, to: ViewContainerLocation) => {
return `Moved ${view.id} from ${from === ViewContainerLocation.Sidebar ? 'Sidebar' : 'Panel'} to ${to === ViewContainerLocation.Sidebar ? 'Sidebar' : 'Panel'}\n`;
};
disposables.push(viewDescriptorService.onDidChangeContainer(({ views, from, to }) => {
views.forEach(view => {
actualSequence += containerMoveString(view, from, to);
});
}));
disposables.push(viewDescriptorService.onDidChangeLocation(({ views, from, to }) => {
views.forEach(view => {
actualSequence += locationMoveString(view, from, to);
});
}));
ViewsRegistry.registerViews(viewDescriptors.slice(0, 2), sidebarContainer);
ViewsRegistry.registerViews(viewDescriptors.slice(2), panelContainer);
expectedSequence += locationMoveString(viewDescriptors[0], ViewContainerLocation.Sidebar, ViewContainerLocation.Panel);
viewDescriptorService.moveViewToLocation(viewDescriptors[0], ViewContainerLocation.Panel);
expectedSequence += containerMoveString(viewDescriptors[0], sidebarContainer, viewDescriptorService.getViewContainer(viewDescriptors[0].id)!);
expectedSequence += locationMoveString(viewDescriptors[2], ViewContainerLocation.Panel, ViewContainerLocation.Sidebar);
viewDescriptorService.moveViewToLocation(viewDescriptors[2], ViewContainerLocation.Sidebar);
expectedSequence += containerMoveString(viewDescriptors[2], panelContainer, viewDescriptorService.getViewContainer(viewDescriptors[2].id)!);
expectedSequence += locationMoveString(viewDescriptors[0], ViewContainerLocation.Panel, ViewContainerLocation.Sidebar);
expectedSequence += containerMoveString(viewDescriptors[0], viewDescriptorService.getViewContainer(viewDescriptors[0].id)!, sidebarContainer);
viewDescriptorService.moveViewToLocation(viewDescriptors[0], ViewContainerLocation.Sidebar);
expectedSequence += locationMoveString(viewDescriptors[2], ViewContainerLocation.Sidebar, ViewContainerLocation.Panel);
expectedSequence += containerMoveString(viewDescriptors[2], viewDescriptorService.getViewContainer(viewDescriptors[2].id)!, panelContainer);
viewDescriptorService.moveViewToLocation(viewDescriptors[2], ViewContainerLocation.Panel);
expectedSequence += locationMoveString(viewDescriptors[0], ViewContainerLocation.Sidebar, ViewContainerLocation.Panel);
expectedSequence += containerMoveString(viewDescriptors[0], sidebarContainer, panelContainer);
viewDescriptorService.moveViewsToContainer([viewDescriptors[0]], panelContainer);
expectedSequence += locationMoveString(viewDescriptors[2], ViewContainerLocation.Panel, ViewContainerLocation.Sidebar);
expectedSequence += containerMoveString(viewDescriptors[2], panelContainer, sidebarContainer);
viewDescriptorService.moveViewsToContainer([viewDescriptors[2]], sidebarContainer);
expectedSequence += locationMoveString(viewDescriptors[1], ViewContainerLocation.Sidebar, ViewContainerLocation.Panel);
expectedSequence += locationMoveString(viewDescriptors[2], ViewContainerLocation.Sidebar, ViewContainerLocation.Panel);
expectedSequence += containerMoveString(viewDescriptors[1], sidebarContainer, panelContainer);
expectedSequence += containerMoveString(viewDescriptors[2], sidebarContainer, panelContainer);
viewDescriptorService.moveViewsToContainer([viewDescriptors[1], viewDescriptors[2]], panelContainer);
assert.equal(actualSequence, expectedSequence, 'Event sequence not matching expected sequence');
});
});

View File

@@ -7,7 +7,7 @@ import * as assert from 'assert';
import { StorageScope, IStorageService } from 'vs/platform/storage/common/storage';
import { Memento } from 'vs/workbench/common/memento';
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
suite('Memento', () => {
let context: StorageScope | undefined = undefined;
@@ -177,4 +177,4 @@ suite('Memento', () => {
memento = myMemento2.getMemento(StorageScope.WORKSPACE);
assert.deepEqual(memento, { foo: 'Hello World', bar: 'Hello World' });
});
});
});

View File

@@ -0,0 +1,137 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { join } from 'vs/base/common/path';
import * as resources from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { Event, Emitter } from 'vs/base/common/event';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkspaceContextService, IWorkspace as IWorkbenchWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, Workspace } from 'vs/platform/workspace/common/workspace';
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
import { isLinux, isMacintosh } from 'vs/base/common/platform';
import { InMemoryStorageService, IWillSaveStateEvent } from 'vs/platform/storage/common/storage';
import { WorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {
_serviceBrand: undefined;
constructor(
@IConfigurationService private readonly configurationService: IConfigurationService,
) {
}
getEOL(resource: URI, language?: string): string {
const eol = this.configurationService.getValue<string>('files.eol', { overrideIdentifier: language, resource });
if (eol && eol !== 'auto') {
return eol;
}
return (isLinux || isMacintosh) ? '\n' : '\r\n';
}
}
export class TestContextService implements IWorkspaceContextService {
_serviceBrand: undefined;
private workspace: Workspace;
private options: any;
private readonly _onDidChangeWorkspaceName: Emitter<void>;
private readonly _onDidChangeWorkspaceFolders: Emitter<IWorkspaceFoldersChangeEvent>;
private readonly _onDidChangeWorkbenchState: Emitter<WorkbenchState>;
constructor(workspace: any = TestWorkspace, options: any = null) {
this.workspace = workspace;
this.options = options || Object.create(null);
this._onDidChangeWorkspaceName = new Emitter<void>();
this._onDidChangeWorkspaceFolders = new Emitter<IWorkspaceFoldersChangeEvent>();
this._onDidChangeWorkbenchState = new Emitter<WorkbenchState>();
}
get onDidChangeWorkspaceName(): Event<void> {
return this._onDidChangeWorkspaceName.event;
}
get onDidChangeWorkspaceFolders(): Event<IWorkspaceFoldersChangeEvent> {
return this._onDidChangeWorkspaceFolders.event;
}
get onDidChangeWorkbenchState(): Event<WorkbenchState> {
return this._onDidChangeWorkbenchState.event;
}
getFolders(): IWorkspaceFolder[] {
return this.workspace ? this.workspace.folders : [];
}
getWorkbenchState(): WorkbenchState {
if (this.workspace.configuration) {
return WorkbenchState.WORKSPACE;
}
if (this.workspace.folders.length) {
return WorkbenchState.FOLDER;
}
return WorkbenchState.EMPTY;
}
getCompleteWorkspace(): Promise<IWorkbenchWorkspace> {
return Promise.resolve(this.getWorkspace());
}
getWorkspace(): IWorkbenchWorkspace {
return this.workspace;
}
getWorkspaceFolder(resource: URI): IWorkspaceFolder | null {
return this.workspace.getFolder(resource);
}
setWorkspace(workspace: any): void {
this.workspace = workspace;
}
getOptions() {
return this.options;
}
updateOptions() {
}
isInsideWorkspace(resource: URI): boolean {
if (resource && this.workspace) {
return resources.isEqualOrParent(resource, this.workspace.folders[0].uri);
}
return false;
}
toResource(workspaceRelativePath: string): URI {
return URI.file(join('C:\\', workspaceRelativePath));
}
isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean {
return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && resources.isEqual(this.workspace.folders[0].uri, workspaceIdentifier);
}
}
export class TestStorageService extends InMemoryStorageService {
readonly _onWillSaveState = this._register(new Emitter<IWillSaveStateEvent>());
readonly onWillSaveState = this._onWillSaveState.event;
}
export class TestWorkingCopyService extends WorkingCopyService { }
export function mock<T>(): Ctor<T> {
return function () { } as any;
}
export interface Ctor<T> {
new(): T;
}

View File

@@ -1,76 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { isURLDomainTrusted } from 'vs/workbench/contrib/url/common/trustedDomainsValidator';
import { URI } from 'vs/base/common/uri';
function linkAllowedByRules(link: string, rules: string[]) {
assert.ok(isURLDomainTrusted(URI.parse(link), rules), `Link\n${link}\n should be protected by rules\n${JSON.stringify(rules)}`);
}
function linkNotAllowedByRules(link: string, rules: string[]) {
assert.ok(!isURLDomainTrusted(URI.parse(link), rules), `Link\n${link}\n should NOT be protected by rules\n${JSON.stringify(rules)}`);
}
suite('Link protection domain matching', () => {
test('simple', () => {
linkNotAllowedByRules('https://x.org', []);
linkAllowedByRules('https://x.org', ['https://x.org']);
linkAllowedByRules('https://x.org/foo', ['https://x.org']);
linkNotAllowedByRules('https://x.org', ['http://x.org']);
linkNotAllowedByRules('http://x.org', ['https://x.org']);
linkNotAllowedByRules('https://www.x.org', ['https://x.org']);
linkAllowedByRules('https://www.x.org', ['https://www.x.org', 'https://y.org']);
});
test('localhost', () => {
linkAllowedByRules('https://127.0.0.1', []);
linkAllowedByRules('https://127.0.0.1:3000', []);
linkAllowedByRules('https://localhost', []);
linkAllowedByRules('https://localhost:3000', []);
});
test('* star', () => {
linkAllowedByRules('https://a.x.org', ['https://*.x.org']);
linkAllowedByRules('https://a.b.x.org', ['https://*.x.org']);
linkAllowedByRules('https://a.x.org', ['https://a.x.*']);
linkAllowedByRules('https://a.x.org', ['https://a.*.org']);
linkAllowedByRules('https://a.x.org', ['https://*.*.org']);
linkAllowedByRules('https://a.b.x.org', ['https://*.b.*.org']);
linkAllowedByRules('https://a.a.b.x.org', ['https://*.b.*.org']);
});
test('no scheme', () => {
linkAllowedByRules('https://a.x.org', ['a.x.org']);
linkAllowedByRules('https://a.x.org', ['*.x.org']);
linkAllowedByRules('https://a.b.x.org', ['*.x.org']);
linkAllowedByRules('https://x.org', ['*.x.org']);
});
test('sub paths', () => {
linkAllowedByRules('https://x.org/foo', ['https://x.org/foo']);
linkAllowedByRules('https://x.org/foo', ['x.org/foo']);
linkAllowedByRules('https://x.org/foo', ['*.org/foo']);
linkNotAllowedByRules('https://x.org/bar', ['https://x.org/foo']);
linkNotAllowedByRules('https://x.org/bar', ['x.org/foo']);
linkNotAllowedByRules('https://x.org/bar', ['*.org/foo']);
linkAllowedByRules('https://x.org/foo/bar', ['https://x.org/foo']);
linkNotAllowedByRules('https://x.org/foo2', ['https://x.org/foo']);
linkNotAllowedByRules('https://www.x.org/foo', ['https://x.org/foo']);
linkNotAllowedByRules('https://a.x.org/bar', ['https://*.x.org/foo']);
linkNotAllowedByRules('https://a.b.x.org/bar', ['https://*.x.org/foo']);
linkAllowedByRules('https://github.com', ['https://github.com/foo/bar', 'https://github.com']);
});
});

View File

@@ -15,11 +15,11 @@ import { MainContext, MainThreadSearchShape } from 'vs/workbench/api/common/extH
import { NativeExtHostSearch } from 'vs/workbench/api/node/extHostSearch';
import { Range } from 'vs/workbench/api/common/extHostTypes';
import { IFileMatch, IFileQuery, IPatternInfo, IRawFileMatch2, ISearchCompleteStats, ISearchQuery, ITextQuery, QueryType, resultIsMatch } from 'vs/workbench/services/search/common/search';
import { TestRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
import { TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
import type * as vscode from 'vscode';
import { NullLogService } from 'vs/platform/log/common/log';
import { URITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { mock } from 'vs/workbench/test/browser/api/mock';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { TextSearchManager } from 'vs/workbench/services/search/common/textSearchManager';
import { NativeTextSearchManager } from 'vs/workbench/services/search/node/textSearchManager';

View File

@@ -7,7 +7,7 @@ import * as assert from 'assert';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { FinalNewLineParticipant, TrimFinalNewLinesParticipant } from 'vs/workbench/api/browser/mainThreadSaveParticipant';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { workbenchInstantiationService, TestTextFileService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService, TestTextFileService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
import { toResource } from 'vs/base/test/common/utils';
import { IModelService } from 'vs/editor/common/services/modelService';
import { Range } from 'vs/editor/common/core/range';
@@ -34,7 +34,6 @@ suite('MainThreadSaveParticipant', function () {
teardown(() => {
(<TextFileEditorModelManager>accessor.textFileService.files).dispose();
TextFileEditorModel.setSaveParticipant(null); // reset any set participant
});
test('insert final new line', async function () {

View File

@@ -3,12 +3,12 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { ISearchService, IFileQuery } from 'vs/workbench/services/search/common/search';
import { MainThreadWorkspace } from 'vs/workbench/api/browser/mainThreadWorkspace';
import * as assert from 'assert';
import { SingleProxyRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
import { SingleProxyRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';

View File

@@ -28,7 +28,8 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { LocalSearchService } from 'vs/workbench/services/search/node/searchService';
import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
import { TestContextService, TestEditorGroupsService, TestEditorService, TestEnvironmentService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
import { TestContextService, TestEditorGroupsService, TestEditorService, TestTextResourcePropertiesService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestEnvironmentService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { NullLogService } from 'vs/platform/log/common/log';

View File

@@ -17,7 +17,8 @@ import * as minimist from 'vscode-minimist';
import * as path from 'vs/base/common/path';
import { LocalSearchService } from 'vs/workbench/services/search/node/searchService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { TestEnvironmentService, TestContextService, TestEditorService, TestEditorGroupsService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
import { TestContextService, TestEditorService, TestEditorGroupsService, TestTextResourcePropertiesService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestEnvironmentService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { URI } from 'vs/base/common/uri';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';

View File

@@ -0,0 +1,189 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { workbenchInstantiationService as browserWorkbenchInstantiationService, ITestInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { Event } from 'vs/base/common/event';
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { NativeTextFileService } from 'vs/workbench/services/textfile/electron-browser/nativeTextFileService';
import { IElectronService } from 'vs/platform/electron/node/electron';
import { INativeOpenDialogOptions } from 'vs/platform/dialogs/node/dialogs';
import { FileOperationError, IFileService } from 'vs/platform/files/common/files';
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IDialogService, IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfigurationService';
import { IProductService } from 'vs/platform/product/common/productService';
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { URI } from 'vs/base/common/uri';
import { IReadTextFileOptions, ITextFileStreamContent, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { createTextBufferFactoryFromStream } from 'vs/editor/common/model/textModel';
import { IOpenedWindow, IOpenEmptyWindowOptions, IWindowOpenable, IOpenWindowOptions, IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { LogLevel } from 'vs/platform/log/common/log';
import { IRemotePathService } from 'vs/workbench/services/path/common/remotePathService';
export const TestWindowConfiguration: IWindowConfiguration = {
windowId: 0,
sessionId: 'testSessionId',
logLevel: LogLevel.Error,
mainPid: 0,
appRoot: '',
userEnv: {},
execPath: process.execPath,
perfEntries: [],
...parseArgs(process.argv, OPTIONS)
};
export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestWindowConfiguration, process.execPath, 0);
export class TestTextFileService extends NativeTextFileService {
private resolveTextContentError!: FileOperationError | null;
constructor(
@IFileService protected fileService: IFileService,
@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService,
@ILifecycleService lifecycleService: ILifecycleService,
@IInstantiationService instantiationService: IInstantiationService,
@IModelService modelService: IModelService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IDialogService dialogService: IDialogService,
@IFileDialogService fileDialogService: IFileDialogService,
@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,
@IProductService productService: IProductService,
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService,
@ITextModelService textModelService: ITextModelService,
@ICodeEditorService codeEditorService: ICodeEditorService,
@INotificationService notificationService: INotificationService,
@IRemotePathService remotePathService: IRemotePathService
) {
super(
fileService,
untitledTextEditorService,
lifecycleService,
instantiationService,
modelService,
environmentService,
dialogService,
fileDialogService,
textResourceConfigurationService,
productService,
filesConfigurationService,
textModelService,
codeEditorService,
notificationService,
remotePathService
);
}
setResolveTextContentErrorOnce(error: FileOperationError): void {
this.resolveTextContentError = error;
}
async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {
if (this.resolveTextContentError) {
const error = this.resolveTextContentError;
this.resolveTextContentError = null;
throw error;
}
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
};
}
}
export class TestSharedProcessService implements ISharedProcessService {
_serviceBrand: undefined;
getChannel(channelName: string): any { return undefined; }
registerChannel(channelName: string, channel: any): void { }
async toggleSharedProcessWindow(): Promise<void> { }
async whenSharedProcessReady(): 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.');
}
async toggleFullScreen(): Promise<void> { }
async handleTitleDoubleClick(): Promise<void> { }
async isMaximized(): Promise<boolean> { return true; }
async maximizeWindow(): Promise<void> { }
async unmaximizeWindow(): Promise<void> { }
async minimizeWindow(): Promise<void> { }
async focusWindow(options?: { windowId?: number | undefined; } | undefined): Promise<void> { }
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.'); }
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; }
async updateTouchBar(): Promise<void> { }
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; }
}
export function workbenchInstantiationService(): ITestInstantiationService {
const instantiationService = browserWorkbenchInstantiationService({
textFileService: insta => <ITextFileService>insta.createInstance(TestTextFileService)
});
instantiationService.stub(IElectronService, new TestElectronService());
return instantiationService;
}