Commit | Line | Data |
---|---|---|
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 | ||
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 | ||
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 | ||
33 | // Menu strings | |
34 | public static final String CONNECT_MENU_ITEM = "Connect"; | |
35 | public static final String CREATE_SESSION_MENU_ITEM = "Create Session..."; | |
36 | public static final String ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM = "Enable Event (default channel)..."; | |
37 | public static final String ENABLE_CHANNEL_MENU_ITEM = "Enable Channel..."; | |
38 | public static final String ENABLE_EVENT_MENU_ITEM = "Enable Event..."; | |
39 | public static final String START_MENU_ITEM = "Start"; | |
40 | public static final String STOP_MENU_ITEM = "Stop"; | |
41 | public static final String DESTROY_MENU_ITEM = "Destroy Session..."; | |
42 | public static final String DISCONNECT_MENU_ITEM = "Disconnect"; | |
43 | ||
44 | // Dialog strings | |
45 | public static final String CREATE_SESSION_DIALOG_TITLE = "Create Session"; | |
46 | public static final String SESSION_NAME_LABEL = "Session Name"; | |
47 | public static final String DIALOG_OK_BUTTON = "Ok"; | |
48 | public static final String CONFIRM_DIALOG_OK_BUTTON = "OK"; | |
49 | public static final String ENABLE_EVENT_DIALOG_TITLE = "Enable Events"; | |
50 | public static final String ALL_TREE_NODE = "All"; | |
51 | public static final String SYSCALL_GROUP_NAME = "All Syscalls"; | |
52 | public static final String GROUP_SELECT_NAME = "Select"; | |
53 | public static final String ENABLE_CHANNEL_DIALOG_TITLE = "Enable Channel"; | |
54 | public static final String DOMAIN_GROUP_NAME = "Domain"; | |
55 | public static final String UST_GROUP_NAME = "UST"; | |
56 | public static final String BUFFERTYPE_GROUP_NAME = "Buffer Type"; | |
57 | public static final String BUFFERTYPE_PER_UID = "Per UID buffers"; | |
58 | ||
59 | public static final String DESTROY_CONFIRM_DIALOG_TITLE = "Destroy Confirmation"; | |
60 | public static final String CHANNEL_NAME_LABEL = "Channel Name"; | |
61 | ||
62 | ||
63 | ||
64 | private ControlViewSwtBotUtil() { } | |
65 | ||
66 | /** | |
67 | * Tests for Target node state | |
68 | * | |
69 | * @param node | |
70 | * target node component | |
71 | * @param state | |
72 | * the state to wait | |
73 | * @return the condition instance | |
74 | */ | |
75 | public static ICondition isStateChanged(final TargetNodeComponent node, final TargetNodeState state) { | |
76 | return new SWTBotTestCondition() { | |
77 | @Override | |
78 | public boolean test() throws Exception { | |
79 | if (node.getTargetNodeState() != state) { | |
80 | return false; | |
81 | } | |
82 | return true; | |
83 | } | |
84 | }; | |
85 | } | |
86 | ||
87 | /** | |
88 | * Tests for session state | |
89 | * | |
90 | * @param session | |
91 | * the session component | |
92 | * @param state | |
93 | * the state to wait | |
94 | * @return the condition instance | |
95 | */ | |
96 | public static ICondition isSessionStateChanged(final TraceSessionComponent session, final TraceSessionState state) { | |
97 | return new SWTBotTestCondition() { | |
98 | @Override | |
99 | public boolean test() throws Exception { | |
100 | if (session.getSessionState() != state) { | |
101 | return false; | |
102 | } | |
103 | return true; | |
104 | } | |
105 | }; | |
106 | } | |
107 | ||
108 | /** | |
109 | * Finds a session for given node | |
110 | * | |
111 | * @param target | |
112 | * target node component | |
113 | * @param sessionName | |
114 | * session name to find | |
115 | * @return the session component or null | |
116 | */ | |
117 | public static TraceSessionComponent getSessionComponent(TargetNodeComponent target, String sessionName) { | |
118 | final TraceSessionComponent[] sessions = target.getSessions(); | |
119 | if (sessions != null) { | |
120 | for (int i = 0; i < sessions.length; i++) { | |
121 | if (sessionName.equals(sessions[i].getName())) { | |
122 | return sessions[i]; | |
123 | } | |
124 | } | |
125 | } | |
126 | return null; | |
127 | } | |
128 | ||
129 | } |