/*******************************************************************************
- * Copyright (c) 2015 Ericsson
+ * Copyright (c) 2015, 2016 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
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.tests.shared.WaitUtils;
import org.eclipse.tracecompass.tmf.ui.views.callstack.CallStackView;
import org.junit.After;
import org.junit.Before;
* Stack frames of consecutive events in the trace
*/
private static final String[] STACK_FRAMES[] = new String[][] {
- {"40472b", "4045c8", "404412", "", ""},
- {"40472b", "4045c8", "404412", "40392b", ""},
- {"40472b", "4045c8", "404412", "", ""},
- {"40472b", "4045c8", "", "", ""},
- {"40472b", "4045c8", "404412", "", ""},
- {"40472b", "4045c8", "404412", "40392b", ""},
- {"40472b", "4045c8", "404412", "", ""},
- {"40472b", "4045c8", "", "", ""},
- {"40472b", "4045c8", "404412", "", ""},
- {"40472b", "4045c8", "404412", "40392b", ""},
- {"40472b", "4045c8", "404412", "", ""},
+ {"0x40472b", "0x4045c8", "0x404412", "", ""},
+ {"0x40472b", "0x4045c8", "0x404412", "0x40392b", ""},
+ {"0x40472b", "0x4045c8", "0x404412", "", ""},
+ {"0x40472b", "0x4045c8", "", "", ""},
+ {"0x40472b", "0x4045c8", "0x404412", "", ""},
+ {"0x40472b", "0x4045c8", "0x404412", "0x40392b", ""},
+ {"0x40472b", "0x4045c8", "0x404412", "", ""},
+ {"0x40472b", "0x4045c8", "", "", ""},
+ {"0x40472b", "0x4045c8", "0x404412", "", ""},
+ {"0x40472b", "0x4045c8", "0x404412", "0x40392b", ""},
+ {"0x40472b", "0x4045c8", "0x404412", "", ""},
};
/** Tooltips of the toolbar buttons */
private static final @NonNull String ALIGN_VIEWS = "Align Views";
- private static final @NonNull String IMPORT_BINARY = "Import a binary file containing debugging symbols";
- private static final @NonNull String IMPORT_TEXT = "Import a text file containing the mapping between addresses and function names";
+ private static final @NonNull String CONFIGURE_SYMBOL_PROVIDERS = "Configure how the addresses are mapped to function names";
// Separator
private static final @NonNull String SORT_BY_NAME = "Sort threads by thread name";
private static final @NonNull String SORT_BY_ID = "Sort threads by thread id";
private static final @NonNull String SORT_BY_START = "Sort threads by start time";
// Separator
+ private static final @NonNull String SHOW_VIEW_FILTERS = "Show View Filters";
+ // Separator
private static final @NonNull String RESET_TIME_SCALE = "Reset the Time Scale to Default";
- private static final @NonNull String SELECT_PREVIOUS_EVENT = "Select Previous Event";
- private static final @NonNull String SELECT_NEXT_EVENT = "Select Next Event";
+ private static final @NonNull String SELECT_PREVIOUS_STATE_CHANGE = "Select Previous State Change";
+ private static final @NonNull String SELECT_NEXT_STATE_CHANGE = "Select Next State Change";
+ // Separator
+ private static final @NonNull String ADD_BOOKMARK = "Add Bookmark...";
+ private static final @NonNull String PREVIOUS_MARKER = "Previous Marker";
+ private static final @NonNull String NEXT_MARKER = "Next Marker";
+ // Separator
private static final @NonNull String SELECT_PREVIOUS_ITEM = "Select Previous Item";
private static final @NonNull String SELECT_NEXT_ITEM = "Select Next Item";
private static final @NonNull String ZOOM_IN = "Zoom In";
// Separator
private static final String PIN_VIEW = "Pin View";
private static final List<String> TOOLBAR_BUTTONS_TOOLTIPS = ImmutableList.of(
- ALIGN_VIEWS, IMPORT_BINARY, IMPORT_TEXT,
+ ALIGN_VIEWS, CONFIGURE_SYMBOL_PROVIDERS,
"",
SORT_BY_NAME, SORT_BY_ID, SORT_BY_START,
"",
- RESET_TIME_SCALE, SELECT_PREVIOUS_EVENT, SELECT_NEXT_EVENT,
+ SHOW_VIEW_FILTERS,
+ "",
+ RESET_TIME_SCALE, SELECT_PREVIOUS_STATE_CHANGE, SELECT_NEXT_STATE_CHANGE,
+ "",
+ ADD_BOOKMARK, PREVIOUS_MARKER, NEXT_MARKER,
+ "",
SELECT_PREVIOUS_ITEM, SELECT_NEXT_ITEM, ZOOM_IN, ZOOM_OUT,
"",
PIN_VIEW);
*/
@BeforeClass
public static void init() {
- SWTBotUtils.failIfUIThread();
+ SWTBotUtils.initialize();
Thread.currentThread().setName("SWTBot Thread"); // for the debugger
/* set up for swtbot */
SWTBotUtils.switchToTracingPerspective();
/* finish waiting for eclipse to load */
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
}
/**
final File file = new File(CtfTmfTestTraceUtils.getTrace(cygProfile).getPath());
SWTBotUtils.openTrace(PROJECT_NAME, file.getAbsolutePath(), UST_ID);
SWTBotUtils.openView(CallStackView.ID);
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
}
/**
@Test
public void testOpenCallstack() {
String node = "glxgears-cyg-profile";
+ String processName = "UNKNOWN";
String childName = "glxgears-16073";
- List<String> expected = ImmutableList.of("40472b", "", "", "", "");
+ List<String> expected = ImmutableList.of("0x40472b", "", "", "", "");
SWTBotView viewBot = fBot.viewById(CallStackView.ID);
viewBot.setFocus();
final SWTBotView viewBot1 = viewBot;
SWTBotTree tree = viewBot1.bot().tree();
- SWTBotTreeItem treeItem = tree.getTreeItem(node);
+ SWTBotTreeItem treeItem = tree.getTreeItem(node).getNode(processName);
assertEquals(childName, treeItem.getNodes().get(0));
List<String> names = treeItem.getNode(childName).getNodes();
assertEquals(expected, names);
final SWTBotView viewBot = fBot.viewById(CallStackView.ID);
viewBot.setFocus();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
List<String> names = getVisibleStackFrames(viewBot);
assertArrayEquals(STACK_FRAMES[0], names.toArray());
}
final SWTBotView viewBot = fBot.viewById(CallStackView.ID);
// forward 10 times
for (int i = 0; i < 10; i++) {
- viewBot.toolbarPushButton(SELECT_NEXT_EVENT).click();
+ viewBot.toolbarPushButton(SELECT_NEXT_STATE_CHANGE).click();
currentEventOffset++;
fBot.waitUntil(ConditionHelpers.selectionInEventsTable(fBot, TIMESTAMPS[currentEventOffset]));
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
assertArrayEquals(STACK_FRAMES[currentEventOffset], getVisibleStackFrames(viewBot).toArray());
}
// back twice
for (int i = 0; i < 2; i++) {
- viewBot.toolbarPushButton(SELECT_PREVIOUS_EVENT).click();
+ viewBot.toolbarPushButton(SELECT_PREVIOUS_STATE_CHANGE).click();
currentEventOffset--;
fBot.waitUntil(ConditionHelpers.selectionInEventsTable(fBot, TIMESTAMPS[currentEventOffset]));
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
assertArrayEquals(STACK_FRAMES[currentEventOffset], getVisibleStackFrames(viewBot).toArray());
}
// move up and down once to make sure it doesn't explode
viewBot.toolbarPushButton(SELECT_PREVIOUS_ITEM).click();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
viewBot.toolbarPushButton(SELECT_NEXT_ITEM).click();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
// Zoom in and out too
viewBot.toolbarPushButton(ZOOM_IN).click();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
viewBot.toolbarPushButton(ZOOM_OUT).click();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
}
/**
viewBot.toolbarToggleButton(SORT_BY_ID).click();
viewBot.toolbarToggleButton(SORT_BY_START).click();
viewBot.setFocus();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
List<String> names = getVisibleStackFrames(viewBot);
assertArrayEquals(STACK_FRAMES[0], names.toArray());
}
private static List<String> getVisibleStackFrames(final SWTBotView viewBot) {
SWTBotTree tree = viewBot.bot().tree();
- List<String> names = new ArrayList<>();
- for (SWTBotTreeItem swtBotTreeItem : tree.getAllItems()) {
- for (SWTBotTreeItem items : swtBotTreeItem.getItems()) {
- for (SWTBotTreeItem item : items.getItems()) {
- names.add(item.cell(0));
- }
- }
- }
- return names;
+ return Arrays.stream(tree.getAllItems())
+ // Process entries
+ .flatMap(item -> Arrays.stream(item.getItems()))
+ // Thread entries
+ .flatMap(item -> Arrays.stream(item.getItems()))
+ // Callstack entries
+ .flatMap(item -> Arrays.stream(item.getItems()))
+ .map(item -> item.cell(0))
+ .collect(Collectors.toList());
}
private static void goToTime(long timestamp) {
SWTBotTable table = fBot.activeEditor().bot().table();
table.setFocus();
- TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(table.widget, new TmfNanoTimestamp(timestamp)));
+ TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(table.widget, TmfTimestamp.fromNanos(timestamp)));
fBot.waitUntil(ConditionHelpers.selectionInEventsTable(fBot, timestamp));
}
viewBot.setFocus();
// no way to load mappings yet! :(
SWTBotTree tree = viewBot.bot().tree();
- SWTBotUtils.waitForJobs();
+ WaitUtils.waitForJobs();
List<String> names = new ArrayList<>();
for (SWTBotTreeItem swtBotTreeItem : tree.getAllItems()) {
for (SWTBotTreeItem items : swtBotTreeItem.getItems()) {