From b1a8048c19c2e95feb4e390441ad2184d3618a51 Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 27 Dec 2017 17:50:31 +0100 Subject: [PATCH] fix tests and groups --- extensions/markdown/package.json | 2 +- .../actions/test/common/menuService.test.ts | 10 +++++----- .../electron-browser/execution.contribution.ts | 4 ++-- .../electron-browser/fileActions.contribution.ts | 16 ++++++++-------- .../electron-browser/search.contribution.ts | 4 ++-- .../test/node/keybindingEditing.test.ts | 4 +++- src/vs/workbench/test/workbenchTestServices.ts | 2 ++ 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/extensions/markdown/package.json b/extensions/markdown/package.json index c7a54dd3e8a..417e2456a6a 100644 --- a/extensions/markdown/package.json +++ b/extensions/markdown/package.json @@ -154,7 +154,7 @@ { "command": "markdown.showPreview", "when": "resourceLangId == markdown", - "group": "2_navigation" + "group": "navigation" } ], "commandPalette": [ diff --git a/src/vs/platform/actions/test/common/menuService.test.ts b/src/vs/platform/actions/test/common/menuService.test.ts index 40ecb80f1ff..996fd93c2b8 100644 --- a/src/vs/platform/actions/test/common/menuService.test.ts +++ b/src/vs/platform/actions/test/common/menuService.test.ts @@ -151,8 +151,8 @@ suite('MenuService', function () { const groups = menuService.createMenu(MenuId.ExplorerContext, contextKeyService).getActions(); - assert.equal(groups.length, 1); - const [[, actions]] = groups; + assert.equal(groups.length, 2); + const [, actions] = groups[1]; assert.equal(actions.length, 3); const [one, two, three] = actions; @@ -188,8 +188,8 @@ suite('MenuService', function () { const groups = menuService.createMenu(MenuId.ExplorerContext, contextKeyService).getActions(); - assert.equal(groups.length, 1); - const [[, actions]] = groups; + assert.equal(groups.length, 2); + const [, actions] = groups[1]; assert.equal(actions.length, 4); const [one, two, three, four] = actions; @@ -225,7 +225,7 @@ suite('MenuService', function () { assert.equal(groups.length, 1); const [[, actions]] = groups; - assert.equal(actions.length, 3); + assert.equal(actions.length, 5); const [one, two, three] = actions; assert.equal(one.id, 'c'); assert.equal(two.id, 'b'); diff --git a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts index 7e19eab1a72..1eedc47fecf 100644 --- a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts +++ b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts @@ -163,14 +163,14 @@ const openConsoleCommand = { }; MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, { - group: '2_navigation', + group: 'navigation', order: 30, command: openConsoleCommand, when: ResourceContextKey.Scheme.isEqualTo('file') }); MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { - group: '2_navigation', + group: 'navigation', order: 30, command: openConsoleCommand, when: ResourceContextKey.Scheme.isEqualTo('file') diff --git a/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts b/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts index 2c175622c54..13c358c0c4a 100644 --- a/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts +++ b/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts @@ -130,7 +130,7 @@ function appendSaveConflictEditorTitleAction(id: string, title: string, iconClas MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id, title, iconClass }, when: ContextKeyExpr.equals(CONFLICT_RESOLUTION_CONTEXT, true), - group: '2_navigation', + group: 'navigation', order }); } @@ -142,7 +142,7 @@ const openToSideCommand = { title: nls.localize('openToSide', "Open to the Side") }; MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, { - group: '2_navigation', + group: 'navigation', order: 10, command: openToSideCommand, when: ResourceContextKey.HasResource @@ -153,7 +153,7 @@ const revealInOsCommand = { title: isWindows ? nls.localize('revealInWindows', "Reveal in Explorer") : isMacintosh ? nls.localize('revealInMac', "Reveal in Finder") : nls.localize('openContainer', "Open Containing Folder") }; MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, { - group: '2_navigation', + group: 'navigation', order: 20, command: revealInOsCommand, when: ResourceContextKey.Scheme.isEqualTo('file') @@ -164,7 +164,7 @@ const copyPathCommand = { title: nls.localize('copyPath', "Copy Path") }; MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, { - group: '2_navigation', + group: 'navigation', order: 40, command: copyPathCommand, when: ResourceContextKey.HasResource @@ -281,7 +281,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, { // Menu registration - explorer MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { - group: '1_new', + group: 'navigation', order: 4, command: { id: NEW_FILE_COMMAND_ID, @@ -291,7 +291,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { }); MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { - group: '1_new', + group: 'navigation', order: 6, command: { id: NEW_FOLDER_COMMAND_ID, @@ -301,14 +301,14 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { }); MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { - group: '2_navigation', + group: 'navigation', order: 10, command: openToSideCommand, when: ContextKeyExpr.and(ResourceContextKey.Scheme.isEqualTo('file'), ExplorerFolderContext.toNegated()) }); MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { - group: '2_navigation', + group: 'navigation', order: 20, command: revealInOsCommand, when: ResourceContextKey.HasResource diff --git a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts index e82b4d5ebdd..bbee04d3204 100644 --- a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts +++ b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts @@ -220,7 +220,7 @@ CommandsRegistry.registerCommand({ }); MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { - group: '2_navigation', + group: 'navigation', order: 50, command: { id: FIND_IN_FOLDER_ID, @@ -230,7 +230,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { }); MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { - group: '2_navigation', + group: 'navigation', order: 20, command: { id: FIND_IN_WORKSPACE_ID, diff --git a/src/vs/workbench/services/keybinding/test/node/keybindingEditing.test.ts b/src/vs/workbench/services/keybinding/test/node/keybindingEditing.test.ts index 6b9bbd618b5..2d603d901f1 100644 --- a/src/vs/workbench/services/keybinding/test/node/keybindingEditing.test.ts +++ b/src/vs/workbench/services/keybinding/test/node/keybindingEditing.test.ts @@ -37,13 +37,14 @@ import { IModeService } from 'vs/editor/common/services/modeService'; import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl'; import { IModelService } from 'vs/editor/common/services/modelService'; import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl'; -import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; +import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { KeybindingsEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing'; import { IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding'; import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; import { IHashService } from 'vs/workbench/services/hash/common/hashService'; import { mkdirp } from 'vs/base/node/pfs'; +import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService'; interface Modifiers { metaKey?: boolean; @@ -73,6 +74,7 @@ suite('Keybindings Editing', () => { instantiationService.stub(IWorkspaceContextService, new TestContextService()); const lifecycleService = new TestLifecycleService(); instantiationService.stub(ILifecycleService, lifecycleService); + instantiationService.stub(IContextKeyService, instantiationService.createInstance(MockContextKeyService)); instantiationService.stub(IHashService, new TestHashService()); instantiationService.stub(IEditorGroupService, new TestEditorGroupService()); instantiationService.stub(ITelemetryService, NullTelemetryService); diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 426c251d808..e55ac87907a 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -60,6 +60,7 @@ import { IPosition, Position as EditorPosition } from 'vs/editor/common/core/pos import { ICommandAction } from 'vs/platform/actions/common/actions'; import { IHashService } from 'vs/workbench/services/hash/common/hashService'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService'; export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput { return instantiationService.createInstance(FileEditorInput, resource, void 0); @@ -236,6 +237,7 @@ export class TestTextFileService extends TextFileService { export function workbenchInstantiationService(): IInstantiationService { let instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()])); + instantiationService.stub(IContextKeyService, instantiationService.createInstance(MockContextKeyService)); instantiationService.stub(IWorkspaceContextService, new TestContextService(TestWorkspace)); const configService = new TestConfigurationService(); instantiationService.stub(IConfigurationService, configService);