X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lttng%2Forg.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests%2Fsrc%2Forg%2Feclipse%2Ftracecompass%2Flttng2%2Fkernel%2Fui%2Fswtbot%2Ftests%2FControlFlowViewTest.java;h=f8655d702f219f32bfada65f3b2d6cebb40589d1;hb=946539479db4d4e1448736945420fd62ff9c8ccc;hp=62b81255a789a22b1fb7c78e552d0be86d136f20;hpb=d33eb61061c384ed367b6690f65b014ea7ec4bfa;p=deliverable%2Ftracecompass.git diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java index 62b81255a7..f8655d702f 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java @@ -16,6 +16,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import org.eclipse.jdt.annotation.NonNull; import org.eclipse.swt.SWT; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; @@ -31,7 +35,7 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel; import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.eclipse.tracecompass.ctf.core.tests.shared.LttngKernelTraceGenerator; +import org.eclipse.tracecompass.ctf.core.tests.shared.LttngTraceGenerator; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; @@ -40,6 +44,7 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; +import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl; import org.eclipse.ui.IWorkbenchPart; @@ -55,6 +60,7 @@ import org.junit.runner.RunWith; @RunWith(SWTBotJunit4ClassRunner.class) public class ControlFlowViewTest extends KernelTestBase { + private static final String SEPARATOR = ""; private static final String CHECK_SELECTED = "Check selected"; private static final String CHECK_ALL = "Check all"; private static final String CHECK_SUBTREE = "Check subtree"; @@ -64,7 +70,6 @@ public class ControlFlowViewTest extends KernelTestBase { private static final String UNCHECK_SUBTREE = "Uncheck subtree"; private static final String UNCHECK_INACTIVE = "Uncheck Inactive"; - private static final String FOLLOW_CPU_BACKWARD = "Follow CPU Backward"; private static final String FOLLOW_CPU_FORWARD = "Follow CPU Forward"; private static final String SELECT_PREVIOUS_STATE_CHANGE = "Select Previous State Change"; @@ -86,6 +91,32 @@ public class ControlFlowViewTest extends KernelTestBase { private SWTBotView fViewBot; + /** + * Get the legend text values in order (override if you subclass the test) + * + * @return the legend text values in order + */ + protected List getLegendValues() { + String[] labelValues = { "UNKNOWN", "WAIT_UNKNOWN", "WAIT_BLOCKED", "WAIT_FOR_CPU", "USERMODE", "SYSCALL", "INTERRUPTED" }; + return Arrays.asList(labelValues); + } + + /** + * Get the tool bar tool tip text values in order (override if you subclass the test) + * + * @return the tool bar tool tip text values in order + */ + protected List getToolbarTooltips() { + String[] tooltipsArray = { "Align Views", "Optimize", SEPARATOR, + "Show View Filters", "Show Legend", SEPARATOR, + "Reset the Time Scale to Default", "Select Previous State Change", "Select Next State Change", SEPARATOR, + "Add Bookmark...", "Previous Marker", "Next Marker", SEPARATOR, + "Select Previous Process", "Select Next Process", "Zoom In", "Zoom Out", SEPARATOR, + "Hide Arrows", "Follow CPU Backward", "Follow CPU Forward", + "Go to previous event of the selected thread", "Go to next event of the selected thread" }; + return Arrays.asList(tooltipsArray); + } + /** * Before Test */ @@ -110,7 +141,8 @@ public class ControlFlowViewTest extends KernelTestBase { } /** - * Test tool bar buttons "Select Next State Change" and "Select Previous State Change" + * Test tool bar buttons "Select Next State Change" and "Select Previous + * State Change" */ @Test public void testToolBarSelectNextPreviousStateChange() { @@ -131,8 +163,7 @@ public class ControlFlowViewTest extends KernelTestBase { timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME)); /* select first item */ - final SWTBotTree tree = fViewBot.bot().tree(); - tree.pressShortcut(Keystrokes.HOME); + SWTBotUtils.pressShortcutGoToTreeTop(KEYBOARD); fViewBot.toolbarButton(SELECT_NEXT_PROCESS).click(); /* set focus on time graph */ @@ -221,20 +252,36 @@ public class ControlFlowViewTest extends KernelTestBase { assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(START_TIME)); } + /** + * Test toolbar button order and that all buttons are enabled and visible + */ + @Test + public void testToolbar() { + List buttons = fViewBot.getToolbarButtons(); + List tooltipsExpected = getToolbarTooltips(); + List tooltips = new ArrayList<>(); + for (SWTBotToolbarButton button : buttons) { + tooltips.add(button.getToolTipText()); + assertTrue(button.getText() + " enabled", button.isEnabled()); + assertTrue(button.getText() + " visible", button.isVisible()); + } + assertEquals(tooltipsExpected, tooltips); + } + /** * Test the legend content */ @Test public void testLegend() { - String[] labelValues = { "UNKNOWN", "WAIT_UNKNOWN", "WAIT_BLOCKED", "WAIT_FOR_CPU", "USERMODE", "SYSCALL", "INTERRUPTED" }; + List labelValues = getLegendValues(); SWTBotToolbarButton legendButton = fViewBot.toolbarButton("Show Legend"); legendButton.click(); fBot.waitUntil(org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive("States Transition Visualizer")); SWTBot bot = fBot.activeShell().bot(); - for (int i = 1; i < 8; i++) { + for (int i = 1; i <= labelValues.size(); i++) { SWTBotLabel label = bot.label(i); assertNotNull(label); - assertEquals(labelValues[i - 1], label.getText()); + assertEquals(labelValues.get(i - 1), label.getText()); } bot.button("OK").click(); } @@ -275,7 +322,7 @@ public class ControlFlowViewTest extends KernelTestBase { checked = UIThreadRunnable.syncExec(treeCheckCounter); assertEquals(UNCHECK_INACTIVE, 69, checked.intValue()); // test check selected - treeBot.getTreeItem(LttngKernelTraceGenerator.getName()).select("gnuplot"); + treeBot.getTreeItem(LttngTraceGenerator.getName()).select("gnuplot"); bot.button(UNCHECK_ALL).click(); bot.button(CHECK_SELECTED).click(); checked = UIThreadRunnable.syncExec(treeCheckCounter); @@ -300,7 +347,7 @@ public class ControlFlowViewTest extends KernelTestBase { checked = UIThreadRunnable.syncExec(treeCheckCounter); assertEquals(0, checked.intValue()); bot.text().setText("half-life 3"); - SWTBotTreeItem treeItem = treeBot.getTreeItem(LttngKernelTraceGenerator.getName()); + SWTBotTreeItem treeItem = treeBot.getTreeItem(LttngTraceGenerator.getName()); treeItem.rowCount(); fBot.waitUntil(ConditionHelpers.treeItemCount(treeItem, 25)); bot.button(CHECK_ALL).click(); @@ -308,7 +355,7 @@ public class ControlFlowViewTest extends KernelTestBase { assertEquals("Filtered", 26, checked.intValue()); bot.button("OK").click(); treeBot = fViewBot.bot().tree(); - treeItem = treeBot.getTreeItem(LttngKernelTraceGenerator.getName()); + treeItem = treeBot.getTreeItem(LttngTraceGenerator.getName()); for (int i = 0; i < 25; i++) { assertEquals("Filtered Control flow view", "Half-life 3", treeItem.cell(i, 0)); } @@ -330,7 +377,7 @@ public class ControlFlowViewTest extends KernelTestBase { /* select first item */ final SWTBotTree tree = fViewBot.bot().tree(); - tree.pressShortcut(Keystrokes.HOME); + SWTBotUtils.pressShortcutGoToTreeTop(KEYBOARD); fViewBot.toolbarButton(SELECT_NEXT_PROCESS).click(); /* set focus on time graph */