Commit | Line | Data |
---|---|---|
3d09f0a5 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 static org.junit.Assert.assertEquals; | |
13 | import static org.junit.Assume.assumeTrue; | |
14 | ||
15 | import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; | |
16 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; | |
17 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio; | |
18 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; | |
19 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; | |
20 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; | |
21 | import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; | |
22 | import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; | |
f0beeb4a | 23 | import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils; |
3d09f0a5 BH |
24 | import org.junit.Test; |
25 | import org.junit.runner.RunWith; | |
26 | ||
27 | /** | |
28 | * Test for the Control view in Trace Compass. This will test the save and load feature. | |
29 | * | |
30 | * @author Bernd Hufmann | |
31 | */ | |
32 | @RunWith(SWTBotJunit4ClassRunner.class) | |
33 | public class ControlViewProfileTest extends ControlViewTest { | |
34 | ||
35 | // ------------------------------------------------------------------------ | |
36 | // Constants | |
37 | // ------------------------------------------------------------------------ | |
38 | private static final boolean IS_LINUX = System.getProperty("os.name").contains("Linux") ? true : false; | |
39 | private static final String TEST_STREAM = "Profile.cfg"; | |
40 | private static final String CREATE_PROFILE_SCENARIO_NAME = "ProfileTest"; | |
41 | ||
921151cf | 42 | private static final String SESSION_NAME = String.valueOf(System.nanoTime()); |
3d09f0a5 BH |
43 | |
44 | @Override | |
45 | protected String getTestStream() { | |
46 | return TEST_STREAM; | |
47 | } | |
48 | ||
49 | @Override | |
50 | protected String getSessionName() { | |
51 | return SESSION_NAME; | |
52 | } | |
53 | ||
54 | @Override | |
55 | @Test | |
56 | public void testTraceSessionTree() { | |
57 | ||
58 | // Save and load feature will only work on a Linux remote | |
59 | assumeTrue(IS_LINUX); | |
60 | ||
921151cf | 61 | fProxy.setSessionName(getSessionName()); |
3d09f0a5 BH |
62 | fProxy.setTestFile(fTestFile); |
63 | fProxy.setScenario(INIT_SCENARIO_NAME); | |
64 | ||
65 | testConnectToNode(); | |
66 | // Prepare for saving of profile | |
67 | fProxy.setScenario(CREATE_PROFILE_SCENARIO_NAME); | |
68 | testSaveSession(); | |
69 | testDestroySession(); | |
70 | testLoadSession(); | |
71 | testDestroySession(); | |
72 | // Disable saving of profiles | |
73 | fProxy.setProfileName(null); | |
74 | fProxy.deleteProfileFile(); | |
921151cf | 75 | fProxy.setSessionName(null); |
3d09f0a5 BH |
76 | testDisconnectFromNode(); |
77 | } | |
78 | ||
79 | /** | |
80 | * Test save session | |
81 | */ | |
82 | private void testSaveSession() { | |
83 | fProxy.setProfileName(getSessionName()); | |
84 | ||
85 | SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree, | |
86 | getNodeName(), | |
87 | ControlViewSwtBotUtil.SESSION_GROUP_NAME, | |
88 | SESSION_NAME); | |
89 | ||
90 | assertEquals(SESSION_NAME, sessionItem.getText()); | |
91 | ||
92 | sessionItem.select(); | |
93 | SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.SAVE_MENU_ITEM); | |
94 | menuBot.click(); | |
95 | ||
96 | SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.SAVE_DIALOG_TITLE).activate(); | |
97 | shell.bot().button(ControlViewSwtBotUtil.CONFIRM_DIALOG_OK_BUTTON).click(); | |
f0beeb4a | 98 | WaitUtils.waitForJobs(); |
3d09f0a5 BH |
99 | } |
100 | ||
101 | /** | |
102 | * Test load session | |
103 | */ | |
104 | private void testLoadSession() { | |
105 | SWTBotTreeItem nodeItem = SWTBotUtils.getTreeItem(fBot, fTree, getNodeName()); | |
106 | SWTBotTreeItem sessionGroupItem = nodeItem.getNode(ControlViewSwtBotUtil.SESSION_GROUP_NAME); | |
107 | ||
108 | sessionGroupItem.select(); | |
109 | SWTBotMenu menuBot = sessionGroupItem.contextMenu(ControlViewSwtBotUtil.LOAD_MENU_ITEM); | |
110 | menuBot.click(); | |
111 | ||
112 | SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.LOAD_DIALOG_TITLE).activate(); | |
113 | ||
114 | SWTBotRadio button = shell.bot().radio(ControlViewSwtBotUtil.REMOTE_RADIO_BUTTON_LABEL); | |
115 | button.click(); | |
116 | ||
117 | SWTBotTree shellTree = shell.bot().tree(); | |
118 | ||
119 | SWTBotTreeItem profileItem = shellTree.getTreeItem(SESSION_NAME + ControlViewSwtBotUtil.PROFILE_SUFFIX); | |
120 | profileItem.select(); | |
121 | profileItem.click(); | |
122 | ||
123 | shell.bot().button(ControlViewSwtBotUtil.CONFIRM_DIALOG_OK_BUTTON).click(); | |
f0beeb4a | 124 | WaitUtils.waitForJobs(); |
3d09f0a5 BH |
125 | |
126 | sessionGroupItem = SWTBotUtils.getTreeItem(fBot, fTree, | |
127 | getNodeName(), ControlViewSwtBotUtil.SESSION_GROUP_NAME); | |
128 | ||
129 | fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(SESSION_NAME, sessionGroupItem)); | |
130 | assertEquals(1, sessionGroupItem.getNodes().size()); | |
131 | } | |
132 | ||
133 | } |