Search in sources :

Example 1 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class ControlFlowViewTest method testDynamicFiltersDialog.

/**
 * Test dynamic filters dialog
 */
@Test
public void testDynamicFiltersDialog() {
    String valid_cpu_ranges = "0,1,2-100";
    String invalid_cpu_ranges = "-1,1";
    /* Change window range to 10 ms */
    TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, range.getStartTime(), range.getEndTime()));
    timeGraphIsReadyCondition(range);
    getViewBot().viewMenu(DYNAMIC_FILTER_CONFIGURE_LABEL).click();
    SWTBotShell shell = fBot.shell(DYNAMIC_FILTERS_SHELL_TEXT).activate();
    /* Make sure nothing is checked and radio buttons are disabled */
    SWTBotCheckBox activeThreadsCheckbox = shell.bot().checkBox(DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX);
    SWTBotRadio onCpuRadio = shell.bot().radio(DYNAMIC_FILTERS_ON_CPU_RADIO);
    SWTBotRadio allActiveRadio = shell.bot().radio(DYNAMIC_FILTERS_ALL_ACTIVE_RADIO);
    SWTBotText onCpuField = shell.bot().textWithMessage(DYNAMIC_FILTER_ON_CPU_FIELD_MESSAGE);
    assertFalse(activeThreadsCheckbox.isChecked());
    assertFalse(onCpuRadio.isEnabled());
    assertFalse(allActiveRadio.isEnabled());
    assertFalse(onCpuField.isEnabled());
    /*
         * Test Active Filter buttons toggle
         */
    activeThreadsCheckbox.click();
    /* All objects should be enabled except for the CPU ranges field */
    assertTrue(activeThreadsCheckbox.isChecked());
    assertTrue(allActiveRadio.isEnabled());
    assertTrue(onCpuRadio.isEnabled());
    assertFalse(onCpuField.isEnabled());
    /*
         * The All Active Threads option should be the default for a new filter
         */
    assertTrue(allActiveRadio.isSelected());
    /*
         * Select All Threads on CPUs option
         */
    onCpuRadio.click();
    /* All objects should be enabled */
    assertTrue(activeThreadsCheckbox.isChecked());
    assertTrue(allActiveRadio.isEnabled());
    assertTrue(onCpuRadio.isEnabled());
    assertTrue(onCpuField.isEnabled());
    assertFalse(allActiveRadio.isSelected());
    assertTrue(onCpuRadio.isSelected());
    /*
         * Select All Active Threads then Active Threads on CPUs to validate
         * toggle of options
         */
    allActiveRadio.click();
    /* All objects should be enabled except for the CPU ranges field */
    assertTrue(activeThreadsCheckbox.isChecked());
    assertTrue(allActiveRadio.isEnabled());
    assertTrue(onCpuRadio.isEnabled());
    assertFalse(onCpuField.isEnabled());
    assertTrue(allActiveRadio.isSelected());
    assertFalse(onCpuRadio.isSelected());
    /* Select Active Threads on CPUs */
    onCpuRadio.click();
    /* All objects should be enabled */
    assertTrue(activeThreadsCheckbox.isChecked());
    assertTrue(allActiveRadio.isEnabled());
    assertTrue(onCpuRadio.isEnabled());
    assertTrue(onCpuField.isEnabled());
    assertFalse(allActiveRadio.isSelected());
    assertTrue(onCpuRadio.isSelected());
    /* Put an invalid value in the CPU ranges field */
    onCpuField.setText(invalid_cpu_ranges);
    /* Make sure the OK button is not enabled when in an invalid state */
    assertFalse(shell.bot().button(DIALOG_OK).isEnabled());
    /* Put a valid value in the CPU ranges field */
    onCpuField.setText(valid_cpu_ranges);
    /* Make sure the OK button is enabled when in a valid state */
    assertTrue(shell.bot().button(DIALOG_OK).isEnabled());
    shell.bot().button(DIALOG_OK).click();
    timeGraphIsReadyCondition(range);
    /* Make sure that the quick Active Thread Filter toggle is checked */
    assertTrue(getViewBot().viewMenu(DYNAMIC_FILTER_ACTIVE_THREADS_ONLY_TOGGLE).isChecked());
    /* Make sure that the Flat presentation is checked */
    assertTrue(getViewBot().viewMenu(THREAD_PRESENTATION_FLAT).isChecked());
    assertFalse(getViewBot().viewMenu(THREAD_PRESENTATION_HIERARCHICAL).isChecked());
    /* Reopen the dialog */
    getViewBot().viewMenu(DYNAMIC_FILTER_CONFIGURE_LABEL).click();
    shell = fBot.shell(DYNAMIC_FILTERS_SHELL_TEXT).activate();
    /* Make sure nothing is checked and radio buttons are disabled */
    activeThreadsCheckbox = shell.bot().checkBox(DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX);
    onCpuRadio = shell.bot().radio(DYNAMIC_FILTERS_ON_CPU_RADIO);
    allActiveRadio = shell.bot().radio(DYNAMIC_FILTERS_ALL_ACTIVE_RADIO);
    onCpuField = shell.bot().textWithMessage(DYNAMIC_FILTER_ON_CPU_FIELD_MESSAGE);
    /* Make sure the previous settings are set correctly */
    assertTrue(activeThreadsCheckbox.isChecked());
    assertTrue(allActiveRadio.isEnabled());
    assertTrue(onCpuRadio.isEnabled());
    assertTrue(onCpuField.isEnabled());
    assertFalse(allActiveRadio.isSelected());
    assertTrue(onCpuRadio.isSelected());
    assertTrue(onCpuField.isEnabled());
    assertEquals("CPU ranges not equal", onCpuField.getText(), valid_cpu_ranges);
    /*
         * Change to All Active Threads option click OK then reopen. The
         * previous CPU range should still be there.
         */
    allActiveRadio.click();
    /* Make sure that the ranges are still visible but disabled */
    assertFalse(onCpuField.isEnabled());
    assertEquals("Cpu ranges not equal", onCpuField.getText(), valid_cpu_ranges);
    /* Close the dialog */
    shell.bot().button(DIALOG_OK).click();
    timeGraphIsReadyCondition(range);
    /* Open the dialog */
    getViewBot().viewMenu(DYNAMIC_FILTER_CONFIGURE_LABEL).click();
    shell = fBot.shell(DYNAMIC_FILTERS_SHELL_TEXT).activate();
    activeThreadsCheckbox = shell.bot().checkBox(DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX);
    onCpuRadio = shell.bot().radio(DYNAMIC_FILTERS_ON_CPU_RADIO);
    allActiveRadio = shell.bot().radio(DYNAMIC_FILTERS_ALL_ACTIVE_RADIO);
    onCpuField = shell.bot().textWithMessage(DYNAMIC_FILTER_ON_CPU_FIELD_MESSAGE);
    /* Range field should have a value in it */
    assertTrue(activeThreadsCheckbox.isChecked());
    assertTrue(allActiveRadio.isEnabled());
    assertTrue(onCpuRadio.isEnabled());
    assertFalse(onCpuField.isEnabled());
    assertTrue(allActiveRadio.isSelected());
    assertFalse(onCpuRadio.isSelected());
    assertFalse(onCpuField.isEnabled());
    assertEquals("CPU ranges not equal", onCpuField.getText(), valid_cpu_ranges);
    shell.bot().button(DIALOG_CANCEL).click();
}
Also used : SWTBotRadio(org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) SWTBotCheckBox(org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 2 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class ControlFlowViewTest method testToolBarFollowCPUForwardBackward.

/**
 * Test tool bar buttons "Follow CPU Forward" and "Follow CPU Backward"
 */
@Test
public void testToolBarFollowCPUForwardBackward() {
    /* change window range to 10 ms */
    TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
    fBot.waitUntil(ConditionHelpers.windowRange(range));
    /* set selection to trace start time */
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME));
    timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
    SWTBotView viewBot = getViewBot();
    /* set focus on time graph */
    SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(viewBot.bot());
    timeGraph.setFocus();
    /* select first thread */
    timeGraph.getEntry(LttngTraceGenerator.getName(), "gnuplot").select();
    /* click "Follow CPU Forward" 3 times */
    timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1));
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME1, TID2_TIME1));
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID2_TIME2)));
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
    assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME2));
    /* shift-click "Follow CPU Forward" 3 times */
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME3));
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4));
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID5_TIME1)));
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "5"));
    assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID5_TIME1));
    /* shift-click "Follow CPU Backward" 4 times */
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4));
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME3));
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME1));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID2_TIME1)));
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
    assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME1));
    /* click "Follow CPU Forward" 2 times */
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID2_TIME3)));
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
    assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME3));
    /* shift-click "Follow CPU Backward" 3 times */
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME2));
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME1));
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID1_TIME1));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID1_TIME1)));
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "1"));
    assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME1));
    /* shift-click "Follow CPU Forward" 4 times */
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME1));
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME2));
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3));
    viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME4));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID2_TIME4)));
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
    assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME4));
    /* click "Follow CPU Backward" 5 times */
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3));
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME1, TID2_TIME1));
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1));
    viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME)));
    assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(START_TIME));
}
Also used : TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) SWTBotTimeGraph(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Example 3 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class ControlFlowViewTest method testFilter.

/**
 * Test the filter
 */
@Test
public void testFilter() {
    /* change window range to 1 ms */
    TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(1000000L, ITmfTimestamp.NANOSECOND_SCALE));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
    timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
    SWTBotView viewBot = getViewBot();
    SWTBotToolbarButton filterButton = viewBot.toolbarButton("Show View Filters");
    filterButton.click();
    SWTBot bot = fBot.shell("Filter").activate().bot();
    SWTBotTree treeBot = bot.tree();
    // get how many items there are
    int checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("default", 226, checked);
    // test "uncheck all button"
    bot.button(UNCHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(0, checked);
    // test check active
    bot.button(CHECK_ACTIVE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_ACTIVE, 69, checked);
    // test check all
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_ALL, 226, checked);
    // test uncheck inactive
    bot.button(UNCHECK_INACTIVE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_INACTIVE, 69, checked);
    // test check selected
    treeBot.getTreeItem(LttngTraceGenerator.getName()).select("gnuplot");
    bot.button(UNCHECK_ALL).click();
    bot.button(CHECK_SELECTED).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_SELECTED, 2, checked);
    // test check subtree
    bot.button(UNCHECK_ALL).click();
    bot.button(CHECK_SUBTREE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_SUBTREE, 2, checked);
    // test uncheck selected
    bot.button(CHECK_ALL).click();
    bot.button(UNCHECK_SELECTED).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_SELECTED, 225, checked);
    // test uncheck subtree
    bot.button(CHECK_ALL).click();
    bot.button(UNCHECK_SUBTREE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_SELECTED, 225, checked);
    // test filter
    bot.button(UNCHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(0, checked);
    bot.text().setText("half-life 3");
    SWTBotTreeItem treeItem = treeBot.getTreeItem(LttngTraceGenerator.getName());
    treeItem.rowCount();
    fBot.waitUntil(ConditionHelpers.treeItemCount(treeItem, 25));
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("Filtered", 26, checked);
    bot.button(DIALOG_OK).click();
    SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(getViewBot().bot());
    SWTBotTimeGraphEntry traceEntry = timeGraph.getEntry(LttngTraceGenerator.getName());
    for (SWTBotTimeGraphEntry entry : traceEntry.getEntries()) {
        assertEquals("Filtered Control flow view", "Half-life 3", entry.getText());
    }
}
Also used : SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTimeGraph(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) SWTBotTimeGraphEntry(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraphEntry) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) Test(org.junit.Test)

Example 4 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class CriticalPathTest method testFull.

/**
 * test the behavior of the critical path for a thread selection signal from
 * the control flow view
 */
@Test
public void testFull() {
    SWTBotTimeGraph timeGraphCfv = new SWTBotTimeGraph(fViewBotCfv.bot());
    SWTBotTree treeCp = fViewBotCp.bot().tree();
    SWTBotTimeGraph timeGraphCp = new SWTBotTimeGraph(fViewBotCp.bot());
    assertNotNull(timeGraphCfv.widget);
    assertNotNull(treeCp.widget);
    SWTBotTreeItem[] allItems = treeCp.getAllItems();
    for (int i = 0; i < allItems.length; i++) {
        assertEquals(0, allItems[i].getNodes().size());
    }
    ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(trace);
    SWTBotTimeGraphEntry entry = timeGraphCfv.getEntry(trace.getName(), "systemd", "we", PROCESS);
    assertNotNull(entry);
    entry.select();
    SWTBotMenu menu = entry.contextMenu("Follow " + PROCESS + "/" + TID);
    assertEquals("Follow " + PROCESS + "/" + TID, menu.getText());
    menu.click();
    fBot.waitUntil(new DefaultCondition() {

        @Override
        public boolean test() throws Exception {
            SWTBotTimeGraphEntry[] entries = timeGraphCp.getEntries();
            return CRIT_PATH_MAIN_ENTRY.equals(entries[0].getEntries()[0].getText());
        }

        @Override
        public String getFailureMessage() {
            return "Could not find " + CRIT_PATH_MAIN_ENTRY + " in Critical Path view";
        }
    });
    // Test navigating the critical path view with the follow arrows buttons
    IWorkbenchPart part = fViewBotCp.getViewReference().getPart(false);
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, CPU_TIME0));
    SWTBotTimeGraphEntry critPathEntry = timeGraphCp.getEntry(trace.getHostId(), CRIT_PATH_MAIN_ENTRY);
    critPathEntry.select();
    // Condition to wait for the time graph view to refresh
    ICondition timeGraphIsReadyCondition = ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) part, new TmfTimeRange(CPU_TIME1, CPU_TIME1), CPU_TIME1);
    // Reach the end of the current event
    fViewBotCp.toolbarButton(FOLLOW_FORWARD).click();
    fBot.waitUntil(timeGraphIsReadyCondition);
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraphCp, 0, CRIT_PATH_MAIN_ENTRY));
    // Follow the arrow down to the next item
    fViewBotCp.toolbarButton(FOLLOW_FORWARD).click();
    fBot.waitUntil(timeGraphIsReadyCondition);
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraphCp, 0, CRIT_PATH_OTHER_ENTRY));
    // Make sure changing the selection changed the selection in CFV too
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraphCfv, 0, KWORKER_PROCESS));
    // Follow it back up
    fViewBotCp.toolbarButton(FOLLOW_BACKWARD).click();
    fBot.waitUntil(timeGraphIsReadyCondition);
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraphCp, 0, CRIT_PATH_MAIN_ENTRY));
    // Make sure changing the selection changed the selection in CFV too
    fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraphCfv, 0, PROCESS));
    // Follow another process and make sure the critical path changes
    entry = timeGraphCfv.getEntry(trace.getName(), "systemd", "we", PROCESS, PROCESS2);
    assertNotNull(entry);
    entry.select();
    menu = entry.contextMenu("Follow " + PROCESS2 + "/" + TID2);
    assertEquals("Follow " + PROCESS2 + "/" + TID2, menu.getText());
    menu.click();
    fBot.waitUntil(new DefaultCondition() {

        @Override
        public boolean test() throws Exception {
            SWTBotTimeGraphEntry[] entries = timeGraphCp.getEntries();
            return CRIT_PATH_MAIN_ENTRY2.equals(entries[0].getEntries()[0].getText());
        }

        @Override
        public String getFailureMessage() {
            return "Could not find " + CRIT_PATH_MAIN_ENTRY2 + " in Critical Path view";
        }
    });
}
Also used : SWTBotTimeGraph(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) IOException(java.io.IOException) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) DefaultCondition(org.eclipse.swtbot.swt.finder.waits.DefaultCondition) SWTBotTimeGraphEntry(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraphEntry) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition) Test(org.junit.Test)

Example 5 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class DisksIOViewTest method testDiskView.

/**
 * Test to check the Disks IO Activity view. First, when trace opened, there
 * should not be any activity. Then, we move to a time range where there are
 * write activity. Afterward, we test the zoom
 */
@Test
public void testDiskView() {
    // Wait for analysis to finish.
    WaitUtils.waitForJobs();
    IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
    assertTrue(viewPart instanceof DiskIOActivityView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    final Chart chart = getChart();
    assertNotNull(chart);
    SWTBotTreeItem[] items = getSWTBotView().bot().tree().getAllItems();
    for (SWTBotTreeItem item : items) {
        item.check();
    }
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 0, chart, "No data available");
    chartViewer.setNbPoints(NUMBER_OF_POINT);
    /* Initially, no disk activity */
    SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, WRITE_SERIES_NAME), "resources/disk/disk0-res50.json", "Chart data is not valid");
    /* Change time range where there is disks activity */
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, new TmfTimeRange(ZOOM_START_TIME, ZOOM_END_TIME)));
    fBot.waitUntil(ConditionHelpers.windowRange(new TmfTimeRange(ZOOM_START_TIME, ZOOM_END_TIME)));
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    /* Test type, style and color of series */
    verifyChartStyle();
    /* Test data model */
    SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, WRITE_SERIES_NAME), "resources/disk/disk1-res50.json", "Chart data is not valid");
    /* Change Zoom and number of points */
    chartViewer.setNbPoints(MORE_POINTS);
    /* Test type, style and color of series */
    verifyChartStyle();
    /* Test data model */
    SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, WRITE_SERIES_NAME), "resources/disk/disk2-res100.json", "Chart data is not valid");
}
Also used : DiskIOActivityView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.io.diskioactivity.DiskIOActivityView) IViewPart(org.eclipse.ui.IViewPart) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Aggregations

TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)168 Test (org.junit.Test)98 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)53 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)29 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)24 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)24 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)21 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)20 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)19 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)16 SWTBotTimeGraph (org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph)16 Vector (java.util.Vector)13 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)12 TmfTraceManager (org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager)10 ITmfEventProvider (org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider)9 AbstractTimeGraphView (org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView)9 TmfTraceContext (org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext)8 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)8 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)8 Point (org.eclipse.swt.graphics.Point)7