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
.junit
.Test
;
24 import org
.junit
.runner
.RunWith
;
27 * Test for the Control view in Trace Compass. This will test the save and load feature.
29 * @author Bernd Hufmann
31 @RunWith(SWTBotJunit4ClassRunner
.class)
32 public class ControlViewProfileTest
extends ControlViewTest
{
34 // ------------------------------------------------------------------------
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";
41 private static final String SESSION_NAME
= String
.valueOf(System
.nanoTime());
44 protected String
getTestStream() {
49 protected String
getSessionName() {
55 public void testTraceSessionTree() {
57 // Save and load feature will only work on a Linux remote
60 fProxy
.setSessionName(getSessionName());
61 fProxy
.setTestFile(fTestFile
);
62 fProxy
.setScenario(INIT_SCENARIO_NAME
);
65 // Prepare for saving of profile
66 fProxy
.setScenario(CREATE_PROFILE_SCENARIO_NAME
);
71 // Disable saving of profiles
72 fProxy
.setProfileName(null);
73 fProxy
.deleteProfileFile();
74 fProxy
.setSessionName(null);
75 testDisconnectFromNode();
81 private void testSaveSession() {
82 fProxy
.setProfileName(getSessionName());
84 SWTBotTreeItem sessionItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
86 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
89 assertEquals(SESSION_NAME
, sessionItem
.getText());
92 SWTBotMenu menuBot
= sessionItem
.contextMenu(ControlViewSwtBotUtil
.SAVE_MENU_ITEM
);
95 SWTBotShell shell
= fBot
.shell(ControlViewSwtBotUtil
.SAVE_DIALOG_TITLE
).activate();
96 shell
.bot().button(ControlViewSwtBotUtil
.CONFIRM_DIALOG_OK_BUTTON
).click();
97 SWTBotUtils
.waitForJobs();
103 private void testLoadSession() {
104 SWTBotTreeItem nodeItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
, getNodeName());
105 SWTBotTreeItem sessionGroupItem
= nodeItem
.getNode(ControlViewSwtBotUtil
.SESSION_GROUP_NAME
);
107 sessionGroupItem
.select();
108 SWTBotMenu menuBot
= sessionGroupItem
.contextMenu(ControlViewSwtBotUtil
.LOAD_MENU_ITEM
);
111 SWTBotShell shell
= fBot
.shell(ControlViewSwtBotUtil
.LOAD_DIALOG_TITLE
).activate();
113 SWTBotRadio button
= shell
.bot().radio(ControlViewSwtBotUtil
.REMOTE_RADIO_BUTTON_LABEL
);
116 SWTBotTree shellTree
= shell
.bot().tree();
118 SWTBotTreeItem profileItem
= shellTree
.getTreeItem(SESSION_NAME
+ ControlViewSwtBotUtil
.PROFILE_SUFFIX
);
119 profileItem
.select();
122 shell
.bot().button(ControlViewSwtBotUtil
.CONFIRM_DIALOG_OK_BUTTON
).click();
123 SWTBotUtils
.waitForJobs();
125 sessionGroupItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
126 getNodeName(), ControlViewSwtBotUtil
.SESSION_GROUP_NAME
);
128 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(SESSION_NAME
, sessionGroupItem
));
129 assertEquals(1, sessionGroupItem
.getNodes().size());