move to browser namespace
This commit is contained in:
parent
2d892ae9c7
commit
56e0512769
4 changed files with 64 additions and 109 deletions
|
@ -9,8 +9,7 @@ import * as json from 'vs/base/common/json';
|
|||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { TestProductService, workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestWorkbenchConfiguration, TestTextFileService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
|
||||
import { TestEnvironmentService, TestTextFileService, workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService';
|
||||
|
@ -32,37 +31,22 @@ import { NullLogService } from 'vs/platform/log/common/log';
|
|||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { KeybindingsEditingService, IKeybindingEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing';
|
||||
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
|
||||
import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentityService';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { InMemoryFileSystemProvider } from 'vs/platform/files/common/inMemoryFilesystemProvider';
|
||||
import { ConfigurationCache as NativeConfigurationCache } from 'vs/workbench/services/configuration/electron-browser/configurationCache';
|
||||
import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
|
||||
class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
|
||||
|
||||
constructor(private _appSettingsHome: URI) {
|
||||
super(TestWorkbenchConfiguration, TestProductService);
|
||||
}
|
||||
|
||||
get appSettingsHome() { return this._appSettingsHome; }
|
||||
}
|
||||
|
||||
class ConfigurationCache extends NativeConfigurationCache {
|
||||
needsCaching(resource: URI): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
import { ConfigurationCache } from 'vs/workbench/services/configuration/browser/configurationCache';
|
||||
import { RemoteAgentService } from 'vs/workbench/services/remote/browser/remoteAgentServiceImpl';
|
||||
import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
|
||||
|
||||
const ROOT = URI.file('tests').with({ scheme: 'vscode-tests' });
|
||||
|
||||
suite('ConfigurationEditingService', () => {
|
||||
|
||||
let instantiationService: TestInstantiationService;
|
||||
let environmentService: NativeWorkbenchEnvironmentService;
|
||||
let environmentService: BrowserWorkbenchEnvironmentService;
|
||||
let fileService: IFileService;
|
||||
let workspaceService: WorkspaceService;
|
||||
let testObject: ConfigurationEditingService;
|
||||
|
@ -101,13 +85,13 @@ suite('ConfigurationEditingService', () => {
|
|||
await fileService.createFolder(workspaceFolder);
|
||||
|
||||
instantiationService = <TestInstantiationService>workbenchInstantiationService(undefined, disposables);
|
||||
environmentService = new TestWorkbenchEnvironmentService(workspaceFolder);
|
||||
environmentService = TestEnvironmentService;
|
||||
instantiationService.stub(IEnvironmentService, environmentService);
|
||||
const remoteAgentService = disposables.add(instantiationService.createInstance(RemoteAgentService));
|
||||
const remoteAgentService = disposables.add(instantiationService.createInstance(RemoteAgentService, null));
|
||||
disposables.add(fileService.registerProvider(Schemas.userData, disposables.add(new FileUserDataProvider(ROOT.scheme, fileSystemProvider, Schemas.userData, logService))));
|
||||
instantiationService.stub(IFileService, fileService);
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
workspaceService = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache(ROOT, fileService) }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
workspaceService = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache() }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceService);
|
||||
|
||||
await workspaceService.initialize({ folder: workspaceFolder, id: createHash('md5').update(workspaceFolder.toString()).digest('hex') });
|
||||
|
@ -151,7 +135,7 @@ suite('ConfigurationEditingService', () => {
|
|||
});
|
||||
|
||||
test('errors cases - invalid global tasks configuration', async () => {
|
||||
const resource = joinPath(environmentService.appSettingsHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
const resource = joinPath(environmentService.userRoamingDataHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
await fileService.writeFile(resource, VSBuffer.fromString(',,,,,,,,,,,,,,'));
|
||||
try {
|
||||
await testObject.writeConfiguration(EditableConfigurationTarget.USER_LOCAL, { key: 'tasks.configurationEditing.service.testSetting', value: 'value' });
|
||||
|
@ -267,7 +251,7 @@ suite('ConfigurationEditingService', () => {
|
|||
});
|
||||
|
||||
test('write user standalone setting - empty file', async () => {
|
||||
const target = joinPath(environmentService.appSettingsHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
const target = joinPath(environmentService.userRoamingDataHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
await testObject.writeConfiguration(EditableConfigurationTarget.USER_LOCAL, { key: 'tasks.service.testSetting', value: 'value' });
|
||||
|
||||
const contents = await fileService.readFile(target);
|
||||
|
@ -288,7 +272,7 @@ suite('ConfigurationEditingService', () => {
|
|||
});
|
||||
|
||||
test('write user standalone setting - existing file', async () => {
|
||||
const target = joinPath(environmentService.appSettingsHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
const target = joinPath(environmentService.userRoamingDataHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
await fileService.writeFile(target, VSBuffer.fromString('{ "my.super.setting": "my.super.value" }'));
|
||||
|
||||
await testObject.writeConfiguration(EditableConfigurationTarget.USER_LOCAL, { key: 'tasks.service.testSetting', value: 'value' });
|
||||
|
@ -312,7 +296,7 @@ suite('ConfigurationEditingService', () => {
|
|||
test('write user standalone setting - empty file - full JSON', async () => {
|
||||
await testObject.writeConfiguration(EditableConfigurationTarget.USER_LOCAL, { key: 'tasks', value: { 'version': '1.0.0', tasks: [{ 'taskName': 'myTask' }] } });
|
||||
|
||||
const target = joinPath(environmentService.appSettingsHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
const target = joinPath(environmentService.userRoamingDataHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
const contents = await fileService.readFile(target);
|
||||
const parsed = json.parse(contents.value.toString());
|
||||
assert.equal(parsed['version'], '1.0.0');
|
||||
|
@ -332,7 +316,7 @@ suite('ConfigurationEditingService', () => {
|
|||
});
|
||||
|
||||
test('write user standalone setting - existing file - full JSON', async () => {
|
||||
const target = joinPath(environmentService.appSettingsHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
const target = joinPath(environmentService.userRoamingDataHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
await fileService.writeFile(target, VSBuffer.fromString('{ "my.super.setting": "my.super.value" }'));
|
||||
|
||||
await testObject.writeConfiguration(EditableConfigurationTarget.USER_LOCAL, { key: 'tasks', value: { 'version': '1.0.0', tasks: [{ 'taskName': 'myTask' }] } });
|
||||
|
@ -356,7 +340,7 @@ suite('ConfigurationEditingService', () => {
|
|||
});
|
||||
|
||||
test('write user standalone setting - existing file with JSON errors - full JSON', async () => {
|
||||
const target = joinPath(environmentService.appSettingsHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
const target = joinPath(environmentService.userRoamingDataHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
await fileService.writeFile(target, VSBuffer.fromString('{ "my.super.setting": ')); // invalid JSON
|
||||
|
||||
await testObject.writeConfiguration(EditableConfigurationTarget.USER_LOCAL, { key: 'tasks', value: { 'version': '1.0.0', tasks: [{ 'taskName': 'myTask' }] } });
|
||||
|
@ -389,7 +373,7 @@ suite('ConfigurationEditingService', () => {
|
|||
});
|
||||
|
||||
test('write user standalone setting should replace complete file', async () => {
|
||||
const target = joinPath(environmentService.appSettingsHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
const target = joinPath(environmentService.userRoamingDataHome, USER_STANDALONE_CONFIGURATIONS['tasks']);
|
||||
await fileService.writeFile(target, VSBuffer.fromString(`{
|
||||
"version": "1.0.0",
|
||||
"tasks": [
|
|
@ -15,8 +15,7 @@ import { ConfigurationEditingErrorCode } from 'vs/workbench/services/configurati
|
|||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFoldersChangeEvent } from 'vs/platform/workspace/common/workspace';
|
||||
import { ConfigurationTarget, IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
|
||||
import { workbenchInstantiationService, RemoteFileSystemProvider, TestProductService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestWorkbenchConfiguration, TestTextFileService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
|
||||
import { workbenchInstantiationService, RemoteFileSystemProvider, TestProductService, TestEnvironmentService, TestTextFileService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
|
@ -27,44 +26,26 @@ import { createHash } from 'crypto';
|
|||
import { Schemas } from 'vs/base/common/network';
|
||||
import { joinPath, dirname, basename } from 'vs/base/common/resources';
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl';
|
||||
import { RemoteAuthorityResolverService } from 'vs/platform/remote/electron-sandbox/remoteAuthorityResolverService';
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
import { FileService } from 'vs/platform/files/common/fileService';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ConfigurationCache as NativeConfigurationCache } from 'vs/workbench/services/configuration/electron-browser/configurationCache';
|
||||
import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment';
|
||||
import { IConfigurationCache } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { SignService } from 'vs/platform/sign/browser/signService';
|
||||
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
|
||||
import { IKeybindingEditingService, KeybindingsEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing';
|
||||
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
|
||||
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentityService';
|
||||
import { InMemoryFileSystemProvider } from 'vs/platform/files/common/inMemoryFilesystemProvider';
|
||||
|
||||
class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
|
||||
|
||||
constructor(private _appSettingsHome: URI) {
|
||||
super(TestWorkbenchConfiguration, TestProductService);
|
||||
}
|
||||
|
||||
get appSettingsHome() { return this._appSettingsHome; }
|
||||
|
||||
}
|
||||
|
||||
class ConfigurationCache extends NativeConfigurationCache {
|
||||
needsCaching(resource: URI): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
import { ConfigurationCache as BrowserConfigurationCache } from 'vs/workbench/services/configuration/browser/configurationCache';
|
||||
import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
|
||||
import { RemoteAgentService } from 'vs/workbench/services/remote/browser/remoteAgentServiceImpl';
|
||||
import { RemoteAuthorityResolverService } from 'vs/platform/remote/browser/remoteAuthorityResolverService';
|
||||
|
||||
function convertToWorkspacePayload(folder: URI): ISingleFolderWorkspaceInitializationPayload {
|
||||
return {
|
||||
|
@ -73,6 +54,10 @@ function convertToWorkspacePayload(folder: URI): ISingleFolderWorkspaceInitializ
|
|||
} as ISingleFolderWorkspaceInitializationPayload;
|
||||
}
|
||||
|
||||
class ConfigurationCache extends BrowserConfigurationCache {
|
||||
needsCaching() { return false; }
|
||||
}
|
||||
|
||||
const ROOT = URI.file('tests').with({ scheme: 'vscode-tests' });
|
||||
|
||||
suite('WorkspaceContextService - Folder', () => {
|
||||
|
@ -89,9 +74,9 @@ suite('WorkspaceContextService - Folder', () => {
|
|||
folder = joinPath(ROOT, folderName);
|
||||
await fileService.createFolder(folder);
|
||||
|
||||
const environmentService = new TestWorkbenchEnvironmentService(folder);
|
||||
const environmentService = TestEnvironmentService;
|
||||
fileService.registerProvider(Schemas.userData, disposables.add(new FileUserDataProvider(ROOT.scheme, fileSystemProvider, Schemas.userData, new NullLogService())));
|
||||
testObject = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache(ROOT, fileService) }, environmentService, fileService, new RemoteAgentService(environmentService, { _serviceBrand: undefined, ...product }, new RemoteAuthorityResolverService(), new SignService(undefined), new NullLogService()), new UriIdentityService(fileService), new NullLogService()));
|
||||
testObject = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache() }, environmentService, fileService, new RemoteAgentService(null, environmentService, { _serviceBrand: undefined, ...product }, new RemoteAuthorityResolverService(undefined, undefined), new SignService(undefined), new NullLogService()), new UriIdentityService(fileService), new NullLogService()));
|
||||
await (<WorkspaceService>testObject).initialize(convertToWorkspacePayload(folder));
|
||||
});
|
||||
|
||||
|
@ -153,11 +138,11 @@ suite('WorkspaceContextService - Workspace', () => {
|
|||
await fileService.writeFile(configResource, VSBuffer.fromString(JSON.stringify(workspace, null, '\t')));
|
||||
|
||||
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
const environmentService = new TestWorkbenchEnvironmentService(appSettingsHome);
|
||||
const remoteAgentService = disposables.add(instantiationService.createInstance(RemoteAgentService));
|
||||
const environmentService = TestEnvironmentService;
|
||||
const remoteAgentService = disposables.add(instantiationService.createInstance(RemoteAgentService, null));
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
fileService.registerProvider(Schemas.userData, disposables.add(new FileUserDataProvider(ROOT.scheme, fileSystemProvider, Schemas.userData, new NullLogService())));
|
||||
testObject = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache(ROOT, fileService) }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
testObject = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache() }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
|
||||
instantiationService.stub(IWorkspaceContextService, testObject);
|
||||
instantiationService.stub(IConfigurationService, testObject);
|
||||
|
@ -211,11 +196,11 @@ suite('WorkspaceContextService - Workspace Editing', () => {
|
|||
await fileService.writeFile(configResource, VSBuffer.fromString(JSON.stringify(workspace, null, '\t')));
|
||||
|
||||
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
const environmentService = new TestWorkbenchEnvironmentService(appSettingsHome);
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService);
|
||||
const environmentService = TestEnvironmentService;
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService, null);
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
fileService.registerProvider(Schemas.userData, disposables.add(new FileUserDataProvider(ROOT.scheme, fileSystemProvider, Schemas.userData, new NullLogService())));
|
||||
testObject = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache(ROOT, fileService) }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
testObject = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache() }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
|
||||
instantiationService.stub(IFileService, fileService);
|
||||
instantiationService.stub(IWorkspaceContextService, testObject);
|
||||
|
@ -406,7 +391,7 @@ suite('WorkspaceContextService - Workspace Editing', () => {
|
|||
|
||||
suite('WorkspaceService - Initialization', () => {
|
||||
|
||||
let configResource: URI, testObject: WorkspaceService, fileService: IFileService, environmentService: NativeWorkbenchEnvironmentService;
|
||||
let configResource: URI, testObject: WorkspaceService, fileService: IFileService, environmentService: BrowserWorkbenchEnvironmentService;
|
||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
|
@ -447,11 +432,11 @@ suite('WorkspaceService - Initialization', () => {
|
|||
await fileService.writeFile(configResource, VSBuffer.fromString(JSON.stringify(workspace, null, '\t')));
|
||||
|
||||
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
environmentService = new TestWorkbenchEnvironmentService(appSettingsHome);
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService);
|
||||
environmentService = TestEnvironmentService;
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService, null);
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
fileService.registerProvider(Schemas.userData, disposables.add(new FileUserDataProvider(ROOT.scheme, fileSystemProvider, Schemas.userData, new NullLogService())));
|
||||
testObject = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache(ROOT, fileService) }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
testObject = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache() }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
instantiationService.stub(IFileService, fileService);
|
||||
instantiationService.stub(IWorkspaceContextService, testObject);
|
||||
instantiationService.stub(IConfigurationService, testObject);
|
||||
|
@ -548,8 +533,8 @@ suite('WorkspaceService - Initialization', () => {
|
|||
testObject.onDidChangeWorkspaceFolders(target);
|
||||
testObject.onDidChangeConfiguration(target);
|
||||
|
||||
await fileService.writeFile(joinPath(joinPath(ROOT, 'a'), '.vscode', 'settings.json'), VSBuffer.fromString('{ "initialization.testSetting1": "workspaceValue1" }'));
|
||||
await fileService.writeFile(joinPath(joinPath(ROOT, 'b'), '.vscode', 'settings.json'), VSBuffer.fromString('{ "initialization.testSetting2": "workspaceValue2" }'));
|
||||
await fileService.writeFile(joinPath(ROOT, 'a', '.vscode', 'settings.json'), VSBuffer.fromString('{ "initialization.testSetting1": "workspaceValue1" }'));
|
||||
await fileService.writeFile(joinPath(ROOT, 'b', '.vscode', 'settings.json'), VSBuffer.fromString('{ "initialization.testSetting2": "workspaceValue2" }'));
|
||||
await testObject.initialize(getWorkspaceIdentifier(configResource));
|
||||
|
||||
assert.equal(target.callCount, 4);
|
||||
|
@ -592,7 +577,7 @@ suite('WorkspaceService - Initialization', () => {
|
|||
testObject.onDidChangeWorkspaceFolders(target);
|
||||
testObject.onDidChangeConfiguration(target);
|
||||
|
||||
await fileService.writeFile(joinPath(joinPath(ROOT, 'b'), '.vscode', 'settings.json'), VSBuffer.fromString('{ "initialization.testSetting1": "workspaceValue2" }'));
|
||||
await fileService.writeFile(joinPath(ROOT, 'b', '.vscode', 'settings.json'), VSBuffer.fromString('{ "initialization.testSetting1": "workspaceValue2" }'));
|
||||
await testObject.initialize(convertToWorkspacePayload(joinPath(ROOT, 'b')));
|
||||
|
||||
assert.equal(testObject.getValue('initialization.testSetting1'), 'workspaceValue2');
|
||||
|
@ -612,7 +597,7 @@ suite('WorkspaceService - Initialization', () => {
|
|||
testObject.onDidChangeWorkspaceFolders(target);
|
||||
testObject.onDidChangeConfiguration(target);
|
||||
|
||||
await fileService.writeFile(joinPath(joinPath(ROOT, 'a'), '.vscode', 'settings.json'), VSBuffer.fromString('{ "initialization.testSetting1": "workspaceValue2" }'));
|
||||
await fileService.writeFile(joinPath(ROOT, 'a', '.vscode', 'settings.json'), VSBuffer.fromString('{ "initialization.testSetting1": "workspaceValue2" }'));
|
||||
await testObject.initialize(getWorkspaceIdentifier(configResource));
|
||||
|
||||
assert.equal(target.callCount, 4);
|
||||
|
@ -628,7 +613,7 @@ suite('WorkspaceService - Initialization', () => {
|
|||
|
||||
suite('WorkspaceConfigurationService - Folder', () => {
|
||||
|
||||
let testObject: IConfigurationService, workspaceService: WorkspaceService, fileService: IFileService, environmentService: NativeWorkbenchEnvironmentService;
|
||||
let testObject: IConfigurationService, workspaceService: WorkspaceService, fileService: IFileService, environmentService: BrowserWorkbenchEnvironmentService;
|
||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
|
||||
const disposables: DisposableStore = new DisposableStore();
|
||||
|
||||
|
@ -672,17 +657,15 @@ suite('WorkspaceConfigurationService - Folder', () => {
|
|||
const fileSystemProvider = disposables.add(new InMemoryFileSystemProvider());
|
||||
fileService.registerProvider(ROOT.scheme, fileSystemProvider);
|
||||
|
||||
const appSettingsHome = joinPath(joinPath(ROOT, 'user'));
|
||||
const folder = joinPath(joinPath(ROOT, 'a'));
|
||||
const folder = joinPath(ROOT, 'a');
|
||||
await fileService.createFolder(folder);
|
||||
await fileService.createFolder(appSettingsHome);
|
||||
|
||||
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
environmentService = new TestWorkbenchEnvironmentService(appSettingsHome);
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService);
|
||||
environmentService = TestEnvironmentService;
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService, null);
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
fileService.registerProvider(Schemas.userData, disposables.add(new FileUserDataProvider(ROOT.scheme, fileSystemProvider, Schemas.userData, new NullLogService())));
|
||||
workspaceService = testObject = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache(ROOT, fileService) }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
workspaceService = testObject = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache() }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
instantiationService.stub(IFileService, fileService);
|
||||
instantiationService.stub(IWorkspaceContextService, testObject);
|
||||
instantiationService.stub(IConfigurationService, testObject);
|
||||
|
@ -1124,7 +1107,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
|
|||
|
||||
suite('WorkspaceConfigurationService-Multiroot', () => {
|
||||
|
||||
let workspaceContextService: IWorkspaceContextService, jsonEditingServce: IJSONEditingService, testObject: IConfigurationService, fileService: IFileService, environmentService: NativeWorkbenchEnvironmentService;
|
||||
let workspaceContextService: IWorkspaceContextService, jsonEditingServce: IJSONEditingService, testObject: IConfigurationService, fileService: IFileService, environmentService: BrowserWorkbenchEnvironmentService;
|
||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
|
@ -1184,17 +1167,17 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
|
|||
await fileService.writeFile(configResource, VSBuffer.fromString(JSON.stringify(workspace, null, '\t')));
|
||||
|
||||
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
environmentService = new TestWorkbenchEnvironmentService(appSettingsHome);
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService);
|
||||
environmentService = TestEnvironmentService;
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService, null);
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
fileService.registerProvider(Schemas.userData, disposables.add(new FileUserDataProvider(ROOT.scheme, fileSystemProvider, Schemas.userData, new NullLogService())));
|
||||
const workspaceService = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache(ROOT, fileService) }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
const workspaceService = disposables.add(new WorkspaceService({ configurationCache: new ConfigurationCache() }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
|
||||
instantiationService.stub(IFileService, fileService);
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceService);
|
||||
instantiationService.stub(IConfigurationService, workspaceService);
|
||||
instantiationService.stub(IWorkbenchEnvironmentService, environmentService);
|
||||
instantiationService.stub(INativeWorkbenchEnvironmentService, environmentService);
|
||||
instantiationService.stub(IEnvironmentService, environmentService);
|
||||
|
||||
await workspaceService.initialize(getWorkspaceIdentifier(configResource));
|
||||
instantiationService.stub(IKeybindingEditingService, instantiationService.createInstance(KeybindingsEditingService));
|
||||
|
@ -1727,7 +1710,7 @@ suite('WorkspaceConfigurationService - Remote Folder', () => {
|
|||
|
||||
let testObject: WorkspaceService, folder: URI,
|
||||
machineSettingsResource: URI, remoteSettingsResource: URI, fileSystemProvider: InMemoryFileSystemProvider, resolveRemoteEnvironment: () => void,
|
||||
instantiationService: TestInstantiationService, fileService: IFileService, environmentService: NativeWorkbenchEnvironmentService;
|
||||
instantiationService: TestInstantiationService, fileService: IFileService, environmentService: BrowserWorkbenchEnvironmentService;
|
||||
const remoteAuthority = 'configuraiton-tests';
|
||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
|
||||
const disposables = new DisposableStore();
|
||||
|
@ -1767,15 +1750,15 @@ suite('WorkspaceConfigurationService - Remote Folder', () => {
|
|||
fileSystemProvider = disposables.add(new InMemoryFileSystemProvider());
|
||||
fileService.registerProvider(ROOT.scheme, fileSystemProvider);
|
||||
|
||||
const appSettingsHome = joinPath(joinPath(ROOT, 'user'));
|
||||
folder = joinPath(joinPath(ROOT, 'a'));
|
||||
const appSettingsHome = joinPath(ROOT, 'user');
|
||||
folder = joinPath(ROOT, 'a');
|
||||
await fileService.createFolder(folder);
|
||||
await fileService.createFolder(appSettingsHome);
|
||||
machineSettingsResource = joinPath(ROOT, 'machine-settings.json');
|
||||
remoteSettingsResource = machineSettingsResource.with({ scheme: Schemas.vscodeRemote, authority: remoteAuthority });
|
||||
|
||||
instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
environmentService = new TestWorkbenchEnvironmentService(appSettingsHome);
|
||||
environmentService = TestEnvironmentService;
|
||||
const remoteEnvironmentPromise = new Promise<Partial<IRemoteAgentEnvironment>>(c => resolveRemoteEnvironment = () => c({ settingsPath: remoteSettingsResource }));
|
||||
const remoteAgentService = instantiationService.stub(IRemoteAgentService, <Partial<IRemoteAgentService>>{ getEnvironment: () => remoteEnvironmentPromise });
|
||||
fileService.registerProvider(Schemas.userData, disposables.add(new FileUserDataProvider(ROOT.scheme, fileSystemProvider, Schemas.userData, new NullLogService())));
|
||||
|
@ -1978,10 +1961,10 @@ suite('ConfigurationService - Configuration Defaults', () => {
|
|||
});
|
||||
|
||||
function createConfigurationService(configurationDefaults: Record<string, any>): IConfigurationService {
|
||||
const remoteAgentService = (<TestInstantiationService>workbenchInstantiationService()).createInstance(RemoteAgentService);
|
||||
const remoteAgentService = (<TestInstantiationService>workbenchInstantiationService()).createInstance(RemoteAgentService, null);
|
||||
const environmentService = new BrowserWorkbenchEnvironmentService({ logsPath: joinPath(ROOT, 'logs'), workspaceId: '', configurationDefaults }, TestProductService);
|
||||
const fileService = new FileService(new NullLogService());
|
||||
return disposableStore.add(new WorkspaceService({ configurationCache: new ConfigurationCache(ROOT, fileService) }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
return disposableStore.add(new WorkspaceService({ configurationCache: new ConfigurationCache() }, environmentService, fileService, remoteAgentService, new UriIdentityService(fileService), new NullLogService()));
|
||||
}
|
||||
|
||||
});
|
|
@ -33,15 +33,13 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor
|
|||
import { KeybindingsEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
|
||||
import { TestBackupFileService, TestEditorGroupsService, TestEditorService, TestLifecycleService, TestPathService, TestProductService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestBackupFileService, TestEditorGroupsService, TestEditorService, TestEnvironmentService, TestLifecycleService, TestPathService, TestTextFileService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { FileService } from 'vs/platform/files/common/fileService';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
|
||||
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { TestWorkbenchConfiguration, TestTextFileService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { LabelService } from 'vs/workbench/services/label/common/labelService';
|
||||
import { IFilesConfigurationService, FilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
@ -59,15 +57,6 @@ import { InMemoryFileSystemProvider } from 'vs/platform/files/common/inMemoryFil
|
|||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
|
||||
class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
|
||||
|
||||
constructor(private _appSettingsHome: URI) {
|
||||
super(TestWorkbenchConfiguration, TestProductService);
|
||||
}
|
||||
|
||||
get appSettingsHome() { return this._appSettingsHome; }
|
||||
}
|
||||
|
||||
interface Modifiers {
|
||||
metaKey?: boolean;
|
||||
ctrlKey?: boolean;
|
||||
|
@ -80,7 +69,7 @@ const ROOT = URI.file('tests').with({ scheme: 'vscode-tests' });
|
|||
suite('KeybindingsEditing', () => {
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
let instantiationService: TestInstantiationService, fileService: IFileService, environmentService: NativeWorkbenchEnvironmentService;
|
||||
let instantiationService: TestInstantiationService, fileService: IFileService, environmentService: IEnvironmentService;
|
||||
let testObject: KeybindingsEditingService;
|
||||
|
||||
setup(async () => {
|
||||
|
@ -91,7 +80,7 @@ suite('KeybindingsEditing', () => {
|
|||
|
||||
const userFolder = joinPath(ROOT, 'User');
|
||||
await fileService.createFolder(userFolder);
|
||||
environmentService = new TestWorkbenchEnvironmentService(userFolder);
|
||||
environmentService = TestEnvironmentService;
|
||||
|
||||
instantiationService = new TestInstantiationService();
|
||||
|
|
@ -16,17 +16,16 @@ import { DisposableStore, IDisposable, Disposable } from 'vs/base/common/lifecyc
|
|||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { TestProductService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { TestWorkbenchConfiguration } from 'vs/workbench/test/electron-browser/workbenchTestServices';
|
||||
import { InMemoryFileSystemProvider } from 'vs/platform/files/common/inMemoryFilesystemProvider';
|
||||
import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
|
||||
|
||||
const ROOT = URI.file('tests').with({ scheme: 'vscode-tests' });
|
||||
|
||||
class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
|
||||
constructor(private readonly _appSettingsHome: URI) {
|
||||
super(TestWorkbenchConfiguration, TestProductService);
|
||||
class TestWorkbenchEnvironmentService extends BrowserWorkbenchEnvironmentService {
|
||||
constructor(private readonly appSettingsHome: URI) {
|
||||
super(Object.create(null), TestProductService);
|
||||
}
|
||||
get appSettingsHome() { return this._appSettingsHome; }
|
||||
get userRoamingDataHome() { return this.appSettingsHome.with({ scheme: Schemas.userData }); }
|
||||
}
|
||||
|
||||
suite('FileUserDataProvider', () => {
|
Loading…
Reference in a new issue