lttng.swtbot: add test to open and re-open time graph views.
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Mon, 21 Nov 2016 16:36:07 +0000 (11:36 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Mon, 21 Nov 2016 20:59:34 +0000 (15:59 -0500)
This removes 4 manual tests. ControlFlowView 1.3 and 1.4 and
ResourcesView 1.3 and 1.4.

Change-Id: I28c4b0bae9d5e6a846ac619c22e97d1df8ad47a8
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/85429
Reviewed-by: Jonathan Rajotte Julien <jonathan.rajotte-julien@efficios.com>
Reviewed-by: Hudson CI
Reviewed-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Tested-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/KernelTimeGraphViewTestBase.java
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ResourcesViewTest.java

index 5cee455f183cff832f35edc348549518f3fca0b9..14602cbfbac9a0fedadc3f352cbbf765ad8e8e76 100644 (file)
@@ -31,6 +31,7 @@ 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.internal.analysis.os.linux.ui.views.controlflow.ControlFlowView;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
 import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
@@ -41,6 +42,7 @@ 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.SWTBotTimeGraph;
 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraphEntry;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
 import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView;
 import org.eclipse.ui.IWorkbenchPart;
 import org.junit.Before;
@@ -87,6 +89,12 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
         return fBot.viewByTitle("Control Flow");
     }
 
+    @Override
+    protected SWTBotView openView() {
+        SWTBotUtils.openView(ControlFlowView.ID);
+        return getViewBot();
+    }
+
     @Override
     protected List<String> getLegendValues() {
         return Arrays.asList("UNKNOWN", "WAIT_UNKNOWN", "WAIT_BLOCKED", "WAIT_FOR_CPU", "USERMODE", "SYSCALL", "INTERRUPTED");
index b0b585169db31e21548ade06965daecd7253eec8..41a98c3f6751c7ff07f5070dc01dbe107338a8fc 100644 (file)
@@ -14,12 +14,19 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
 import org.eclipse.swtbot.swt.finder.SWTBot;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraphEntry;
 import org.junit.Test;
 
 /**
@@ -57,6 +64,13 @@ public abstract class KernelTimeGraphViewTestBase extends KernelTestBase {
      */
     protected abstract List<String> getLegendValues();
 
+    /**
+     * Opens the view
+     *
+     * @return the view bot
+     */
+    protected abstract SWTBotView openView();
+
     /**
      * Test toolbar button order and that all buttons are enabled and visible
      */
@@ -91,4 +105,32 @@ public abstract class KernelTimeGraphViewTestBase extends KernelTestBase {
         bot.button("OK").click();
     }
 
+    /**
+     * Test that re-opening a view repoopulates it properly.
+     */
+    @Test
+    public void testOpenCloseOpen() {
+        SWTBotView viewBot = openView();
+        SWTBotTimeGraph tgBot = new SWTBotTimeGraph(viewBot.bot());
+        Map<String, List<String>> before = getItemNames(tgBot);
+        viewBot.close();
+        viewBot = openView();
+        tgBot = new SWTBotTimeGraph(viewBot.bot());
+        Map<String, List<String>> after = getItemNames(tgBot);
+        assertEquals(before, after);
+    }
+
+    private @NonNull static Map<String, List<String>> getItemNames(SWTBotTimeGraph tgBot) {
+        Map<String, List<String>> returnStructure = new HashMap<>();
+        for (SWTBotTimeGraphEntry element : tgBot.getEntries()) {
+            returnStructure.put(element.getText(),
+                    Arrays.stream(
+                        element.getEntries())
+                        .map(tgEntry -> tgEntry.getText())
+                        .collect(Collectors.toList())
+                    );
+        }
+        return returnStructure;
+    }
+
 }
\ No newline at end of file
index c99e1ab93646826caa511c779519ae0207abc983..585b32ba25399d9ab1d8c8032c3d4931208d68b2 100644 (file)
@@ -41,6 +41,7 @@ import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
 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.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphMarkerAxis;
@@ -93,6 +94,12 @@ public class ResourcesViewTest extends KernelTimeGraphViewTestBase {
         return Arrays.asList("IDLE", "USERMODE", "SYSCALL", "IRQ", "SOFT_IRQ", "IRQ_ACTIVE", "SOFT_IRQ_RAISED", "SOFT_IRQ_ACTIVE");
     }
 
+    @Override
+    protected SWTBotView openView() {
+        SWTBotUtils.openView(ResourcesView.ID);
+        return getViewBot();
+    }
+
     @Override
     protected List<String> getToolbarTooltips() {
         return Arrays.asList("Align Views", "Show View Filters", "Show Legend", SEPARATOR,
This page took 0.027408 seconds and 5 git commands to generate.