From f9159c02fd805877e1194b211b0a823039b7d816 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Mon, 9 May 2016 22:45:23 -0400 Subject: [PATCH] linux.swtbot: Add basic critical flow view test. 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 Reviewed-on: https://git.eclipse.org/r/72360 Reviewed-by: Hudson CI Reviewed-by: Genevieve Bastien Tested-by: Genevieve Bastien --- .../META-INF/MANIFEST.MF | 3 +- .../ui/swtbot/tests/CriticalPathTest.java | 104 ++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/META-INF/MANIFEST.MF b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/META-INF/MANIFEST.MF index 47e70dfd27..85fcd788c9 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/META-INF/MANIFEST.MF +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/META-INF/MANIFEST.MF @@ -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 index 0000000000..a70d84063d --- /dev/null +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java @@ -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()); + } +} -- 2.34.1