X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lttng%2Forg.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests%2Fsrc%2Forg%2Feclipse%2Ftracecompass%2Flttng2%2Fust%2Fui%2Fswtbot%2Ftests%2FCallStackViewTest.java;h=25f7d5f00ff0f86108b644c0c0e844512cfc258d;hb=f0beeb4aa356d812661dfa658bfd15a4a1e76e30;hp=53eb9e243d886c7ba5f64acdcb2365b8f6e125ee;hpb=66838307598d512bc33e18e512d1ef10838d8620;p=deliverable%2Ftracecompass.git diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java index 53eb9e243d..25f7d5f00f 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * 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 @@ -18,7 +18,9 @@ import static org.junit.Assert.assertNotNull; 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; @@ -35,10 +37,11 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; 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; @@ -84,32 +87,38 @@ public class CallStackViewTest { * 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"; @@ -117,11 +126,16 @@ public class CallStackViewTest { // Separator private static final String PIN_VIEW = "Pin View"; private static final List 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); @@ -131,7 +145,7 @@ public class CallStackViewTest { */ @BeforeClass public static void init() { - SWTBotUtils.failIfUIThread(); + SWTBotUtils.initialize(); Thread.currentThread().setName("SWTBot Thread"); // for the debugger /* set up for swtbot */ @@ -143,7 +157,7 @@ public class CallStackViewTest { SWTBotUtils.switchToTracingPerspective(); /* finish waiting for eclipse to load */ - SWTBotUtils.waitForJobs(); + WaitUtils.waitForJobs(); } /** @@ -158,7 +172,7 @@ public class CallStackViewTest { 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(); } /** @@ -176,14 +190,15 @@ public class CallStackViewTest { @Test public void testOpenCallstack() { String node = "glxgears-cyg-profile"; + String processName = "UNKNOWN"; String childName = "glxgears-16073"; - List expected = ImmutableList.of("40472b", "", "", "", ""); + List 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 names = treeItem.getNode(childName).getNodes(); assertEquals(expected, names); @@ -198,7 +213,7 @@ public class CallStackViewTest { final SWTBotView viewBot = fBot.viewById(CallStackView.ID); viewBot.setFocus(); - SWTBotUtils.waitForJobs(); + WaitUtils.waitForJobs(); List names = getVisibleStackFrames(viewBot); assertArrayEquals(STACK_FRAMES[0], names.toArray()); } @@ -214,32 +229,32 @@ public class CallStackViewTest { 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(); } /** @@ -255,28 +270,28 @@ public class CallStackViewTest { viewBot.toolbarToggleButton(SORT_BY_ID).click(); viewBot.toolbarToggleButton(SORT_BY_START).click(); viewBot.setFocus(); - SWTBotUtils.waitForJobs(); + WaitUtils.waitForJobs(); List names = getVisibleStackFrames(viewBot); assertArrayEquals(STACK_FRAMES[0], names.toArray()); } private static List getVisibleStackFrames(final SWTBotView viewBot) { SWTBotTree tree = viewBot.bot().tree(); - List 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)); } @@ -291,7 +306,7 @@ public class CallStackViewTest { viewBot.setFocus(); // no way to load mappings yet! :( SWTBotTree tree = viewBot.bot().tree(); - SWTBotUtils.waitForJobs(); + WaitUtils.waitForJobs(); List names = new ArrayList<>(); for (SWTBotTreeItem swtBotTreeItem : tree.getAllItems()) { for (SWTBotTreeItem items : swtBotTreeItem.getItems()) {