RunnerExtension { @Inject public void setUpRunActions(ActionManager actionManager, RunAction runAction, RunWithAction runWithAction, ChooseRunnerAction chooseRunner, CreateCustomRunnerAction createCustomRunner) { DefaultActionGroup runToolbarGroup = (DefaultActionGroup)actionManager.getAction(GROUP_RUN_TOOLBAR); if (runToolbarGroup == null) { DefaultActionGroup rightToolbarGroup = (DefaultActionGroup)actionManager.getAction(GROUP_RIGHT_TOOLBAR); runToolbarGroup = new DefaultActionGroup(GROUP_RUN_TOOLBAR, false, actionManager); rightToolbarGroup.add(runToolbarGroup, new Constraints(Anchor.AFTER, GROUP_BUILD_TOOLBAR)); actionManager.registerAction(GROUP_RUN_TOOLBAR, runToolbarGroup); } actionManager.registerAction(ActionId.CHOOSE_RUNNER_ID.getId(), chooseRunner); actionManager.registerAction(ActionId.RUN_APP_ID.getId(), runAction); actionManager.registerAction(ActionId.RUN_WITH.getId(), runWithAction); actionManager.registerAction(ActionId.CREATE_CUSTOM_RUNNER.getId(), createCustomRunner); DefaultActionGroup contextMenuGroup = (DefaultActionGroup)actionManager.getAction(GROUP_MAIN_CONTEXT_MENU); DefaultActionGroup runContextGroup = (DefaultActionGroup)actionManager.getAction(GROUP_RUN_CONTEXT_MENU); runContextGroup.addSeparator(); runContextGroup.add(runAction); contextMenuGroup.add(runContextGroup); runToolbarGroup.add(chooseRunner); runToolbarGroup.add(runAction, new Constraints(AFTER, ActionId.CHOOSE_RUNNER_ID.getId())); DefaultActionGroup runMenuActionGroup = (DefaultActionGroup)actionManager.getAction(GROUP_RUN); runMenuActionGroup.add(runAction, FIRST); runMenuActionGroup.add(runWithAction, new Constraints(Anchor.AFTER, ActionId.RUN_APP_ID.getId())); DefaultActionGroup runnersList = new DefaultActionGroup(RUNNER_LIST, false, actionManager); actionManager.registerAction(RUNNER_LIST, runnersList); runnersList.add(createCustomRunner, FIRST); runnersList.addSeparator(); } @Inject  RunnerExtension(RunnerResources resources); @Inject void setUpRunnerConsole(WorkspaceAgent workspaceAgent, RunnerManagerPresenter runnerManagerPresenter); @Inject void setUpRunActions(ActionManager actionManager,
                                RunAction runAction,
                                RunWithAction runWithAction,
                                ChooseRunnerAction chooseRunner,
                                CreateCustomRunnerAction createCustomRunner); static final String BUILDER_PART_ID; static final String RUNNER_LIST; }
@Test public void runnerMenuActionsShouldBeAdded() throws Exception { ActionManager actionManager = mock(ActionManager.class); RunAction runAction = mock(RunAction.class); RunWithAction runWithAction = mock(RunWithAction.class); ChooseRunnerAction chooseRunnerAction = mock(ChooseRunnerAction.class); CreateCustomRunnerAction createCustomRunnerAction = mock(CreateCustomRunnerAction.class); DefaultActionGroup rightToolbarGroup = mock(DefaultActionGroup.class); DefaultActionGroup runContextGroup = mock(DefaultActionGroup.class); DefaultActionGroup contextMenuGroup = mock(DefaultActionGroup.class); DefaultActionGroup mainMenuGroup = mock(DefaultActionGroup.class); when(actionManager.getAction(GROUP_RIGHT_TOOLBAR)).thenReturn(rightToolbarGroup); when(actionManager.getAction(GROUP_RUN_CONTEXT_MENU)).thenReturn(runContextGroup); when(actionManager.getAction(GROUP_MAIN_CONTEXT_MENU)).thenReturn(contextMenuGroup); when(actionManager.getAction(GROUP_RUN)).thenReturn(mainMenuGroup); extension.setUpRunActions(actionManager, runAction, runWithAction, chooseRunnerAction, createCustomRunnerAction); verify(rightToolbarGroup).add(actionGroupCaptor.capture(), constraintsCaptor.capture()); verifyConstants(Anchor.AFTER, GROUP_BUILD_TOOLBAR); verify(runContextGroup).addSeparator(); verify(runContextGroup).add(runAction); verify(contextMenuGroup).add(runContextGroup); DefaultActionGroup runToolbarGroup = actionGroupCaptor.getValue(); assertThat(runToolbarGroup.getChildrenCount(), is(2)); verify(actionManager).registerAction(GROUP_RUN_TOOLBAR, runToolbarGroup); verifyConstants(Anchor.AFTER, GROUP_BUILD_TOOLBAR); }
@Test public void runnerToolbarActionsShouldBeAddedToRegisteredEarlyGroup() throws Exception { ActionManager actionManager = mock(ActionManager.class); RunAction runAction = mock(RunAction.class); RunWithAction runWithAction = mock(RunWithAction.class); ChooseRunnerAction chooseRunnerAction = mock(ChooseRunnerAction.class); DefaultActionGroup rightToolbarGroup = mock(DefaultActionGroup.class); DefaultActionGroup runToolbarGroup = mock(DefaultActionGroup.class); DefaultActionGroup runContextGroup = mock(DefaultActionGroup.class); DefaultActionGroup contextMenuGroup = mock(DefaultActionGroup.class); DefaultActionGroup mainMenuGroup = mock(DefaultActionGroup.class); CreateCustomRunnerAction createCustomRunnerAction = mock(CreateCustomRunnerAction.class); when(actionManager.getAction(GROUP_RUN_TOOLBAR)).thenReturn(runToolbarGroup); when(actionManager.getAction(GROUP_RUN_CONTEXT_MENU)).thenReturn(runContextGroup); when(actionManager.getAction(GROUP_MAIN_CONTEXT_MENU)).thenReturn(contextMenuGroup); when(actionManager.getAction(GROUP_RUN)).thenReturn(mainMenuGroup); extension.setUpRunActions(actionManager, runAction, runWithAction, chooseRunnerAction, createCustomRunnerAction); verify(actionManager, never()).registerAction(GROUP_RUN_TOOLBAR, runToolbarGroup); verify(rightToolbarGroup, never()).add(eq(runToolbarGroup), constraintsCaptor.capture()); verify(runToolbarGroup).add(chooseRunnerAction); verify(runToolbarGroup).add(eq(runAction), constraintsCaptor.capture()); verifyConstants(Anchor.AFTER, ActionId.CHOOSE_RUNNER_ID.getId()); verify(runContextGroup).addSeparator(); verify(runContextGroup).add(runAction); verify(contextMenuGroup).add(runContextGroup); }