control: add swtbot test for testing load and save feature
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / swtbot / tests / ControlViewSwtBotUtil.java
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
10 package org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests;
11
12 import org.eclipse.swtbot.swt.finder.waits.ICondition;
13 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState;
14 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
15 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
16 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
17 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers.SWTBotTestCondition;
18
19 /**
20 * SWTBot utilities for ControlView test
21 *
22 * @author Bernd Hufmann
23 */
24 class ControlViewSwtBotUtil {
25
26 public static final String USER_HOME = System.getProperty("user.home");
27 public static final String DEFAULT_CHANNEL_NAME = "channel0";
28 public static final String KERNEL_DOMAIN_NAME = "Kernel";
29 public static final String UST_DOMAIN_NAME = "UST global";
30 public static final String SESSION_GROUP_NAME = "Sessions";
31 public static final String ALL_EVENTS_NAME = "*";
32 public static final String PROFILE_SUFFIX = ".lttng";
33
34 // Menu strings
35 public static final String CONNECT_MENU_ITEM = "Connect";
36 public static final String CREATE_SESSION_MENU_ITEM = "Create Session...";
37 public static final String ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM = "Enable Event (default channel)...";
38 public static final String ENABLE_CHANNEL_MENU_ITEM = "Enable Channel...";
39 public static final String ENABLE_EVENT_MENU_ITEM = "Enable Event...";
40 public static final String START_MENU_ITEM = "Start";
41 public static final String STOP_MENU_ITEM = "Stop";
42 public static final String DESTROY_MENU_ITEM = "Destroy Session...";
43 public static final String DISCONNECT_MENU_ITEM = "Disconnect";
44 public static final String SAVE_MENU_ITEM = "Save...";
45 public static final String LOAD_MENU_ITEM = "Load...";
46
47 // Dialog strings
48 public static final String CREATE_SESSION_DIALOG_TITLE = "Create Session";
49 public static final String SESSION_NAME_LABEL = "Session Name";
50 public static final String DIALOG_OK_BUTTON = "Ok";
51 public static final String CONFIRM_DIALOG_OK_BUTTON = "OK";
52 public static final String ENABLE_EVENT_DIALOG_TITLE = "Enable Events";
53 public static final String ALL_TREE_NODE = "All";
54 public static final String SYSCALL_GROUP_NAME = "All Syscalls";
55 public static final String GROUP_SELECT_NAME = "Select";
56 public static final String ENABLE_CHANNEL_DIALOG_TITLE = "Enable Channel";
57 public static final String DOMAIN_GROUP_NAME = "Domain";
58 public static final String UST_GROUP_NAME = "UST";
59 public static final String BUFFERTYPE_GROUP_NAME = "Buffer Type";
60 public static final String BUFFERTYPE_PER_UID = "Per UID buffers";
61
62 public static final String DESTROY_CONFIRM_DIALOG_TITLE = "Destroy Confirmation";
63 public static final String CHANNEL_NAME_LABEL = "Channel Name";
64
65 public static final String SAVE_DIALOG_TITLE = "Save Sessions";
66 public static final String LOAD_DIALOG_TITLE = "Load Sessions";
67 public static final String REMOTE_RADIO_BUTTON_LABEL = "Remote";
68
69 private ControlViewSwtBotUtil() { }
70
71 /**
72 * Tests for Target node state
73 *
74 * @param node
75 * target node component
76 * @param state
77 * the state to wait
78 * @return the condition instance
79 */
80 public static ICondition isStateChanged(final TargetNodeComponent node, final TargetNodeState state) {
81 return new SWTBotTestCondition() {
82 @Override
83 public boolean test() throws Exception {
84 if (node.getTargetNodeState() != state) {
85 return false;
86 }
87 return true;
88 }
89 };
90 }
91
92 /**
93 * Tests for session state
94 *
95 * @param session
96 * the session component
97 * @param state
98 * the state to wait
99 * @return the condition instance
100 */
101 public static ICondition isSessionStateChanged(final TraceSessionComponent session, final TraceSessionState state) {
102 return new SWTBotTestCondition() {
103 @Override
104 public boolean test() throws Exception {
105 if (session.getSessionState() != state) {
106 return false;
107 }
108 return true;
109 }
110 };
111 }
112
113 /**
114 * Finds a session for given node
115 *
116 * @param target
117 * target node component
118 * @param sessionName
119 * session name to find
120 * @return the session component or null
121 */
122 public static TraceSessionComponent getSessionComponent(TargetNodeComponent target, String sessionName) {
123 final TraceSessionComponent[] sessions = target.getSessions();
124 if (sessions != null) {
125 for (int i = 0; i < sessions.length; i++) {
126 if (sessionName.equals(sessions[i].getName())) {
127 return sessions[i];
128 }
129 }
130 }
131 return null;
132 }
133
134 }
This page took 0.037254 seconds and 6 git commands to generate.