71296a1e4e2785280dce1808b84dc8852a9c7c09
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / swtbot / tests / ControlViewExcludeEventsTest.java
1 /*******************************************************************************
2 * Copyright (c) 2015 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.control.ui.swtbot.tests;
11
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertTrue;
15
16 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
17 import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
18 import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
19 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
20 import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
21 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
22 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
23 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
24 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
25 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
26 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceEventComponent;
27 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
28 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31
32 /**
33 * Test for the Control view in Trace Compass. This will test the exclude events feature.
34 *
35 * @author Bruno Roy
36 */
37 @RunWith(SWTBotJunit4ClassRunner.class)
38 public class ControlViewExcludeEventsTest extends ControlViewTest {
39
40 // ------------------------------------------------------------------------
41 // Constants
42 // ------------------------------------------------------------------------
43 private static final String TEST_STREAM = "CreateSessionTestLTTng2_8.cfg";
44
45 private static final String CREATE_SESSION_UST_EXCLUDE_SCENARIO_NAME = "ExcludeEvent";
46
47 private static final String SESSION_NAME = "mysession";
48 private static final String EXCLUDE_EXPRESSION = "foo";
49 private static final String PROPERTIES_VIEW = "Properties";
50 private static final String EXCLUDE_TREE_ITEM = "Exclude";
51
52 @Override
53 protected String getTestStream() {
54 return TEST_STREAM;
55 }
56
57 @Override
58 protected String getSessionName() {
59 return SESSION_NAME;
60 }
61
62 /**
63 * Testing the trace session tree.
64 */
65 @Override
66 @Test
67 public void testTraceSessionTree() {
68
69 fProxy.setTestFile(fTestFile);
70 fProxy.setScenario(INIT_SCENARIO_NAME);
71 testConnectToNode();
72
73 // Enable all UST events with one excluded event
74 fProxy.setScenario(CREATE_SESSION_UST_EXCLUDE_SCENARIO_NAME);
75 testCreateSession();
76 testEnableUstEventExclude();
77 testStartStopTracing(TraceSessionState.ACTIVE);
78 testStartStopTracing(TraceSessionState.INACTIVE);
79 // Verify that the Properties view shows to right excluded event
80 testPropertiesEventExclude();
81 // Clean session
82 testDestroySession();
83 testDisconnectFromNode();
84 }
85
86 /**
87 * Enable all UST events with one excluded event.
88 */
89 protected void testEnableUstEventExclude() {
90 // Getting the 'Sessions' tree
91 SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
92 getNodeName(),
93 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
94 getSessionName());
95 sessionItem.select();
96
97 // Clicking on the 'Enable Event (default channel)...'
98 SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
99 menuBot.click();
100
101 SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
102
103 // Switching to the UST domain
104 shell.bot().radioInGroup(ControlViewSwtBotUtil.UST_GROUP_NAME, ControlViewSwtBotUtil.DOMAIN_GROUP_NAME).click();
105
106 // Selecting all UST events
107 SWTBotTree tracepointsTree = shell.bot().treeInGroup(ControlViewSwtBotUtil.TRACEPOINTS_GROUP_NAME);
108 SWTBotTreeItem treeItem = tracepointsTree.getTreeItem(ControlViewSwtBotUtil.ALL_TREE_NODE);
109 treeItem.check();
110
111 // Click the checkbox for the Exclude event
112 shell.bot().checkBoxInGroup(ControlViewSwtBotUtil.GROUP_SELECT_NAME, ControlViewSwtBotUtil.EXCLUDE_EVENT_LABEL).click();
113
114 // Enter the event to exclude in the text field
115 SWTBotText excludeText = shell.bot().textInGroup(ControlViewSwtBotUtil.EXCLUDE_EVENT_LABEL);
116 excludeText.setText(EXCLUDE_EXPRESSION);
117
118 // Click the Ok at the bottom of the dialog window
119 shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
120 SWTBotUtils.waitForJobs();
121
122 fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.UST_DOMAIN_NAME, sessionItem));
123
124 // Assert that the domain is UST global
125 SWTBotTreeItem ustGlobalDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
126 getNodeName(),
127 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
128 getSessionName(),
129 ControlViewSwtBotUtil.UST_DOMAIN_NAME);
130 assertEquals(ControlViewSwtBotUtil.UST_DOMAIN_NAME, ustGlobalDomainItem.getText());
131
132 // Assert that the new channel name is channel0 (which is the default name)
133 SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
134 getNodeName(),
135 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
136 getSessionName(),
137 ControlViewSwtBotUtil.UST_DOMAIN_NAME,
138 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
139 assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());
140
141 // Assert that the event type in the channel node are correct (all events = *)
142 SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
143 getNodeName(),
144 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
145 getSessionName(),
146 ControlViewSwtBotUtil.UST_DOMAIN_NAME,
147 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
148 ControlViewSwtBotUtil.ALL_EVENTS_NAME);
149 assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText());
150
151 // Assert that the excluded event is the correct one
152 ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode,
153 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
154 getSessionName(),
155 ControlViewSwtBotUtil.UST_DOMAIN_NAME,
156 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
157 ControlViewSwtBotUtil.ALL_EVENTS_NAME);
158 assertNotNull(comp);
159 assertTrue(comp instanceof TraceEventComponent);
160 TraceEventComponent event = (TraceEventComponent) comp;
161 assertEquals(EXCLUDE_EXPRESSION, event.getExcludedEvents());
162 }
163
164 /**
165 * Test that the Properties view has been update and shows the the right
166 * information.
167 */
168 protected void testPropertiesEventExclude() {
169 // Open the properties view (by id)
170 SWTBotUtils.openView("org.eclipse.ui.views.PropertySheet");
171
172 // Select the event in the Control view
173 fBot.viewById(ControlView.ID).show();
174 SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
175 getNodeName(),
176 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
177 getSessionName(),
178 ControlViewSwtBotUtil.UST_DOMAIN_NAME,
179 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
180 ControlViewSwtBotUtil.ALL_EVENTS_NAME);
181 eventItem.select();
182
183 // Get a bot and open the Properties view
184 SWTBotView propertiesViewBot = fBot.viewByTitle(PROPERTIES_VIEW);
185 propertiesViewBot.show();
186
187 // Get the Exclude field in the tree
188 SWTBotTree propertiesViewTree = propertiesViewBot.bot().tree();
189 SWTBotTreeItem excludeTreeItem = propertiesViewTree.getTreeItem(EXCLUDE_TREE_ITEM);
190 // We want the VALUE of the 'Exclude' row so the cell index is 1
191 String excludeExpression = excludeTreeItem.cell(1);
192
193 // Assert that the expression in the Properties view is the same as
194 // the one we entered
195 assertEquals(EXCLUDE_EXPRESSION, excludeExpression);
196
197 // Close the Properties view
198 SWTBotUtils.closeView(PROPERTIES_VIEW, fBot);
199 }
200
201 }
This page took 0.042225 seconds and 4 git commands to generate.