Commit | Line | Data |
---|---|---|
f9159c02 MK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2016 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | *******************************************************************************/ | |
9 | ||
10 | package org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests; | |
11 | ||
12 | import static org.junit.Assert.assertEquals; | |
13 | import static org.junit.Assert.assertNotNull; | |
14 | import static org.junit.Assert.fail; | |
15 | ||
16 | import java.io.IOException; | |
17 | import java.net.URISyntaxException; | |
18 | import java.nio.file.Paths; | |
19 | ||
20 | import org.eclipse.core.runtime.FileLocator; | |
21 | import org.eclipse.jdt.annotation.NonNull; | |
22 | import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; | |
23 | import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; | |
24 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; | |
25 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; | |
26 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; | |
27 | import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.controlflow.ControlFlowView; | |
28 | import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace; | |
29 | import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; | |
30 | import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; | |
31 | import org.junit.Before; | |
32 | import org.junit.Test; | |
33 | ||
34 | /** | |
35 | * SWTBot tests for Critical Flow view. This test also tests the control flow | |
36 | * view's thread selection as the two views are tightly coupled. | |
37 | * | |
38 | * @author Matthew Khouzam | |
39 | */ | |
40 | public class CriticalPathTest extends KernelTestBase { | |
41 | ||
42 | private static final int TID_NO = 338; | |
43 | private static final String TID = String.valueOf(TID_NO); | |
44 | private static final String PROCESS = "weston"; | |
45 | private static final @NonNull String CP_ID = "org.eclipse.linuxtools.tmf.analysis.graph.ui.criticalpath.view.criticalpathview"; | |
46 | private SWTBotView fViewBotCfv; | |
47 | private SWTBotView fViewBotCp; | |
48 | ||
49 | /** | |
50 | * Before Test | |
51 | */ | |
52 | @Override | |
53 | @Before | |
54 | public void before() { | |
55 | try { | |
56 | String traceName = Paths.get(FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL()).toURI()).toString(); | |
57 | SWTBotUtils.openTrace(TRACE_PROJECT_NAME, traceName, KERNEL_TRACE_TYPE); | |
58 | } catch (IOException | URISyntaxException e) { | |
59 | fail(e.getMessage()); | |
60 | } | |
61 | SWTBotUtils.activateEditor(fBot, "bug446190"); | |
62 | fViewBotCfv = fBot.viewById(ControlFlowView.ID); | |
63 | SWTBotUtils.openView(CP_ID); | |
64 | fViewBotCp = fBot.viewById(CP_ID); | |
65 | fViewBotCp.show(); | |
66 | fViewBotCfv.show(); | |
67 | fViewBotCfv.setFocus(); | |
68 | } | |
69 | ||
70 | /** | |
71 | * test the behavior of the critical path for a thread selection signal from | |
72 | * the control flow view | |
73 | */ | |
74 | @Test | |
75 | public void testFull() { | |
76 | SWTBotTree treeCfv = fViewBotCfv.bot().tree(); | |
77 | SWTBotTree treeCp = fViewBotCp.bot().tree(); | |
78 | assertNotNull(treeCfv.widget); | |
79 | assertNotNull(treeCp.widget); | |
80 | SWTBotTreeItem[] allItems = treeCp.getAllItems(); | |
81 | for (int i = 0; i < allItems.length; i++) { | |
82 | assertEquals(0, allItems[i].getNodes().size()); | |
83 | } | |
84 | ||
85 | SWTBotTreeItem item = treeCfv.getTreeItem(TmfTraceManager.getInstance().getActiveTrace().getName()); | |
86 | assertNotNull(item); | |
87 | item = item.getNode("systemd"); | |
88 | assertNotNull(item); | |
89 | item = item.getNode("we"); | |
90 | assertNotNull(item); | |
91 | item = item.getNode(PROCESS); | |
92 | assertNotNull(item); | |
93 | final SWTBotTreeItem treeItem = item; | |
94 | UIThreadRunnable.syncExec(() -> treeCfv.widget.setTopItem(treeItem.widget)); | |
95 | item.click(); | |
96 | ||
97 | SWTBotMenu menu = item.contextMenu("Follow " + PROCESS + "/" + TID); | |
98 | assertEquals("Follow " + PROCESS + "/" + TID, menu.getText()); | |
99 | menu.click(); | |
100 | SWTBotUtils.waitForJobs(); | |
101 | allItems = treeCp.getAllItems(); | |
102 | assertEquals("[" + PROCESS + "," + TID + "]", allItems[0].getNode(0).getText()); | |
103 | } | |
104 | } |