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;
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.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;
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;
@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";
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_EVENT = "Select Previous Event";
- private static final String SELECT_NEXT_EVENT = "Select Next Event";
+ private static final String SELECT_PREVIOUS_STATE_CHANGE = "Select Previous State Change";
+ private static final String SELECT_NEXT_STATE_CHANGE = "Select Next State Change";
+ private static final String SELECT_NEXT_PROCESS = "Select Next Process";
private static final Keyboard KEYBOARD = KeyboardFactory.getSWTKeyboard();
private static final @NonNull ITmfTimestamp START_TIME = TmfTimestamp.fromNanos(1368000272650993664L);
private static final @NonNull ITmfTimestamp TID1_TIME1 = TmfTimestamp.fromNanos(1368000272651208412L);
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<String> 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<String> 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
*/
}
/**
- * Test tool bar buttons "Select Next Event" and "Select Previous Event"
+ * Test tool bar buttons "Select Next State Change" and "Select Previous
+ * State Change"
*/
@Test
- public void testToolBarSelectNextPreviousEvent() {
- testNextPreviousEvent(() -> fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(),
- () -> fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(SWT.SHIFT),
- () -> fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(),
- () -> fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(SWT.SHIFT));
+ public void testToolBarSelectNextPreviousStateChange() {
+ testNextPreviousEvent(() -> fViewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(),
+ () -> fViewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(SWT.SHIFT),
+ () -> fViewBot.toolbarButton(SELECT_PREVIOUS_STATE_CHANGE).click(),
+ () -> fViewBot.toolbarButton(SELECT_PREVIOUS_STATE_CHANGE).click(SWT.SHIFT));
}
private void testNextPreviousEvent(Runnable selectNext, Runnable shiftSelectNext, Runnable selectPrevious, Runnable shiftSelectPrevious) {
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 */
final TimeGraphControl timegraph = fViewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class));
}
});
- /* click "Select Next Event" 3 times */
+ /* click "Select Next State Change" 3 times */
selectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1));
selectNext.run();
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME3)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME3));
- /* shift-click "Select Next Event" 3 times */
+ /* shift-click "Select Next State Change" 3 times */
shiftSelectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME4));
shiftSelectNext.run();
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME6)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME6));
- /* shift-click "Select Previous Event" 4 times */
+ /* shift-click "Select Previous State Change" 4 times */
shiftSelectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME5));
shiftSelectPrevious.run();
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME2)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME2));
- /* click "Select Next Event" 2 times */
+ /* click "Select Next State Change" 2 times */
selectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME3));
selectNext.run();
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME4)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME4));
- /* shift-click "Select Previous Event" 3 times */
+ /* shift-click "Select Previous State Change" 3 times */
shiftSelectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME3));
shiftSelectPrevious.run();
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME1)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME1));
- /* shift-click "Select Next Event" 4 times */
+ /* shift-click "Select Next State Change" 4 times */
shiftSelectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME2));
shiftSelectNext.run();
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME5)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME5));
- /* click "Select Previous Event" 5 times */
+ /* click "Select Previous State Change" 5 times */
selectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME4));
selectPrevious.run();
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<SWTBotToolbarButton> buttons = fViewBot.getToolbarButtons();
+ List<String> tooltipsExpected = getToolbarTooltips();
+ List<String> 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<String> 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();
}
TreeCheckedCounter treeCheckCounter = new TreeCheckedCounter(treeBot);
// get how many items there are
Integer checked = UIThreadRunnable.syncExec(treeCheckCounter);
- assertEquals("default", 225, checked.intValue());
+ assertEquals("default", 226, checked.intValue());
// test "uncheck all button"
bot.button(UNCHECK_ALL).click();
checked = UIThreadRunnable.syncExec(treeCheckCounter);
// test check active
bot.button(CHECK_ACTIVE).click();
checked = UIThreadRunnable.syncExec(treeCheckCounter);
- assertEquals(CHECK_ACTIVE, 68, checked.intValue());
+ assertEquals(CHECK_ACTIVE, 69, checked.intValue());
// test check all
bot.button(CHECK_ALL).click();
checked = UIThreadRunnable.syncExec(treeCheckCounter);
- assertEquals(CHECK_ALL, 225, checked.intValue());
+ assertEquals(CHECK_ALL, 226, checked.intValue());
// test uncheck inactive
bot.button(UNCHECK_INACTIVE).click();
checked = UIThreadRunnable.syncExec(treeCheckCounter);
- assertEquals(UNCHECK_INACTIVE, 68, checked.intValue());
+ assertEquals(UNCHECK_INACTIVE, 69, checked.intValue());
// test check selected
- treeBot.select(1);
+ treeBot.getTreeItem(LttngTraceGenerator.getName()).select("gnuplot");
bot.button(UNCHECK_ALL).click();
bot.button(CHECK_SELECTED).click();
checked = UIThreadRunnable.syncExec(treeCheckCounter);
- assertEquals(CHECK_SELECTED, 1, checked.intValue());
+ assertEquals(CHECK_SELECTED, 2, checked.intValue());
// test check subtree
bot.button(UNCHECK_ALL).click();
bot.button(CHECK_SUBTREE).click();
checked = UIThreadRunnable.syncExec(treeCheckCounter);
- assertEquals(CHECK_SUBTREE, 1, checked.intValue());
+ assertEquals(CHECK_SUBTREE, 2, checked.intValue());
// test uncheck selected
bot.button(CHECK_ALL).click();
bot.button(UNCHECK_SELECTED).click();
checked = UIThreadRunnable.syncExec(treeCheckCounter);
- assertEquals(UNCHECK_SELECTED, 224, checked.intValue());
+ assertEquals(UNCHECK_SELECTED, 225, checked.intValue());
// test uncheck subtree
bot.button(CHECK_ALL).click();
bot.button(UNCHECK_SUBTREE).click();
checked = UIThreadRunnable.syncExec(treeCheckCounter);
- assertEquals(UNCHECK_SELECTED, 224, checked.intValue());
+ assertEquals(UNCHECK_SELECTED, 225, checked.intValue());
// test filter
bot.button(UNCHECK_ALL).click();
checked = UIThreadRunnable.syncExec(treeCheckCounter);
assertEquals(0, checked.intValue());
bot.text().setText("half-life 3");
- fBot.waitUntil(org.eclipse.swtbot.swt.finder.waits.Conditions.treeHasRows(treeBot, 25));
+ SWTBotTreeItem treeItem = treeBot.getTreeItem(LttngTraceGenerator.getName());
+ treeItem.rowCount();
+ fBot.waitUntil(ConditionHelpers.treeItemCount(treeItem, 25));
bot.button(CHECK_ALL).click();
checked = UIThreadRunnable.syncExec(treeCheckCounter);
- assertEquals("Filtered", 25, checked.intValue());
+ assertEquals("Filtered", 26, checked.intValue());
bot.button("OK").click();
treeBot = fViewBot.bot().tree();
+ treeItem = treeBot.getTreeItem(LttngTraceGenerator.getName());
for (int i = 0; i < 25; i++) {
- assertEquals("Filtered Control flow view", "Half-life 3", treeBot.cell(i, 0));
+ assertEquals("Filtered Control flow view", "Half-life 3", treeItem.cell(i, 0));
}
}
/* 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 */
final TimeGraphControl timegraph = fViewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class));