From 986784928729f70f10c443c945b4aa8a49d30790 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 9 Nov 2021 13:52:01 +0100 Subject: [PATCH] use nullExtensionDescription in more places, https://github.com/microsoft/vscode/issues/131165 --- .../browser/api/extHostAuthentication.test.ts | 51 ++++++++----------- .../extHostDocumentSaveParticipant.test.ts | 14 +---- .../test/browser/api/extHostTreeViews.test.ts | 23 +++++---- .../test/browser/api/extHostWorkspace.test.ts | 16 +----- 4 files changed, 36 insertions(+), 68 deletions(-) diff --git a/src/vs/workbench/test/browser/api/extHostAuthentication.test.ts b/src/vs/workbench/test/browser/api/extHostAuthentication.test.ts index be6599dc21338..87b041692183a 100644 --- a/src/vs/workbench/test/browser/api/extHostAuthentication.test.ts +++ b/src/vs/workbench/test/browser/api/extHostAuthentication.test.ts @@ -7,7 +7,7 @@ import * as assert from 'assert'; import { DisposableStore } from 'vs/base/common/lifecycle'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService'; -import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions'; +import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService'; @@ -20,7 +20,7 @@ import { ExtHostContext, MainContext } from 'vs/workbench/api/common/extHost.pro import { ExtHostAuthentication } from 'vs/workbench/api/common/extHostAuthentication'; import { IActivityService } from 'vs/workbench/services/activity/common/activity'; import { AuthenticationService, IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; -import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; +import { IExtensionService, nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; import { TestRemoteAgentService } from 'vs/workbench/services/remote/test/common/testServices'; import { TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol'; @@ -89,18 +89,7 @@ class TestAuthProvider implements AuthenticationProvider { suite('ExtHostAuthentication', () => { let disposables: DisposableStore; - let nullExtensionDescription: IExtensionDescription = { - identifier: new ExtensionIdentifier('nullExtensionDescription'), - name: 'Null Extension Description', - publisher: 'vscode', - enableProposedApi: true, - engines: undefined!, - extensionLocation: undefined!, - isBuiltin: false, - isUserBuiltin: false, - isUnderDevelopment: false, - version: undefined! - }; + let extensionDescription: IExtensionDescription = { ...nullExtensionDescription, enableProposedApi: true }; let extHostAuthentication: ExtHostAuthentication; let instantiationService: TestInstantiationService; @@ -140,7 +129,7 @@ suite('ExtHostAuthentication', () => { test('createIfNone - true', async () => { const session = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -152,7 +141,7 @@ suite('ExtHostAuthentication', () => { test('createIfNone - false', async () => { const nosession = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], {}); @@ -160,7 +149,7 @@ suite('ExtHostAuthentication', () => { // Now create the session const session = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -171,7 +160,7 @@ suite('ExtHostAuthentication', () => { assert.strictEqual(session?.scopes[0], 'foo'); const session2 = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], {}); @@ -184,7 +173,7 @@ suite('ExtHostAuthentication', () => { // should behave the same as createIfNone: false test('silent - true', async () => { const nosession = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -194,7 +183,7 @@ suite('ExtHostAuthentication', () => { // Now create the session const session = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -205,7 +194,7 @@ suite('ExtHostAuthentication', () => { assert.strictEqual(session?.scopes[0], 'foo'); const session2 = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -218,7 +207,7 @@ suite('ExtHostAuthentication', () => { test('forceNewSession - true', async () => { const session1 = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -227,7 +216,7 @@ suite('ExtHostAuthentication', () => { // Now create the session const session2 = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -241,7 +230,7 @@ suite('ExtHostAuthentication', () => { test('forceNewSession - detail', async () => { const session1 = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -250,7 +239,7 @@ suite('ExtHostAuthentication', () => { // Now create the session const session2 = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -265,7 +254,7 @@ suite('ExtHostAuthentication', () => { test('clearSessionPreference - true', async () => { // Now create the session const session = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test-multiple', ['foo'], { @@ -276,7 +265,7 @@ suite('ExtHostAuthentication', () => { assert.strictEqual(session?.scopes[0], 'foo'); const session2 = await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test-multiple', ['foo'], { @@ -294,7 +283,7 @@ suite('ExtHostAuthentication', () => { test('forceNewSession with no sessions', async () => { try { await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -309,7 +298,7 @@ suite('ExtHostAuthentication', () => { test('createIfNone and forceNewSession', async () => { try { await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -325,7 +314,7 @@ suite('ExtHostAuthentication', () => { test('forceNewSession and silent', async () => { try { await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { @@ -341,7 +330,7 @@ suite('ExtHostAuthentication', () => { test('createIfNone and silent', async () => { try { await extHostAuthentication.getSession( - nullExtensionDescription, + extensionDescription, 'test', ['foo'], { diff --git a/src/vs/workbench/test/browser/api/extHostDocumentSaveParticipant.test.ts b/src/vs/workbench/test/browser/api/extHostDocumentSaveParticipant.test.ts index 68708e71ad19f..4859a1f90862a 100644 --- a/src/vs/workbench/test/browser/api/extHostDocumentSaveParticipant.test.ts +++ b/src/vs/workbench/test/browser/api/extHostDocumentSaveParticipant.test.ts @@ -15,7 +15,7 @@ import type * as vscode from 'vscode'; import { mock } from 'vs/base/test/common/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'; +import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; suite('ExtHostDocumentSaveParticipant', () => { @@ -23,18 +23,6 @@ suite('ExtHostDocumentSaveParticipant', () => { let mainThreadBulkEdits = new class extends mock() { }; let documents: ExtHostDocuments; let nullLogService = new NullLogService(); - let nullExtensionDescription: IExtensionDescription = { - identifier: new ExtensionIdentifier('nullExtensionDescription'), - name: 'Null Extension Description', - publisher: 'vscode', - enableProposedApi: false, - engines: undefined!, - extensionLocation: undefined!, - isBuiltin: false, - isUserBuiltin: false, - isUnderDevelopment: false, - version: undefined! - }; setup(() => { const documentsAndEditors = new ExtHostDocumentsAndEditors(SingleProxyRPCProtocol(null), new NullLogService()); diff --git a/src/vs/workbench/test/browser/api/extHostTreeViews.test.ts b/src/vs/workbench/test/browser/api/extHostTreeViews.test.ts index dc6fdca0353fd..46fc654a93611 100644 --- a/src/vs/workbench/test/browser/api/extHostTreeViews.test.ts +++ b/src/vs/workbench/test/browser/api/extHostTreeViews.test.ts @@ -19,6 +19,7 @@ import { TreeItemCollapsibleState, ITreeItem, IRevealOptions } from 'vs/workbenc import { NullLogService } from 'vs/platform/log/common/log'; import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; import type { IDisposable } from 'vs/base/common/lifecycle'; +import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; suite('ExtHostTreeView', function () { @@ -41,6 +42,8 @@ suite('ExtHostTreeView', function () { } + const extensionsDescription: IExtensionDescription = { ...nullExtensionDescription, enableProposedApi: true }; + let testObject: ExtHostTreeViews; let target: RecordingShape; let onDidChangeTreeNode: Emitter<{ key: string } | undefined>; @@ -80,9 +83,9 @@ suite('ExtHostTreeView', function () { ), new NullLogService()); onDidChangeTreeNode = new Emitter<{ key: string } | undefined>(); onDidChangeTreeNodeWithId = new Emitter<{ key: string }>(); - testObject.createTreeView('testNodeTreeProvider', { treeDataProvider: aNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription); - testObject.createTreeView('testNodeWithIdTreeProvider', { treeDataProvider: aNodeWithIdTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription); - testObject.createTreeView('testNodeWithHighlightsTreeProvider', { treeDataProvider: aNodeWithHighlightedLabelTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription); + testObject.createTreeView('testNodeTreeProvider', { treeDataProvider: aNodeTreeDataProvider() }, extensionsDescription); + testObject.createTreeView('testNodeWithIdTreeProvider', { treeDataProvider: aNodeWithIdTreeDataProvider() }, extensionsDescription); + testObject.createTreeView('testNodeWithHighlightsTreeProvider', { treeDataProvider: aNodeWithHighlightedLabelTreeDataProvider() }, extensionsDescription); return loadCompleteTree('testNodeTreeProvider'); }); @@ -482,14 +485,14 @@ suite('ExtHostTreeView', function () { }); test('reveal will throw an error if getParent is not implemented', () => { - const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription); + const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aNodeTreeDataProvider() }, extensionsDescription); return treeView.reveal({ key: 'a' }) .then(() => assert.fail('Reveal should throw an error as getParent is not implemented'), () => null); }); test('reveal will return empty array for root element', () => { const revealTarget = sinon.spy(target, '$reveal'); - const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription); + const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, extensionsDescription); const expected = { item: { handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }, @@ -506,7 +509,7 @@ suite('ExtHostTreeView', function () { test('reveal will return parents array for an element when hierarchy is not loaded', () => { const revealTarget = sinon.spy(target, '$reveal'); - const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription); + const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, extensionsDescription); const expected = { item: { handle: '0/0:a/0:aa', label: { label: 'aa' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' }, parentChain: [{ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }] @@ -523,7 +526,7 @@ suite('ExtHostTreeView', function () { test('reveal will return parents array for an element when hierarchy is loaded', () => { const revealTarget = sinon.spy(target, '$reveal'); - const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription); + const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, extensionsDescription); const expected = { item: { handle: '0/0:a/0:aa', label: { label: 'aa' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' }, parentChain: [{ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }] @@ -549,7 +552,7 @@ suite('ExtHostTreeView', function () { } }; const revealTarget = sinon.spy(target, '$reveal'); - const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription); + const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, extensionsDescription); const expected = { item: { handle: '0/0:b/0:ba/0:bac', label: { label: 'bac' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:b/0:ba' }, parentChain: [ @@ -569,7 +572,7 @@ suite('ExtHostTreeView', function () { test('reveal after first udpate', () => { const revealTarget = sinon.spy(target, '$reveal'); - const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription); + const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, extensionsDescription); const expected = { item: { handle: '0/0:a/0:ac', label: { label: 'ac' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:a' }, parentChain: [{ handle: '0/0:a', label: { label: 'a' }, collapsibleState: TreeItemCollapsibleState.Collapsed }] @@ -601,7 +604,7 @@ suite('ExtHostTreeView', function () { test('reveal after second udpate', () => { const revealTarget = sinon.spy(target, '$reveal'); - const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription); + const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, extensionsDescription); return loadCompleteTree('treeDataProvider') .then(() => { return runWithEventMerging((resolve) => { diff --git a/src/vs/workbench/test/browser/api/extHostWorkspace.test.ts b/src/vs/workbench/test/browser/api/extHostWorkspace.test.ts index 37bfb0b687016..154a72f8ab9fa 100644 --- a/src/vs/workbench/test/browser/api/extHostWorkspace.test.ts +++ b/src/vs/workbench/test/browser/api/extHostWorkspace.test.ts @@ -7,7 +7,7 @@ import * as assert from 'assert'; import { CancellationToken } from 'vs/base/common/cancellation'; import { basename } from 'vs/base/common/path'; import { URI, UriComponents } from 'vs/base/common/uri'; -import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions'; +import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions'; import { ILogService, NullLogService } from 'vs/platform/log/common/log'; import { IWorkspaceFolderData } from 'vs/platform/workspace/common/workspace'; import { MainThreadWorkspace } from 'vs/workbench/api/browser/mainThreadWorkspace'; @@ -23,6 +23,7 @@ import { IPatternInfo } from 'vs/workbench/services/search/common/search'; import { isLinux, isWindows } from 'vs/base/common/platform'; import { IExtHostFileSystemInfo } from 'vs/workbench/api/common/extHostFileSystemInfo'; import { FileSystemProviderCapabilities } from 'vs/platform/files/common/files'; +import { nullExtensionDescription as extensionDescriptor } from 'vs/workbench/services/extensions/common/extensions'; function createExtHostWorkspace(mainContext: IMainContext, data: IWorkspaceData, logService: ILogService): ExtHostWorkspace { const result = new ExtHostWorkspace( @@ -37,19 +38,6 @@ function createExtHostWorkspace(mainContext: IMainContext, data: IWorkspaceData, suite('ExtHostWorkspace', function () { - const extensionDescriptor: IExtensionDescription = { - identifier: new ExtensionIdentifier('nullExtensionDescription'), - name: 'ext', - publisher: 'vscode', - enableProposedApi: false, - engines: undefined!, - extensionLocation: undefined!, - isBuiltin: false, - isUserBuiltin: false, - isUnderDevelopment: false, - version: undefined! - }; - function assertAsRelativePath(workspace: ExtHostWorkspace, input: string, expected: string, includeWorkspace?: boolean) { const actual = workspace.getRelativePath(input, includeWorkspace); assert.strictEqual(actual, expected);