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