control: command support for enabling all tracepoints/syscalls
[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";
3d09f0a5 37 public static final String PROFILE_SUFFIX = ".lttng";
325d8cac 38 public static final String KERNEL_TRACE_NAME = "kernel";
2e65d221
BH
39
40 // Menu strings
41 public static final String CONNECT_MENU_ITEM = "Connect";
42 public static final String CREATE_SESSION_MENU_ITEM = "Create Session...";
43 public static final String ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM = "Enable Event (default channel)...";
44 public static final String ENABLE_CHANNEL_MENU_ITEM = "Enable Channel...";
45 public static final String ENABLE_EVENT_MENU_ITEM = "Enable Event...";
46 public static final String START_MENU_ITEM = "Start";
47 public static final String STOP_MENU_ITEM = "Stop";
325d8cac 48 public static final String IMPORT_MENU_ITEM = "Import...";
2e65d221
BH
49 public static final String DESTROY_MENU_ITEM = "Destroy Session...";
50 public static final String DISCONNECT_MENU_ITEM = "Disconnect";
3d09f0a5
BH
51 public static final String SAVE_MENU_ITEM = "Save...";
52 public static final String LOAD_MENU_ITEM = "Load...";
2e65d221
BH
53
54 // Dialog strings
55 public static final String CREATE_SESSION_DIALOG_TITLE = "Create Session";
56 public static final String SESSION_NAME_LABEL = "Session Name";
57 public static final String DIALOG_OK_BUTTON = "Ok";
58 public static final String CONFIRM_DIALOG_OK_BUTTON = "OK";
59 public static final String ENABLE_EVENT_DIALOG_TITLE = "Enable Events";
60 public static final String ALL_TREE_NODE = "All";
9ee91a86
BH
61 public static final String ALL_EVENT_GROUP_NAME = "All Tracepoint Events and Syscalls";
62 public static final String TRACEPOINTS_GROUP_NAME = "Tracepoint Events";
2e65d221
BH
63 public static final String SYSCALL_GROUP_NAME = "All Syscalls";
64 public static final String GROUP_SELECT_NAME = "Select";
65 public static final String ENABLE_CHANNEL_DIALOG_TITLE = "Enable Channel";
66 public static final String DOMAIN_GROUP_NAME = "Domain";
67 public static final String UST_GROUP_NAME = "UST";
68 public static final String BUFFERTYPE_GROUP_NAME = "Buffer Type";
69 public static final String BUFFERTYPE_PER_UID = "Per UID buffers";
43628e7b
BH
70 public static final String FILTER_EXPRESSION_LABEL = "Filter Expression";
71 public static final String SESSION_LIST_GROUP_NAME = "Session List";
2e65d221
BH
72
73 public static final String DESTROY_CONFIRM_DIALOG_TITLE = "Destroy Confirmation";
74 public static final String CHANNEL_NAME_LABEL = "Channel Name";
75
3d09f0a5
BH
76 public static final String SAVE_DIALOG_TITLE = "Save Sessions";
77 public static final String LOAD_DIALOG_TITLE = "Load Sessions";
78 public static final String REMOTE_RADIO_BUTTON_LABEL = "Remote";
2e65d221 79
325d8cac
BH
80 // Remote import strings
81 public static final String IMPORT_WIZARD_TITLE = "Fetch Remote Traces";
82 public static final String DEFAULT_REMOTE_PROJECT = "Remote";
83 public static final String FINISH_BUTTON = "Finish";
84 public static final String CANCEL_BUTTON = "Cancel";
85 public static final String OPTION_GROUP_NAME = "Options";
86
2e65d221
BH
87 private ControlViewSwtBotUtil() { }
88
89 /**
90 * Tests for Target node state
91 *
92 * @param node
93 * target node component
94 * @param state
95 * the state to wait
96 * @return the condition instance
97 */
98 public static ICondition isStateChanged(final TargetNodeComponent node, final TargetNodeState state) {
99 return new SWTBotTestCondition() {
100 @Override
101 public boolean test() throws Exception {
102 if (node.getTargetNodeState() != state) {
103 return false;
104 }
105 return true;
106 }
107 };
108 }
109
110 /**
111 * Tests for session state
112 *
113 * @param session
114 * the session component
115 * @param state
116 * the state to wait
117 * @return the condition instance
118 */
119 public static ICondition isSessionStateChanged(final TraceSessionComponent session, final TraceSessionState state) {
120 return new SWTBotTestCondition() {
121 @Override
122 public boolean test() throws Exception {
123 if (session.getSessionState() != state) {
124 return false;
125 }
126 return true;
127 }
128 };
129 }
130
131 /**
132 * Finds a session for given node
133 *
134 * @param target
135 * target node component
136 * @param sessionName
137 * session name to find
138 * @return the session component or null
139 */
3d09f0a5
BH
140 public static TraceSessionComponent getSessionComponent(TargetNodeComponent target, String sessionName) {
141 final TraceSessionComponent[] sessions = target.getSessions();
142 if (sessions != null) {
143 for (int i = 0; i < sessions.length; i++) {
144 if (sessionName.equals(sessions[i].getName())) {
145 return sessions[i];
146 }
147 }
148 }
149 return null;
2e65d221 150 }
2e65d221 151
43628e7b
BH
152 /**
153 * Finds a {@link ITraceControlComponent} in a tree for given path.
154 *
155 * @param root
156 * root component
157 * @param path
158 * path to element
159 * @return the matched component or null
160 */
161 public static ITraceControlComponent getComponent(ITraceControlComponent root, String... path) {
162 ITraceControlComponent newRoot = root;
163 for (String segment : path) {
164 newRoot = Arrays.asList(newRoot.getChildren()).stream()
165 .filter(child -> (child.getName().equals(segment)))
166 .findFirst()
167 .orElse(null);
168 if (newRoot == null) {
169 return null;
170 }
171 }
172 return newRoot;
173 }
174
2e65d221 175}
This page took 0.038077 seconds and 5 git commands to generate.