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