1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.control
.ui
.swtbot
.tests
;
12 import static org
.junit
.Assert
.assertEquals
;
13 import static org
.junit
.Assume
.assumeTrue
;
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
.eclipse
.tracecompass
.tmf
.ui
.tests
.shared
.WaitUtils
;
24 import org
.junit
.Test
;
25 import org
.junit
.runner
.RunWith
;
28 * Test for the Control view in Trace Compass. This will test the save and load feature.
30 * @author Bernd Hufmann
32 @RunWith(SWTBotJunit4ClassRunner
.class)
33 public class ControlViewProfileTest
extends ControlViewTest
{
35 // ------------------------------------------------------------------------
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";
42 private static final String SESSION_NAME
= String
.valueOf(System
.nanoTime());
45 protected String
getTestStream() {
50 protected String
getSessionName() {
56 public void testTraceSessionTree() {
58 // Save and load feature will only work on a Linux remote
61 fProxy
.setSessionName(getSessionName());
62 fProxy
.setTestFile(fTestFile
);
63 fProxy
.setScenario(INIT_SCENARIO_NAME
);
66 // Prepare for saving of profile
67 fProxy
.setScenario(CREATE_PROFILE_SCENARIO_NAME
);
72 // Disable saving of profiles
73 fProxy
.setProfileName(null);
74 fProxy
.deleteProfileFile();
75 fProxy
.setSessionName(null);
76 testDisconnectFromNode();
82 private void testSaveSession() {
83 fProxy
.setProfileName(getSessionName());
85 SWTBotTreeItem sessionItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
87 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
90 assertEquals(SESSION_NAME
, sessionItem
.getText());
93 SWTBotMenu menuBot
= sessionItem
.contextMenu(ControlViewSwtBotUtil
.SAVE_MENU_ITEM
);
96 SWTBotShell shell
= fBot
.shell(ControlViewSwtBotUtil
.SAVE_DIALOG_TITLE
).activate();
97 shell
.bot().button(ControlViewSwtBotUtil
.CONFIRM_DIALOG_OK_BUTTON
).click();
98 WaitUtils
.waitForJobs();
104 private void testLoadSession() {
105 SWTBotTreeItem nodeItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
, getNodeName());
106 SWTBotTreeItem sessionGroupItem
= nodeItem
.getNode(ControlViewSwtBotUtil
.SESSION_GROUP_NAME
);
108 sessionGroupItem
.select();
109 SWTBotMenu menuBot
= sessionGroupItem
.contextMenu(ControlViewSwtBotUtil
.LOAD_MENU_ITEM
);
112 SWTBotShell shell
= fBot
.shell(ControlViewSwtBotUtil
.LOAD_DIALOG_TITLE
).activate();
114 SWTBotRadio button
= shell
.bot().radio(ControlViewSwtBotUtil
.REMOTE_RADIO_BUTTON_LABEL
);
117 SWTBotTree shellTree
= shell
.bot().tree();
119 SWTBotTreeItem profileItem
= shellTree
.getTreeItem(SESSION_NAME
+ ControlViewSwtBotUtil
.PROFILE_SUFFIX
);
120 profileItem
.select();
123 shell
.bot().button(ControlViewSwtBotUtil
.CONFIRM_DIALOG_OK_BUTTON
).click();
124 WaitUtils
.waitForJobs();
126 sessionGroupItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
127 getNodeName(), ControlViewSwtBotUtil
.SESSION_GROUP_NAME
);
129 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(SESSION_NAME
, sessionGroupItem
));
130 assertEquals(1, sessionGroupItem
.getNodes().size());