Skip to content

Commit

Permalink
use nullExtensionDescription in more places, #131165
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Nov 9, 2021
1 parent 3abda3b commit 9867849
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 68 deletions.
51 changes: 20 additions & 31 deletions src/vs/workbench/test/browser/api/extHostAuthentication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -140,7 +129,7 @@ suite('ExtHostAuthentication', () => {

test('createIfNone - true', async () => {
const session = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -152,15 +141,15 @@ suite('ExtHostAuthentication', () => {

test('createIfNone - false', async () => {
const nosession = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{});
assert.strictEqual(nosession, undefined);

// Now create the session
const session = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -171,7 +160,7 @@ suite('ExtHostAuthentication', () => {
assert.strictEqual(session?.scopes[0], 'foo');

const session2 = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{});
Expand All @@ -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'],
{
Expand All @@ -194,7 +183,7 @@ suite('ExtHostAuthentication', () => {

// Now create the session
const session = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -205,7 +194,7 @@ suite('ExtHostAuthentication', () => {
assert.strictEqual(session?.scopes[0], 'foo');

const session2 = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -218,7 +207,7 @@ suite('ExtHostAuthentication', () => {

test('forceNewSession - true', async () => {
const session1 = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -227,7 +216,7 @@ suite('ExtHostAuthentication', () => {

// Now create the session
const session2 = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -241,7 +230,7 @@ suite('ExtHostAuthentication', () => {

test('forceNewSession - detail', async () => {
const session1 = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -250,7 +239,7 @@ suite('ExtHostAuthentication', () => {

// Now create the session
const session2 = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -265,7 +254,7 @@ suite('ExtHostAuthentication', () => {
test('clearSessionPreference - true', async () => {
// Now create the session
const session = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test-multiple',
['foo'],
{
Expand All @@ -276,7 +265,7 @@ suite('ExtHostAuthentication', () => {
assert.strictEqual(session?.scopes[0], 'foo');

const session2 = await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test-multiple',
['foo'],
{
Expand All @@ -294,7 +283,7 @@ suite('ExtHostAuthentication', () => {
test('forceNewSession with no sessions', async () => {
try {
await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -309,7 +298,7 @@ suite('ExtHostAuthentication', () => {
test('createIfNone and forceNewSession', async () => {
try {
await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -325,7 +314,7 @@ suite('ExtHostAuthentication', () => {
test('forceNewSession and silent', async () => {
try {
await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand All @@ -341,7 +330,7 @@ suite('ExtHostAuthentication', () => {
test('createIfNone and silent', async () => {
try {
await extHostAuthentication.getSession(
nullExtensionDescription,
extensionDescription,
'test',
['foo'],
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,14 @@ 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', () => {

let resource = URI.parse('foo:bar');
let mainThreadBulkEdits = new class extends mock<MainThreadBulkEditsShape>() { };
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());
Expand Down
23 changes: 13 additions & 10 deletions src/vs/workbench/test/browser/api/extHostTreeViews.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {

Expand All @@ -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>;
Expand Down Expand Up @@ -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');
});
Expand Down Expand Up @@ -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 },
Expand All @@ -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 }]
Expand All @@ -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 }]
Expand All @@ -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: [
Expand All @@ -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 }]
Expand Down Expand Up @@ -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) => {
Expand Down
16 changes: 2 additions & 14 deletions src/vs/workbench/test/browser/api/extHostWorkspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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(
Expand All @@ -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);
Expand Down

0 comments on commit 9867849

Please sign in to comment.