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
.junit
.Test
;
30 import org
.junit
.runner
.RunWith
;
33 * Test for the Control view in Trace Compass. This will test the exclude events feature.
37 @RunWith(SWTBotJunit4ClassRunner
.class)
38 public class ControlViewExcludeEventsTest
extends ControlViewTest
{
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
43 private static final String TEST_STREAM
= "CreateSessionTestLTTng2_8.cfg";
45 private static final String CREATE_SESSION_UST_EXCLUDE_SCENARIO_NAME
= "ExcludeEvent";
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";
53 protected String
getTestStream() {
58 protected String
getSessionName() {
63 * Testing the trace session tree.
67 public void testTraceSessionTree() {
69 fProxy
.setTestFile(fTestFile
);
70 fProxy
.setScenario(INIT_SCENARIO_NAME
);
73 // Enable all UST events with one excluded event
74 fProxy
.setScenario(CREATE_SESSION_UST_EXCLUDE_SCENARIO_NAME
);
76 testEnableUstEventExclude();
77 testStartStopTracing(TraceSessionState
.ACTIVE
);
78 testStartStopTracing(TraceSessionState
.INACTIVE
);
79 // Verify that the Properties view shows to right excluded event
80 testPropertiesEventExclude();
83 testDisconnectFromNode();
87 * Enable all UST events with one excluded event.
89 protected void testEnableUstEventExclude() {
90 // Getting the 'Sessions' tree
91 SWTBotTreeItem sessionItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
93 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
97 // Clicking on the 'Enable Event (default channel)...'
98 SWTBotMenu menuBot
= sessionItem
.contextMenu(ControlViewSwtBotUtil
.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM
);
101 SWTBotShell shell
= fBot
.shell(ControlViewSwtBotUtil
.ENABLE_EVENT_DIALOG_TITLE
).activate();
103 // Switching to the UST domain
104 shell
.bot().radioInGroup(ControlViewSwtBotUtil
.UST_GROUP_NAME
, ControlViewSwtBotUtil
.DOMAIN_GROUP_NAME
).click();
106 // Selecting all UST events
107 SWTBotTree tracepointsTree
= shell
.bot().treeInGroup(ControlViewSwtBotUtil
.TRACEPOINTS_GROUP_NAME
);
108 SWTBotTreeItem treeItem
= tracepointsTree
.getTreeItem(ControlViewSwtBotUtil
.ALL_TREE_NODE
);
111 // Click the checkbox for the Exclude event
112 shell
.bot().checkBoxInGroup(ControlViewSwtBotUtil
.GROUP_SELECT_NAME
, ControlViewSwtBotUtil
.EXCLUDE_EVENT_LABEL
).click();
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
);
118 // Click the Ok at the bottom of the dialog window
119 shell
.bot().button(ControlViewSwtBotUtil
.DIALOG_OK_BUTTON
).click();
120 SWTBotUtils
.waitForJobs();
122 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(ControlViewSwtBotUtil
.UST_DOMAIN_NAME
, sessionItem
));
124 // Assert that the domain is UST global
125 SWTBotTreeItem ustGlobalDomainItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
127 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
129 ControlViewSwtBotUtil
.UST_DOMAIN_NAME
);
130 assertEquals(ControlViewSwtBotUtil
.UST_DOMAIN_NAME
, ustGlobalDomainItem
.getText());
132 // Assert that the new channel name is channel0 (which is the default name)
133 SWTBotTreeItem channelItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
135 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
137 ControlViewSwtBotUtil
.UST_DOMAIN_NAME
,
138 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
);
139 assertEquals(ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
, channelItem
.getText());
141 // Assert that the event type in the channel node are correct (all events = *)
142 SWTBotTreeItem eventItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
144 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
146 ControlViewSwtBotUtil
.UST_DOMAIN_NAME
,
147 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
148 ControlViewSwtBotUtil
.ALL_EVENTS_NAME
);
149 assertEquals(ControlViewSwtBotUtil
.ALL_EVENTS_NAME
, eventItem
.getText());
151 // Assert that the excluded event is the correct one
152 ITraceControlComponent comp
= ControlViewSwtBotUtil
.getComponent(fNode
,
153 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
155 ControlViewSwtBotUtil
.UST_DOMAIN_NAME
,
156 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
157 ControlViewSwtBotUtil
.ALL_EVENTS_NAME
);
159 assertTrue(comp
instanceof TraceEventComponent
);
160 TraceEventComponent event
= (TraceEventComponent
) comp
;
161 assertEquals(EXCLUDE_EXPRESSION
, event
.getExcludedEvents());
165 * Test that the Properties view has been update and shows the the right
168 protected void testPropertiesEventExclude() {
169 // Open the properties view (by id)
170 SWTBotUtils
.openView("org.eclipse.ui.views.PropertySheet");
172 // Select the event in the Control view
173 fBot
.viewById(ControlView
.ID
).show();
174 SWTBotTreeItem eventItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
176 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
178 ControlViewSwtBotUtil
.UST_DOMAIN_NAME
,
179 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
180 ControlViewSwtBotUtil
.ALL_EVENTS_NAME
);
183 // Get a bot and open the Properties view
184 SWTBotView propertiesViewBot
= fBot
.viewByTitle(PROPERTIES_VIEW
);
185 propertiesViewBot
.show();
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);
193 // Assert that the expression in the Properties view is the same as
194 // the one we entered
195 assertEquals(EXCLUDE_EXPRESSION
, excludeExpression
);
197 // Close the Properties view
198 SWTBotUtils
.closeView(PROPERTIES_VIEW
, fBot
);