use of com.intellij.tasks.actions.SwitchTaskAction in project intellij-community by JetBrains.
the class TaskUiTest method testTaskComboVisible.
public void testTaskComboVisible() throws Exception {
SwitchTaskAction combo = null;
ActionGroup group = (ActionGroup) CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_MAIN_TOOLBAR);
ActionToolbarImpl toolbar = (ActionToolbarImpl) ActionManager.getInstance().createActionToolbar(ActionPlaces.MAIN_TOOLBAR, group, true);
AnAction[] children = group.getChildren(new TestActionEvent());
for (AnAction child : children) {
if (child instanceof ActionGroup) {
AnAction[] actions = ((ActionGroup) child).getChildren(new TestActionEvent());
for (AnAction action : actions) {
if (action instanceof SwitchTaskAction) {
combo = (SwitchTaskAction) action;
}
}
}
}
TaskManager manager = TaskManager.getManager(getProject());
LocalTask defaultTask = manager.getActiveTask();
assertTrue(defaultTask.isDefault());
assertEquals(defaultTask.getCreated(), defaultTask.getUpdated());
Presentation presentation = doTest(combo, toolbar);
assertFalse(presentation.isVisible());
try {
TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO = true;
presentation = doTest(combo, toolbar);
assertTrue(presentation.isVisible());
} finally {
TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO = false;
}
LocalTask task = manager.createLocalTask("test");
manager.activateTask(task, false);
presentation = doTest(combo, toolbar);
assertTrue(presentation.isVisible());
manager.activateTask(defaultTask, false);
task = manager.getActiveTask();
assertTrue(task.isDefault());
presentation = doTest(combo, toolbar);
if (!presentation.isVisible()) {
LocalTask activeTask = manager.getActiveTask();
System.out.println(activeTask);
System.out.println(activeTask.getCreated());
System.out.println(activeTask.getUpdated());
fail();
}
}
Aggregations