1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.control
.ui
.swtbot
.tests
;
12 import static org
.junit
.Assert
.assertEquals
;
13 import static org
.junit
.Assert
.assertNotNull
;
14 import static org
.junit
.Assert
.assertTrue
;
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
.eclipse
.tracecompass
.tmf
.ui
.tests
.shared
.WaitUtils
;
30 import org
.junit
.Test
;
31 import org
.junit
.runner
.RunWith
;
34 * Test for the Control view in Trace Compass. This will test the exclude events feature.
38 @RunWith(SWTBotJunit4ClassRunner
.class)
39 public class ControlViewExcludeEventsTest
extends ControlViewTest
{
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
44 private static final String TEST_STREAM
= "CreateSessionTestLTTng2_8.cfg";
46 private static final String CREATE_SESSION_UST_EXCLUDE_SCENARIO_NAME
= "ExcludeEvent";
48 private static final String SESSION_NAME
= "mysession";
49 private static final String EXCLUDE_EXPRESSION
= "foo";
50 private static final String PROPERTIES_VIEW
= "Properties";
51 private static final String EXCLUDE_TREE_ITEM
= "Exclude";
54 protected String
getTestStream() {
59 protected String
getSessionName() {
64 * Testing the trace session tree.
68 public void testTraceSessionTree() {
70 fProxy
.setTestFile(fTestFile
);
71 fProxy
.setScenario(INIT_SCENARIO_NAME
);
74 // Enable all UST events with one excluded event
75 fProxy
.setScenario(CREATE_SESSION_UST_EXCLUDE_SCENARIO_NAME
);
77 testEnableUstEventExclude();
78 testStartStopTracing(TraceSessionState
.ACTIVE
);
79 testStartStopTracing(TraceSessionState
.INACTIVE
);
80 // Verify that the Properties view shows to right excluded event
81 testPropertiesEventExclude();
84 testDisconnectFromNode();
88 * Enable all UST events with one excluded event.
90 protected void testEnableUstEventExclude() {
91 // Getting the 'Sessions' tree
92 SWTBotTreeItem sessionItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
94 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
98 // Clicking on the 'Enable Event (default channel)...'
99 SWTBotMenu menuBot
= sessionItem
.contextMenu(ControlViewSwtBotUtil
.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM
);
102 SWTBotShell shell
= fBot
.shell(ControlViewSwtBotUtil
.ENABLE_EVENT_DIALOG_TITLE
).activate();
104 // Switching to the UST domain
105 shell
.bot().radioInGroup(ControlViewSwtBotUtil
.UST_GROUP_NAME
, ControlViewSwtBotUtil
.DOMAIN_GROUP_NAME
).click();
107 // Selecting all UST events
108 SWTBotTree tracepointsTree
= shell
.bot().treeInGroup(ControlViewSwtBotUtil
.TRACEPOINTS_GROUP_NAME
);
109 SWTBotTreeItem treeItem
= tracepointsTree
.getTreeItem(ControlViewSwtBotUtil
.ALL_TREE_NODE
);
112 // Click the checkbox for the Exclude event
113 shell
.bot().checkBoxInGroup(ControlViewSwtBotUtil
.GROUP_SELECT_NAME
, ControlViewSwtBotUtil
.EXCLUDE_EVENT_LABEL
).click();
115 // Enter the event to exclude in the text field
116 SWTBotText excludeText
= shell
.bot().textInGroup(ControlViewSwtBotUtil
.EXCLUDE_EVENT_LABEL
);
117 excludeText
.setText(EXCLUDE_EXPRESSION
);
119 // Click the Ok at the bottom of the dialog window
120 shell
.bot().button(ControlViewSwtBotUtil
.DIALOG_OK_BUTTON
).click();
121 WaitUtils
.waitForJobs();
123 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(ControlViewSwtBotUtil
.UST_DOMAIN_NAME
, sessionItem
));
125 // Assert that the domain is UST global
126 SWTBotTreeItem ustGlobalDomainItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
128 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
130 ControlViewSwtBotUtil
.UST_DOMAIN_NAME
);
131 assertEquals(ControlViewSwtBotUtil
.UST_DOMAIN_NAME
, ustGlobalDomainItem
.getText());
133 // Assert that the new channel name is channel0 (which is the default name)
134 SWTBotTreeItem channelItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
136 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
138 ControlViewSwtBotUtil
.UST_DOMAIN_NAME
,
139 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
);
140 assertEquals(ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
, channelItem
.getText());
142 // Assert that the event type in the channel node are correct (all events = *)
143 SWTBotTreeItem eventItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
145 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
147 ControlViewSwtBotUtil
.UST_DOMAIN_NAME
,
148 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
149 ControlViewSwtBotUtil
.ALL_EVENTS_NAME
);
150 assertEquals(ControlViewSwtBotUtil
.ALL_EVENTS_NAME
, eventItem
.getText());
152 // Assert that the excluded event is the correct one
153 ITraceControlComponent comp
= ControlViewSwtBotUtil
.getComponent(fNode
,
154 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
156 ControlViewSwtBotUtil
.UST_DOMAIN_NAME
,
157 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
158 ControlViewSwtBotUtil
.ALL_EVENTS_NAME
);
160 assertTrue(comp
instanceof TraceEventComponent
);
161 TraceEventComponent event
= (TraceEventComponent
) comp
;
162 assertEquals(EXCLUDE_EXPRESSION
, event
.getExcludedEvents());
166 * Test that the Properties view has been update and shows the the right
169 protected void testPropertiesEventExclude() {
170 // Open the properties view (by id)
171 SWTBotUtils
.openView("org.eclipse.ui.views.PropertySheet");
173 // Select the event in the Control view
174 fBot
.viewById(ControlView
.ID
).show();
175 SWTBotTreeItem eventItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
177 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
179 ControlViewSwtBotUtil
.UST_DOMAIN_NAME
,
180 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
181 ControlViewSwtBotUtil
.ALL_EVENTS_NAME
);
184 // Get a bot and open the Properties view
185 SWTBotView propertiesViewBot
= fBot
.viewByTitle(PROPERTIES_VIEW
);
186 propertiesViewBot
.show();
188 // Get the Exclude field in the tree
189 SWTBotTree propertiesViewTree
= propertiesViewBot
.bot().tree();
190 SWTBotTreeItem excludeTreeItem
= propertiesViewTree
.getTreeItem(EXCLUDE_TREE_ITEM
);
191 // We want the VALUE of the 'Exclude' row so the cell index is 1
192 String excludeExpression
= excludeTreeItem
.cell(1);
194 // Assert that the expression in the Properties view is the same as
195 // the one we entered
196 assertEquals(EXCLUDE_EXPRESSION
, excludeExpression
);
198 // Close the Properties view
199 SWTBotUtils
.closeView(PROPERTIES_VIEW
, fBot
);