lttng.control: Add support for enabling syscall by name
[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";
207ff523
BR
68 public static final String SYSCALL_GROUP_NAME = "Syscall Events";
69 public static final String SYSCALL_WRITE_EVENT = "write";
70 public static final String SYSCALL_READ_EVENT = "read";
71 public static final String SYSCALL_CLOSE_EVENT = "close";
2e65d221
BH
72 public static final String GROUP_SELECT_NAME = "Select";
73 public static final String ENABLE_CHANNEL_DIALOG_TITLE = "Enable Channel";
74 public static final String DOMAIN_GROUP_NAME = "Domain";
75 public static final String UST_GROUP_NAME = "UST";
76 public static final String BUFFERTYPE_GROUP_NAME = "Buffer Type";
77 public static final String BUFFERTYPE_PER_UID = "Per UID buffers";
43628e7b 78 public static final String FILTER_EXPRESSION_LABEL = "Filter Expression";
a959e694 79 public static final String EXCLUDE_EVENT_LABEL = "Exclude Events";
43628e7b 80 public static final String SESSION_LIST_GROUP_NAME = "Session List";
2e65d221
BH
81
82 public static final String DESTROY_CONFIRM_DIALOG_TITLE = "Destroy Confirmation";
83 public static final String CHANNEL_NAME_LABEL = "Channel Name";
84
3d09f0a5
BH
85 public static final String SAVE_DIALOG_TITLE = "Save Sessions";
86 public static final String LOAD_DIALOG_TITLE = "Load Sessions";
87 public static final String REMOTE_RADIO_BUTTON_LABEL = "Remote";
2e65d221 88
325d8cac
BH
89 // Remote import strings
90 public static final String IMPORT_WIZARD_TITLE = "Fetch Remote Traces";
91 public static final String DEFAULT_REMOTE_PROJECT = "Remote";
92 public static final String FINISH_BUTTON = "Finish";
93 public static final String CANCEL_BUTTON = "Cancel";
94 public static final String OPTION_GROUP_NAME = "Options";
95
2e65d221
BH
96 private ControlViewSwtBotUtil() { }
97
98 /**
99 * Tests for Target node state
100 *
101 * @param node
102 * target node component
103 * @param state
104 * the state to wait
105 * @return the condition instance
106 */
107 public static ICondition isStateChanged(final TargetNodeComponent node, final TargetNodeState state) {
108 return new SWTBotTestCondition() {
109 @Override
110 public boolean test() throws Exception {
111 if (node.getTargetNodeState() != state) {
112 return false;
113 }
114 return true;
115 }
116 };
117 }
118
119 /**
120 * Tests for session state
121 *
122 * @param session
123 * the session component
124 * @param state
125 * the state to wait
126 * @return the condition instance
127 */
128 public static ICondition isSessionStateChanged(final TraceSessionComponent session, final TraceSessionState state) {
129 return new SWTBotTestCondition() {
130 @Override
131 public boolean test() throws Exception {
132 if (session.getSessionState() != state) {
133 return false;
134 }
135 return true;
136 }
137 };
138 }
139
140 /**
141 * Finds a session for given node
142 *
143 * @param target
144 * target node component
145 * @param sessionName
146 * session name to find
147 * @return the session component or null
148 */
3d09f0a5
BH
149 public static TraceSessionComponent getSessionComponent(TargetNodeComponent target, String sessionName) {
150 final TraceSessionComponent[] sessions = target.getSessions();
151 if (sessions != null) {
152 for (int i = 0; i < sessions.length; i++) {
153 if (sessionName.equals(sessions[i].getName())) {
154 return sessions[i];
155 }
156 }
157 }
158 return null;
2e65d221 159 }
2e65d221 160
43628e7b
BH
161 /**
162 * Finds a {@link ITraceControlComponent} in a tree for given path.
163 *
164 * @param root
165 * root component
166 * @param path
167 * path to element
168 * @return the matched component or null
169 */
170 public static ITraceControlComponent getComponent(ITraceControlComponent root, String... path) {
171 ITraceControlComponent newRoot = root;
172 for (String segment : path) {
173 newRoot = Arrays.asList(newRoot.getChildren()).stream()
174 .filter(child -> (child.getName().equals(segment)))
175 .findFirst()
176 .orElse(null);
177 if (newRoot == null) {
178 return null;
179 }
180 }
181 return newRoot;
182 }
183
2e65d221 184}
This page took 0.042898 seconds and 5 git commands to generate.