Commit | Line | Data |
---|---|---|
6614e196 MAL |
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 | * Contributors: | |
10 | * Marc-Andre Laperle - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.tracecompass.tmf.remote.ui.swtbot.tests.fetch; | |
14 | ||
15 | import static org.junit.Assert.assertEquals; | |
16 | import static org.junit.Assert.assertNotNull; | |
17 | import static org.junit.Assert.assertTrue; | |
78ef9da2 | 18 | import static org.junit.Assert.fail; |
6614e196 MAL |
19 | |
20 | import java.io.File; | |
21 | import java.io.IOException; | |
22 | import java.net.URISyntaxException; | |
23 | import java.util.List; | |
24 | ||
25 | import org.apache.log4j.Logger; | |
26 | import org.apache.log4j.varia.NullAppender; | |
27 | import org.eclipse.core.resources.ResourcesPlugin; | |
28 | import org.eclipse.core.runtime.FileLocator; | |
29 | import org.eclipse.core.runtime.IPath; | |
30 | import org.eclipse.core.runtime.Path; | |
78ef9da2 MAL |
31 | import org.eclipse.jface.bindings.keys.IKeyLookup; |
32 | import org.eclipse.jface.bindings.keys.KeyStroke; | |
33 | import org.eclipse.jface.bindings.keys.ParseException; | |
6614e196 MAL |
34 | import org.eclipse.osgi.util.NLS; |
35 | import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; | |
36 | import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; | |
37 | import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; | |
38 | import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; | |
39 | import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; | |
40 | import org.eclipse.swtbot.swt.finder.utils.SWTUtils; | |
41 | import org.eclipse.swtbot.swt.finder.waits.Conditions; | |
42 | import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; | |
43 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; | |
44 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; | |
45 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; | |
46 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; | |
47 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; | |
48 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; | |
c4d57ac1 | 49 | import org.eclipse.tracecompass.ctf.core.tests.shared.LttngKernelTraceGenerator; |
6614e196 MAL |
50 | import org.eclipse.tracecompass.tmf.remote.ui.swtbot.tests.TmfRemoteUISWTBotTestPlugin; |
51 | import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement; | |
52 | import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry; | |
53 | import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement; | |
54 | import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; | |
55 | import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; | |
56 | import org.junit.BeforeClass; | |
57 | import org.junit.Test; | |
58 | import org.junit.runner.RunWith; | |
59 | ||
60 | /** | |
61 | * Test the Fetch Remote Traces wizard. | |
62 | */ | |
63 | @RunWith(SWTBotJunit4ClassRunner.class) | |
64 | public class FetchRemoteTracesTest { | |
65 | ||
66 | private static final String CONNECTION_NODE_NAME = "node1"; | |
67 | private static final String CONNECTION_NODE_TEXT = CONNECTION_NODE_NAME + " (file://)"; | |
68 | private static final String LTTNG_TRACE_FILE_PATTERN = ".*synthetic.*"; | |
69 | private static final String FETCH_COMMAND_NAME = "Fetch Remote Traces..."; | |
70 | private static final String PROFILE_NAME = "new profile"; | |
71 | private static final String PROJECT_EXPLORER = "Project Explorer"; | |
72 | private static final String PROJECT_NAME = "Test"; | |
73 | private static final String SYSLOG_FILE_PATTERN = ".*syslog"; | |
74 | private static final String TRACE_GROUP_NODE_TEXT; | |
75 | private static final String TRACE_LOCATION; | |
76 | private static final String TRACE_TYPE_LTTNG = "org.eclipse.linuxtools.lttng2.kernel.tracetype"; | |
77 | private static final String TRACE_TYPE_SYSLOG = "org.eclipse.linuxtools.tmf.tests.stubs.trace.text.testsyslog"; | |
78 | private static final String WELCOME_NAME = "welcome"; | |
79 | ||
80 | private static SWTWorkbenchBot fBot; | |
81 | ||
82 | static { | |
83 | String traceLocation = ""; | |
84 | try { | |
85 | IPath resourcesPath = new Path("resources"); | |
86 | File resourcesFile = getBundleFile(resourcesPath); | |
87 | // Create a sub directory to test the trace folders at the same time | |
88 | IPath subDirFullPath = new Path(resourcesFile.getAbsolutePath()).append("generated"); | |
89 | File subDirFile = new File(subDirFullPath.toOSString()); | |
90 | subDirFile.mkdir(); | |
91 | ||
92 | IPath generatedTraceFullPath = subDirFullPath.append("synthetic-trace"); | |
93 | File generatedTraceFile = new File(generatedTraceFullPath.toOSString()); | |
94 | LttngKernelTraceGenerator.generateLttngKernelTrace(generatedTraceFile); | |
95 | traceLocation = new Path(resourcesFile.getAbsolutePath()).toString(); | |
96 | } catch (IOException e) { | |
97 | e.printStackTrace(); | |
98 | } catch (URISyntaxException e) { | |
99 | e.printStackTrace(); | |
100 | } | |
101 | TRACE_LOCATION = traceLocation; | |
102 | TRACE_GROUP_NODE_TEXT = TRACE_LOCATION + " (recursive)"; | |
103 | } | |
104 | ||
105 | private static File getBundleFile(IPath relativePath) throws URISyntaxException, IOException { | |
106 | return new File(FileLocator.toFileURL(FileLocator.find(TmfRemoteUISWTBotTestPlugin.getDefault().getBundle(), relativePath, null)).toURI()); | |
107 | } | |
108 | ||
109 | /** Test Class setup */ | |
110 | @BeforeClass | |
111 | public static void init() { | |
112 | SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; | |
113 | SWTBotUtils.failIfUIThread(); | |
114 | SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */ | |
115 | Logger.getRootLogger().addAppender(new NullAppender()); | |
116 | fBot = new SWTWorkbenchBot(); | |
117 | ||
118 | SWTBotUtils.closeView(WELCOME_NAME, fBot); | |
119 | ||
120 | SWTBotUtils.switchToTracingPerspective(); | |
121 | /* finish waiting for eclipse to load */ | |
122 | SWTBotUtils.waitForJobs(); | |
123 | } | |
124 | ||
125 | private static class TraceCountCondition extends DefaultCondition { | |
126 | ||
127 | private final TmfProjectElement fProject; | |
128 | private final int fExpectedCount; | |
129 | ||
130 | public TraceCountCondition(TmfProjectElement project, int expectedNumber) { | |
131 | fProject = project; | |
132 | fExpectedCount = expectedNumber; | |
133 | } | |
134 | ||
135 | @Override | |
136 | public boolean test() throws Exception { | |
137 | return fProject.getTracesFolder().getTraces().size() == fExpectedCount; | |
138 | } | |
139 | ||
140 | @Override | |
141 | public String getFailureMessage() { | |
142 | return NLS.bind("The project {0} does not contain {1} traces.", fProject.getName(), fExpectedCount); | |
143 | } | |
144 | } | |
145 | ||
146 | /** | |
147 | * Test creating a profile, fetching all using the profile. | |
148 | */ | |
149 | @Test | |
150 | public void testImportAll() { | |
151 | testImport(new Runnable() { | |
152 | @Override | |
153 | public void run() { | |
154 | } | |
155 | }, new Runnable() { | |
156 | @Override | |
157 | public void run() { | |
158 | final TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true); | |
159 | fBot.waitUntil(new TraceCountCondition(project, 2)); | |
160 | List<TmfTraceElement> traces = project.getTracesFolder().getTraces(); | |
161 | assertEquals(2, traces.size()); | |
a5544859 BH |
162 | testTrace(traces.get(0), CONNECTION_NODE_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_LTTNG); |
163 | testTrace(traces.get(1), CONNECTION_NODE_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG); | |
6614e196 MAL |
164 | } |
165 | }); | |
166 | } | |
167 | ||
168 | /** | |
169 | * Test creating a profile, fetching only one trace | |
170 | */ | |
171 | @Test | |
172 | public void testImportOnlyOne() { | |
173 | testImport(new Runnable() { | |
174 | @Override | |
175 | public void run() { | |
176 | SWTBotTree tree = fBot.tree(); | |
177 | fBot.button("Deselect All").click(); | |
178 | int length = tree.getAllItems().length; | |
179 | assertTrue(length > 0); | |
180 | // Selecting the second trace under node > traceGroup | |
181 | SWTBotTreeItem node = getTreeItem(fBot, tree, new String[] { CONNECTION_NODE_TEXT, TRACE_GROUP_NODE_TEXT }).getNode(1); | |
182 | assertEquals("syslog", node.getText()); | |
183 | node.check(); | |
184 | } | |
185 | }, new Runnable() { | |
186 | @Override | |
187 | public void run() { | |
188 | TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true); | |
189 | fBot.waitUntil(new TraceCountCondition(project, 1)); | |
190 | List<TmfTraceElement> traces = project.getTracesFolder().getTraces(); | |
191 | assertEquals(1, traces.size()); | |
a5544859 | 192 | testTrace(traces.get(0), CONNECTION_NODE_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG); |
6614e196 MAL |
193 | } |
194 | }); | |
195 | } | |
196 | ||
197 | /** | |
198 | * Test creating a profile, fetching nothing | |
199 | */ | |
200 | @Test | |
201 | public void testImportNothing() { | |
202 | testImport(new Runnable() { | |
203 | @Override | |
204 | public void run() { | |
205 | fBot.button("Deselect All").click(); | |
206 | } | |
207 | }, new Runnable() { | |
208 | @Override | |
209 | public void run() { | |
210 | TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true); | |
211 | List<TmfTraceElement> traces = project.getTracesFolder().getTraces(); | |
212 | assertEquals(0, traces.size()); | |
213 | } | |
214 | }); | |
215 | } | |
216 | ||
fc4a373f BH |
217 | /** |
218 | * Test to verify that empty files are omitted. | |
219 | */ | |
220 | @Test | |
221 | public void testEmptyFile() { | |
222 | testImport(new Runnable() { | |
223 | @Override | |
224 | public void run() { | |
225 | SWTBotTree tree = fBot.tree(); | |
226 | fBot.button("Deselect All").click(); | |
227 | int length = tree.getAllItems().length; | |
228 | assertTrue(length > 0); | |
229 | ||
230 | SWTBotTreeItem groupNode = getTreeItem(fBot, tree, new String[] { CONNECTION_NODE_TEXT, TRACE_GROUP_NODE_TEXT }); | |
231 | /* | |
232 | * Currently there are 3 items at the location where 1 file has 0 bytes. | |
233 | * Verify that empty file is not shown. | |
234 | */ | |
235 | assertEquals(2, groupNode.getItems().length); | |
236 | } | |
237 | }, new Runnable() { | |
238 | @Override | |
239 | public void run() { | |
240 | TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true); | |
241 | List<TmfTraceElement> traces = project.getTracesFolder().getTraces(); | |
242 | assertEquals(0, traces.size()); | |
243 | } | |
244 | }); | |
245 | } | |
246 | ||
247 | ||
6614e196 MAL |
248 | /** |
249 | * Test editing a profile | |
250 | */ | |
251 | @Test | |
252 | public void testEditProfile() { | |
253 | openRemoteProfilePreferences(); | |
254 | createProfile(); | |
255 | openRemoteProfilePreferences(); | |
256 | ||
257 | // The first tree is the preference "categories" on the left side, we | |
258 | // need to skip it | |
259 | SWTBotTree tree = fBot.tree(1); | |
260 | ||
261 | final String[] traceGroupNodePath = new String[] { PROFILE_NAME, CONNECTION_NODE_TEXT, TRACE_GROUP_NODE_TEXT }; | |
262 | ||
263 | // Initial order of traces | |
264 | SWTBotTreeItem traceGroupNode = getTreeItem(fBot, tree, traceGroupNodePath); | |
265 | SWTBotTreeItem[] traceNodes = traceGroupNode.getItems(); | |
266 | assertEquals(2, traceNodes.length); | |
267 | assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[0].getText()); | |
268 | assertEquals(SYSLOG_FILE_PATTERN, traceNodes[1].getText()); | |
269 | ||
270 | // Test moving down a trace element | |
271 | SWTBotTreeItem traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); | |
272 | traceNode.select(); | |
273 | fBot.button("Move Down").click(); | |
274 | traceGroupNode = getTreeItem(fBot, tree, traceGroupNodePath); | |
275 | traceNodes = traceGroupNode.getItems(); | |
276 | assertEquals(2, traceNodes.length); | |
277 | assertEquals(SYSLOG_FILE_PATTERN, traceNodes[0].getText()); | |
278 | assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[1].getText()); | |
279 | ||
280 | // Test moving down a trace element | |
281 | traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); | |
282 | traceNode.select(); | |
283 | fBot.button("Move Up").click(); | |
284 | traceGroupNode = getTreeItem(fBot, tree, traceGroupNodePath); | |
285 | traceNodes = traceGroupNode.getItems(); | |
286 | assertEquals(2, traceNodes.length); | |
287 | assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[0].getText()); | |
288 | assertEquals(SYSLOG_FILE_PATTERN, traceNodes[1].getText()); | |
289 | ||
290 | // Test Copy/Paste | |
291 | traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); | |
292 | traceNode.select().contextMenu("Copy").click(); | |
293 | traceNode.contextMenu("Paste").click(); | |
294 | traceNodes = traceGroupNode.getItems(); | |
295 | assertEquals(3, traceNodes.length); | |
296 | assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[0].getText()); | |
297 | assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[1].getText()); | |
298 | assertEquals(SYSLOG_FILE_PATTERN, traceNodes[2].getText()); | |
299 | ||
300 | // Test Cut/Paste | |
301 | traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); | |
302 | traceNode.select().contextMenu("Cut").click(); | |
303 | traceNode = traceGroupNode.getNode(SYSLOG_FILE_PATTERN); | |
304 | traceNode.select().contextMenu("Paste").click(); | |
305 | traceNodes = traceGroupNode.getItems(); | |
306 | assertEquals(3, traceNodes.length); | |
307 | assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[0].getText()); | |
308 | assertEquals(SYSLOG_FILE_PATTERN, traceNodes[1].getText()); | |
309 | assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[2].getText()); | |
310 | ||
311 | // Test Delete | |
312 | traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); | |
313 | traceNode.select().contextMenu("Delete").click(); | |
314 | traceNodes = traceGroupNode.getItems(); | |
315 | assertEquals(2, traceNodes.length); | |
316 | assertEquals(SYSLOG_FILE_PATTERN, traceNodes[0].getText()); | |
317 | assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[1].getText()); | |
318 | // Copy to test Paste after Delete | |
319 | traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); | |
320 | traceNode.select().contextMenu("Copy").click(); | |
321 | traceNode = traceGroupNode.select(SYSLOG_FILE_PATTERN, LTTNG_TRACE_FILE_PATTERN); | |
322 | traceNode.pressShortcut(Keystrokes.DELETE); | |
323 | traceNodes = traceGroupNode.getItems(); | |
324 | assertEquals(0, traceNodes.length); | |
325 | // Paste after Delete | |
326 | traceGroupNode.contextMenu("Paste").click(); | |
327 | traceNodes = traceGroupNode.getItems(); | |
328 | assertEquals(1, traceNodes.length); | |
329 | assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[0].getText()); | |
330 | fBot.button("OK").click(); | |
331 | deleteProfile(); | |
332 | } | |
333 | ||
334 | private static void testImport(Runnable selectionFunctor, Runnable verifyTracesFunctor) { | |
335 | SWTBotUtils.createProject(PROJECT_NAME); | |
336 | SWTBotUtils.waitForJobs(); | |
337 | SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); | |
338 | assertNotNull("Cannot find " + PROJECT_EXPLORER, projectExplorerBot); | |
339 | projectExplorerBot.show(); | |
340 | SWTBotTreeItem treeItem = getTracesFolderTreeItem(projectExplorerBot); | |
341 | ||
342 | treeItem.contextMenu(FETCH_COMMAND_NAME).click(); | |
343 | ||
344 | fBot.button("Manage Profiles").click(); | |
345 | ||
346 | createProfile(); | |
347 | ||
348 | assertEquals(PROFILE_NAME, fBot.comboBoxWithLabel("Profile name:").getText()); | |
349 | assertEquals(CONNECTION_NODE_TEXT, fBot.textWithLabel("Nodes:").getText()); | |
350 | ||
351 | // Make sure if we go to the next page and come back that the first page | |
352 | // still has valid values | |
353 | SWTBotButton button = fBot.button("Next >"); | |
354 | fBot.waitUntil(Conditions.widgetIsEnabled(button)); | |
355 | button.click(); | |
356 | button = fBot.button("< Back"); | |
357 | fBot.waitUntil(Conditions.widgetIsEnabled(button)); | |
358 | button.click(); | |
359 | assertEquals(PROFILE_NAME, fBot.comboBoxWithLabel("Profile name:").getText()); | |
360 | assertEquals(CONNECTION_NODE_TEXT, fBot.textWithLabel("Nodes:").getText()); | |
361 | ||
362 | button = fBot.button("Next >"); | |
363 | fBot.waitUntil(Conditions.widgetIsEnabled(button)); | |
364 | button.click(); | |
365 | ||
366 | selectionFunctor.run(); | |
367 | ||
368 | SWTBotShell shell = fBot.activeShell(); | |
369 | ||
370 | button = fBot.button("Finish"); | |
371 | fBot.waitUntil(Conditions.widgetIsEnabled(button)); | |
372 | button.click(); | |
373 | fBot.waitUntil(Conditions.shellCloses(shell)); | |
374 | SWTBotUtils.waitForJobs(); | |
375 | ||
376 | verifyTracesFunctor.run(); | |
377 | fBot.closeAllEditors(); | |
378 | SWTBotUtils.deleteProject(PROJECT_NAME, fBot); | |
379 | deleteProfile(); | |
380 | } | |
381 | ||
382 | private static void createProfile() { | |
383 | fBot.button("Add").click(); | |
384 | ||
385 | // The first tree is the preference "categories" on the left side, we | |
386 | // need to skip it | |
387 | SWTBotTree tree = fBot.tree(1); | |
388 | ||
389 | SWTBotTreeItem treeNode = getTreeItem(fBot, tree, PROFILE_NAME, "name (ssh://userinfo@host:22)"); | |
390 | treeNode.select(); | |
391 | SWTBotText uriLabel = fBot.textWithLabel("URI:"); | |
392 | uriLabel.setText("file://"); | |
393 | SWTBotText nodeNameLabel = fBot.textWithLabel("Node name:"); | |
394 | nodeNameLabel.setText(CONNECTION_NODE_NAME); | |
395 | ||
396 | SWTBotTreeItem traceRootNode = treeNode.getNode("/rootpath"); | |
397 | traceRootNode.select(); | |
398 | SWTBotText pathLabel = fBot.textWithLabel("Root path:"); | |
399 | pathLabel.setText(TRACE_LOCATION); | |
400 | fBot.checkBox("Recursive").select(); | |
401 | ||
402 | // Add the ctf file pattern | |
403 | treeNode = traceRootNode.getNode(".*"); | |
404 | treeNode.select(); | |
405 | SWTBotText filePatternLabel = fBot.textWithLabel("File pattern:"); | |
406 | filePatternLabel.setText(LTTNG_TRACE_FILE_PATTERN); | |
407 | ||
408 | // Add the syslog file pattern | |
409 | traceRootNode.contextMenu("New Trace").click(); | |
410 | treeNode = traceRootNode.getNode(".*"); | |
411 | treeNode.select(); | |
412 | filePatternLabel = fBot.textWithLabel("File pattern:"); | |
413 | filePatternLabel.setText(SYSLOG_FILE_PATTERN); | |
414 | SWTBotCombo combo = fBot.comboBoxWithLabel("Trace type:"); | |
415 | combo.setSelection("Test trace : Test Syslog"); | |
416 | ||
417 | fBot.button("OK").click(); | |
418 | } | |
419 | ||
420 | private static void testTrace(TmfTraceElement tmfTraceElement, String expectedTracePath, String traceType) { | |
421 | assertEquals(traceType, tmfTraceElement.getTraceType()); | |
422 | IPath tracePath = new Path(tmfTraceElement.getElementPath()); | |
423 | assertEquals(expectedTracePath, tracePath.toString()); | |
424 | SWTBotUtils.openEditor(fBot, PROJECT_NAME, tracePath); | |
425 | } | |
426 | ||
427 | private static void deleteProfile() { | |
428 | openRemoteProfilePreferences(); | |
429 | ||
430 | // The second tree is the remote profiles tree on the right side | |
431 | SWTBotTree tree = fBot.tree(1); | |
432 | SWTBotTreeItem treeNode = tree.getTreeItem(PROFILE_NAME); | |
433 | treeNode.select(); | |
434 | fBot.button("Remove").click(); | |
435 | assertEquals(0, tree.getAllItems().length); | |
436 | fBot.button("OK").click(); | |
437 | } | |
438 | ||
439 | private static SWTBotTreeItem getTreeItem(SWTWorkbenchBot bot, SWTBotTree tree, String... nodeNames) { | |
440 | if (nodeNames.length == 0) { | |
441 | return null; | |
442 | } | |
443 | ||
444 | SWTBotTreeItem currentNode = tree.getTreeItem(nodeNames[0]); | |
445 | for (int i = 1; i < nodeNames.length; i++) { | |
446 | String nodeName = nodeNames[i]; | |
447 | bot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(nodeName, currentNode)); | |
448 | SWTBotTreeItem newNode = currentNode.getNode(nodeName); | |
449 | currentNode = newNode; | |
450 | } | |
451 | ||
452 | return currentNode; | |
453 | } | |
454 | ||
455 | private static void openRemoteProfilePreferences() { | |
456 | if (SWTUtils.isMac()) { | |
457 | // On Mac, the Preferences menu item is under the application name. | |
78ef9da2 MAL |
458 | // For some reason, we can't access the application menu anymore so |
459 | // we use the keyboard shortcut. | |
460 | try { | |
461 | fBot.activeShell().pressShortcut(KeyStroke.getInstance(IKeyLookup.COMMAND_NAME + "+"), KeyStroke.getInstance(",")); | |
462 | } catch (ParseException e) { | |
463 | fail(); | |
464 | } | |
6614e196 MAL |
465 | } else { |
466 | fBot.menu("Window").menu("Preferences").click(); | |
467 | } | |
468 | ||
78ef9da2 MAL |
469 | fBot.waitUntil(Conditions.shellIsActive("Preferences")); |
470 | ||
6614e196 MAL |
471 | // The first tree is the preference "categories" on the left side |
472 | SWTBotTree tree = fBot.tree(0); | |
473 | SWTBotTreeItem treeNode = tree.getTreeItem("Tracing"); | |
474 | treeNode.select(); | |
475 | treeNode.expand(); | |
476 | fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable("Remote Profiles", treeNode)); | |
477 | treeNode = treeNode.getNode("Remote Profiles"); | |
478 | treeNode.select(); | |
479 | } | |
480 | ||
481 | private static SWTBotTreeItem getTracesFolderTreeItem(SWTBotView projectExplorerBot) { | |
482 | SWTBotTreeItem treeItem = projectExplorerBot.bot().tree().getTreeItem(PROJECT_NAME); | |
483 | treeItem.select(); | |
484 | treeItem.expand(); | |
485 | return treeItem.getNode("Traces [0]"); | |
486 | } | |
487 | ||
488 | } |