lttng.swtbot: add state system explorer SWTBot test
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 9 Nov 2016 04:29:06 +0000 (23:29 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 15 Dec 2016 20:37:50 +0000 (15:37 -0500)
This test runs three passes, opens the view, re-opens the view
then re-opens the trace.

Future tests can look at the content of the state system. This
test enumerates the state systems available.

Change-Id: I3136bb4bfc802d958d63981d7ca358f44248f0be
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/84711
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Hudson CI
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ImportAndReadKernelSmokeTest.java

index c6524c9f7fea23db0bc252f79fb652f33b8a78a2..bee4bf89b168f97c3c83c1e7f8bf6cefa4093f3f 100644 (file)
 
 package org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests;
 
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.treeHasRows;
+import static org.junit.Assert.assertEquals;
 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.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
@@ -27,6 +33,8 @@ import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
 import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
 import org.eclipse.swtbot.swt.finder.results.VoidResult;
 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.internal.analysis.os.linux.ui.views.controlflow.ControlFlowView;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.resources.ResourcesView;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
@@ -39,6 +47,7 @@ import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor;
 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.histogram.HistogramView;
+import org.eclipse.tracecompass.tmf.ui.views.statesystem.TmfStateSystemExplorer;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IEditorReference;
 import org.eclipse.ui.IViewPart;
@@ -57,6 +66,9 @@ import org.junit.runner.RunWith;
 @RunWith(SWTBotJunit4ClassRunner.class)
 public class ImportAndReadKernelSmokeTest extends KernelTestBase {
 
+    private static final @NonNull List<String> EXPECTED_ANALYSES = Arrays.asList("org.eclipse.tracecompass.analysis.os.linux.inputoutput", "org.eclipse.linuxtools.tmf.statistics.totals", "org.eclipse.linuxtools.tmf.statistics.types",
+            "org.eclipse.tracecompass.analysis.os.linux.kernel.tid", "org.eclipse.tracecompass.analysis.os.linux.kernel", "org.eclipse.tracecompass.analysis.os.linux.contextswitch", "org.eclipse.tracecompass.analysis.os.linux.core.kernelmemory",
+            "org.eclipse.tracecompass.analysis.os.linux.cpuusage");
     private ITmfEvent fDesired1;
     private ITmfEvent fDesired2;
 
@@ -83,6 +95,8 @@ public class ImportAndReadKernelSmokeTest extends KernelTestBase {
         testHV(getViewPart("Histogram"));
         testCFV((ControlFlowView) getViewPart("Control Flow"));
         testRV((ResourcesView) getViewPart("Resources"));
+        testStateSystemExplorer();
+
         trace.dispose();
     }
 
@@ -158,4 +172,45 @@ public class ImportAndReadKernelSmokeTest extends KernelTestBase {
 
         return vps[0];
     }
+
+    private void testStateSystemExplorer() {
+        // Set up
+        SWTWorkbenchBot bot = new SWTWorkbenchBot();
+        List<String> expectedAnalyses = new ArrayList<>();
+        expectedAnalyses.addAll(EXPECTED_ANALYSES);
+        // Open the view
+        SWTBotUtils.openView(TmfStateSystemExplorer.ID);
+        SWTBotView sseBot = bot.viewByTitle("State System Explorer");
+        sseBot.show();
+        // get the list and compare it.
+        List<String> actual = getSSNames(sseBot);
+        assertTrue("State systems are not what expected : " + EXPECTED_ANALYSES + " instead " + actual, actual.containsAll(EXPECTED_ANALYSES));
+        // Re-open the view and make sure it has the same results
+        sseBot.close();
+        SWTBotUtils.openView(TmfStateSystemExplorer.ID);
+        sseBot = bot.viewByTitle("State System Explorer");
+        sseBot.show();
+        List<String> secondOpen = getSSNames(sseBot);
+        assertEquals("Test reopen view", actual, secondOpen);
+        // Close the trace, and re-open it, let's compare one last time
+        bot.closeAllEditors();
+        bot.waitUntil(treeHasRows(sseBot.bot().tree(), 0));
+        // re-open the trace
+        before();
+        secondOpen = getSSNames(sseBot);
+        assertEquals("Test reopen trace", actual, secondOpen);
+        sseBot.close();
+    }
+
+    private static List<String> getSSNames(SWTBotView bot) {
+        SWTBotTree tree = bot.bot().tree();
+        bot.bot().waitWhile(treeHasRows(tree, 0));
+        SWTBotTreeItem item = tree.getTreeItem("synthetic-trace").expand();
+        List<String> strings = new ArrayList<>();
+        strings.addAll(item.getNodes());
+        // The items may be out of order, is this a bug?
+        strings.sort(null);
+        return strings;
+    }
+
 }
This page took 0.027397 seconds and 5 git commands to generate.