control.test: Add tests for the exclude feature in Control view
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / swtbot / tests / ControlViewSwtBotUtil.java
CommitLineData
2e65d221
BH
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
10package org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests;
11
43628e7b
BH
12import java.util.Arrays;
13
2e65d221
BH
14import org.eclipse.swtbot.swt.finder.waits.ICondition;
15import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState;
16import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
43628e7b 17import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
2e65d221
BH
18import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
19import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
20import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers.SWTBotTestCondition;
21
22/**
23 * SWTBot utilities for ControlView test
24 *
25 * @author Bernd Hufmann
26 */
27class ControlViewSwtBotUtil {
28
3d09f0a5 29 public static final String USER_HOME = System.getProperty("user.home");
2e65d221
BH
30 public static final String DEFAULT_CHANNEL_NAME = "channel0";
31 public static final String KERNEL_DOMAIN_NAME = "Kernel";
32 public static final String UST_DOMAIN_NAME = "UST global";
33 public static final String SESSION_GROUP_NAME = "Sessions";
43628e7b 34 public static final String PROVIDER_GROUP_NAME = "Provider";
2e65d221 35 public static final String ALL_EVENTS_NAME = "*";
43628e7b 36 public static final String SCHED_SWITCH_EVENT_NAME = "sched_switch";
0c656739
BR
37 public static final String SCHED_WAKEUP_EVENT_NAME = "sched_wakeup";
38 public static final String SCHED_PROCESSWAIT_EVENT_NAME = "sched_process_wait";
39 public static final String SCHED_PROCESSFORK_EVENT_NAME = "sched_process_fork";
40 public static final String SCHED_PROCESSEXEC_EVENT_NAME = "sched_process_exec";
3d09f0a5 41 public static final String PROFILE_SUFFIX = ".lttng";
325d8cac 42 public static final String KERNEL_TRACE_NAME = "kernel";
2e65d221
BH
43
44 // Menu strings
45 public static final String CONNECT_MENU_ITEM = "Connect";
46 public static final String CREATE_SESSION_MENU_ITEM = "Create Session...";
47 public static final String ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM = "Enable Event (default channel)...";
48 public static final String ENABLE_CHANNEL_MENU_ITEM = "Enable Channel...";
49 public static final String ENABLE_EVENT_MENU_ITEM = "Enable Event...";
50 public static final String START_MENU_ITEM = "Start";
51 public static final String STOP_MENU_ITEM = "Stop";
325d8cac 52 public static final String IMPORT_MENU_ITEM = "Import...";
2e65d221
BH
53 public static final String DESTROY_MENU_ITEM = "Destroy Session...";
54 public static final String DISCONNECT_MENU_ITEM = "Disconnect";
3d09f0a5
BH
55 public static final String SAVE_MENU_ITEM = "Save...";
56 public static final String LOAD_MENU_ITEM = "Load...";
2e65d221
BH
57
58 // Dialog strings
59 public static final String CREATE_SESSION_DIALOG_TITLE = "Create Session";
60 public static final String SESSION_NAME_LABEL = "Session Name";
61 public static final String DIALOG_OK_BUTTON = "Ok";
62 public static final String CONFIRM_DIALOG_OK_BUTTON = "OK";
63 public static final String ENABLE_EVENT_DIALOG_TITLE = "Enable Events";
64 public static final String ALL_TREE_NODE = "All";
9ee91a86 65 public static final String ALL_EVENT_GROUP_NAME = "All Tracepoint Events and Syscalls";
0c656739 66 public static final String SPECIFIC_EVENT_GROUP_NAME = "Specific event";
9ee91a86 67 public static final String TRACEPOINTS_GROUP_NAME = "Tracepoint Events";
2e65d221
BH
68 public static final String SYSCALL_GROUP_NAME = "All Syscalls";
69 public static final String GROUP_SELECT_NAME = "Select";
70 public static final String ENABLE_CHANNEL_DIALOG_TITLE = "Enable Channel";
71 public static final String DOMAIN_GROUP_NAME = "Domain";
72 public static final String UST_GROUP_NAME = "UST";
73 public static final String BUFFERTYPE_GROUP_NAME = "Buffer Type";
74 public static final String BUFFERTYPE_PER_UID = "Per UID buffers";
43628e7b 75 public static final String FILTER_EXPRESSION_LABEL = "Filter Expression";
a959e694 76 public static final String EXCLUDE_EVENT_LABEL = "Exclude Events";
43628e7b 77 public static final String SESSION_LIST_GROUP_NAME = "Session List";
2e65d221
BH
78
79 public static final String DESTROY_CONFIRM_DIALOG_TITLE = "Destroy Confirmation";
80 public static final String CHANNEL_NAME_LABEL = "Channel Name";
81
3d09f0a5
BH
82 public static final String SAVE_DIALOG_TITLE = "Save Sessions";
83 public static final String LOAD_DIALOG_TITLE = "Load Sessions";
84 public static final String REMOTE_RADIO_BUTTON_LABEL = "Remote";
2e65d221 85
325d8cac
BH
86 // Remote import strings
87 public static final String IMPORT_WIZARD_TITLE = "Fetch Remote Traces";
88 public static final String DEFAULT_REMOTE_PROJECT = "Remote";
89 public static final String FINISH_BUTTON = "Finish";
90 public static final String CANCEL_BUTTON = "Cancel";
91 public static final String OPTION_GROUP_NAME = "Options";
92
2e65d221
BH
93 private ControlViewSwtBotUtil() { }
94
95 /**
96 * Tests for Target node state
97 *
98 * @param node
99 * target node component
100 * @param state
101 * the state to wait
102 * @return the condition instance
103 */
104 public static ICondition isStateChanged(final TargetNodeComponent node, final TargetNodeState state) {
105 return new SWTBotTestCondition() {
106 @Override
107 public boolean test() throws Exception {
108 if (node.getTargetNodeState() != state) {
109 return false;
110 }
111 return true;
112 }
113 };
114 }
115
116 /**
117 * Tests for session state
118 *
119 * @param session
120 * the session component
121 * @param state
122 * the state to wait
123 * @return the condition instance
124 */
125 public static ICondition isSessionStateChanged(final TraceSessionComponent session, final TraceSessionState state) {
126 return new SWTBotTestCondition() {
127 @Override
128 public boolean test() throws Exception {
129 if (session.getSessionState() != state) {
130 return false;
131 }
132 return true;
133 }
134 };
135 }
136
137 /**
138 * Finds a session for given node
139 *
140 * @param target
141 * target node component
142 * @param sessionName
143 * session name to find
144 * @return the session component or null
145 */
3d09f0a5
BH
146 public static TraceSessionComponent getSessionComponent(TargetNodeComponent target, String sessionName) {
147 final TraceSessionComponent[] sessions = target.getSessions();
148 if (sessions != null) {
149 for (int i = 0; i < sessions.length; i++) {
150 if (sessionName.equals(sessions[i].getName())) {
151 return sessions[i];
152 }
153 }
154 }
155 return null;
2e65d221 156 }
2e65d221 157
43628e7b
BH
158 /**
159 * Finds a {@link ITraceControlComponent} in a tree for given path.
160 *
161 * @param root
162 * root component
163 * @param path
164 * path to element
165 * @return the matched component or null
166 */
167 public static ITraceControlComponent getComponent(ITraceControlComponent root, String... path) {
168 ITraceControlComponent newRoot = root;
169 for (String segment : path) {
170 newRoot = Arrays.asList(newRoot.getChildren()).stream()
171 .filter(child -> (child.getName().equals(segment)))
172 .findFirst()
173 .orElse(null);
174 if (newRoot == null) {
175 return null;
176 }
177 }
178 return newRoot;
179 }
180
2e65d221 181}
This page took 0.060254 seconds and 5 git commands to generate.