linux.swtbot: Add basic critical flow view test.
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 10 May 2016 02:45:23 +0000 (22:45 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 1 Jun 2016 14:27:37 +0000 (10:27 -0400)
This tests runs a true integration test with the control flow view.
It signals the critical path view from a right click on the cfv.

Change-Id: Icc04e03de0b745eb966bb711494eab749b8b08c6
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/72360
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java [new file with mode: 0644]

index 47e70dfd278a072849b08d62426a377274cf26a7..85fcd788c9b6205d56d1ad3df74e512d3524cb92 100644 (file)
@@ -28,6 +28,7 @@ Require-Bundle: org.apache.log4j,
  org.eclipse.ui,
  org.eclipse.ui.ide,
  org.eclipse.ui.views,
- org.junit
+ org.junit,
+ org.eclipse.tracecompass.analysis.graph.ui
 Import-Package: org.eclipse.tracecompass.testtraces.ctf,
  org.swtchart;version="0.7.0"
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java
new file mode 100644 (file)
index 0000000..a70d840
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.file.Paths;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+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.testtraces.ctf.CtfTestTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * SWTBot tests for Critical Flow view. This test also tests the control flow
+ * view's thread selection as the two views are tightly coupled.
+ *
+ * @author Matthew Khouzam
+ */
+public class CriticalPathTest extends KernelTestBase {
+
+    private static final int TID_NO = 338;
+    private static final String TID = String.valueOf(TID_NO);
+    private static final String PROCESS = "weston";
+    private static final @NonNull String CP_ID = "org.eclipse.linuxtools.tmf.analysis.graph.ui.criticalpath.view.criticalpathview";
+    private SWTBotView fViewBotCfv;
+    private SWTBotView fViewBotCp;
+
+    /**
+     * Before Test
+     */
+    @Override
+    @Before
+    public void before() {
+        try {
+            String traceName = Paths.get(FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL()).toURI()).toString();
+            SWTBotUtils.openTrace(TRACE_PROJECT_NAME, traceName, KERNEL_TRACE_TYPE);
+        } catch (IOException | URISyntaxException e) {
+            fail(e.getMessage());
+        }
+        SWTBotUtils.activateEditor(fBot, "bug446190");
+        fViewBotCfv = fBot.viewById(ControlFlowView.ID);
+        SWTBotUtils.openView(CP_ID);
+        fViewBotCp = fBot.viewById(CP_ID);
+        fViewBotCp.show();
+        fViewBotCfv.show();
+        fViewBotCfv.setFocus();
+    }
+
+    /**
+     * test the behavior of the critical path for a thread selection signal from
+     * the control flow view
+     */
+    @Test
+    public void testFull() {
+        SWTBotTree treeCfv = fViewBotCfv.bot().tree();
+        SWTBotTree treeCp = fViewBotCp.bot().tree();
+        assertNotNull(treeCfv.widget);
+        assertNotNull(treeCp.widget);
+        SWTBotTreeItem[] allItems = treeCp.getAllItems();
+        for (int i = 0; i < allItems.length; i++) {
+            assertEquals(0, allItems[i].getNodes().size());
+        }
+
+        SWTBotTreeItem item = treeCfv.getTreeItem(TmfTraceManager.getInstance().getActiveTrace().getName());
+        assertNotNull(item);
+        item = item.getNode("systemd");
+        assertNotNull(item);
+        item = item.getNode("we");
+        assertNotNull(item);
+        item = item.getNode(PROCESS);
+        assertNotNull(item);
+        final SWTBotTreeItem treeItem = item;
+        UIThreadRunnable.syncExec(() -> treeCfv.widget.setTopItem(treeItem.widget));
+        item.click();
+
+        SWTBotMenu menu = item.contextMenu("Follow " + PROCESS + "/" + TID);
+        assertEquals("Follow " + PROCESS + "/" + TID, menu.getText());
+        menu.click();
+        SWTBotUtils.waitForJobs();
+        allItems = treeCp.getAllItems();
+        assertEquals("[" + PROCESS + "," + TID + "]", allItems[0].getNode(0).getText());
+    }
+}
This page took 0.026298 seconds and 5 git commands to generate.