2 * Copyright 2000-2012 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.tasks;
18 import com.intellij.openapi.actionSystem.AnAction;
19 import com.intellij.openapi.actionSystem.Presentation;
20 import com.intellij.tasks.actions.SwitchTaskCombo;
21 import com.intellij.tasks.config.TaskSettings;
22 import com.intellij.testFramework.IdeaTestCase;
23 import com.intellij.testFramework.TestActionEvent;
24 import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase;
27 * @author Dmitry Avdeev
30 public class TaskUiTest extends CodeInsightFixtureTestCase {
32 public void testTaskComboVisible() throws Exception {
34 TaskManager manager = TaskManager.getManager(getProject());
35 SwitchTaskCombo combo = new SwitchTaskCombo();
37 LocalTask defaultTask = manager.getActiveTask();
38 assertTrue(defaultTask.isDefault());
39 assertEquals(defaultTask.getCreated(), defaultTask.getUpdated());
41 Presentation presentation = doTest(combo);
42 assertFalse(presentation.isVisible());
45 TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO = true;
46 presentation = doTest(combo);
47 assertTrue(presentation.isVisible());
50 TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO = false;
53 LocalTask task = manager.createLocalTask("test");
54 manager.activateTask(task, false);
56 presentation = doTest(combo);
57 assertTrue(presentation.isVisible());
59 manager.activateTask(defaultTask, false);
60 task = manager.getActiveTask();
61 assertTrue(task.isDefault());
63 presentation = doTest(combo);
64 if (!presentation.isVisible()) {
65 LocalTask activeTask = manager.getActiveTask();
66 System.out.println(activeTask);
67 System.out.println(activeTask.getCreated());
68 System.out.println(activeTask.getUpdated());
73 private static Presentation doTest(AnAction action) {
74 TestActionEvent event = new TestActionEvent(action);
76 return event.getPresentation();
79 @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
81 IdeaTestCase.initPlatformPrefix();