1 /*******************************************************************************
2 * Copyright (c) 2014 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
10 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ctf
.ui
.swtbot
.tests
;
15 import static org
.junit
.Assert
.assertNotNull
;
19 import org
.eclipse
.core
.runtime
.Path
;
20 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
21 import org
.eclipse
.jface
.wizard
.WizardDialog
;
22 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.project
.wizards
.importtrace
.ImportTraceWizard
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.editors
.TmfEventsEditor
;
24 import org
.eclipse
.linuxtools
.tmf
.ui
.swtbot
.tests
.SWTBotUtil
;
25 import org
.eclipse
.linuxtools
.tmf
.ui
.swtbot
.tests
.conditions
.ConditionHelpers
;
26 import org
.eclipse
.swt
.widgets
.Shell
;
27 import org
.eclipse
.swtbot
.swt
.finder
.finders
.UIThreadRunnable
;
28 import org
.eclipse
.swtbot
.swt
.finder
.junit
.SWTBotJunit4ClassRunner
;
29 import org
.eclipse
.swtbot
.swt
.finder
.results
.VoidResult
;
30 import org
.eclipse
.swtbot
.swt
.finder
.waits
.Conditions
;
31 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotCombo
;
32 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotRadio
;
33 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotText
;
34 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTree
;
35 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTreeItem
;
36 import org
.eclipse
.ui
.IWorkbench
;
37 import org
.eclipse
.ui
.IWorkbenchWindow
;
38 import org
.eclipse
.ui
.PlatformUI
;
39 import org
.junit
.Test
;
40 import org
.junit
.runner
.RunWith
;
43 * SWTBot Smoke test using ImportTraceWizard.
45 * @author Bernd Hufmann
47 @RunWith(SWTBotJunit4ClassRunner
.class)
48 public class StandardImportAndReadSmokeTest
extends AbstractImportAndReadSmokeTest
{
50 private static final String TRACE_FOLDER_PARENT_PATH
= fTrace
.getPath() + File
.separator
+ ".." + File
.separator
+ ".." + File
.separator
;
51 private static final String TRACE_ARCHIVE_PATH
= TRACE_FOLDER_PARENT_PATH
+ "synctraces.tar.gz";
52 private static final String TRACE_PROJECT_NAME
= "Tracing";
58 public void testImportFromDirectory() {
65 TmfEventsEditor tmfEd
= openEditor();
67 testHistogramView(getViewPart("Histogram"), tmfEd
);
68 testPropertyView(getViewPart("Properties"));
69 testStatisticsView(getViewPart("Statistics"));
70 fBot
.closeAllEditors();
72 SWTBotUtil
.deleteProject(getProjectName(), fBot
);
76 * Test import from archive
79 public void testImportFromArchive() {
87 TmfEventsEditor tmfEd
= openEditor();
89 testHistogramView(getViewPart("Histogram"), tmfEd
);
90 testPropertyView(getViewPart("Properties"));
91 testStatisticsView(getViewPart("Statistics"));
92 fBot
.closeAllEditors();
94 SWTBotUtil
.deleteProject(getProjectName(), fBot
);
97 private static void importAddArchive() {
98 SWTBotRadio button
= fBot
.radio("Select &archive file:");
101 SWTBotCombo sourceCombo
= fBot
.comboBox(1);
103 sourceCombo
.setText(new File(TRACE_ARCHIVE_PATH
).getAbsolutePath());
105 SWTBotText text
= fBot
.text();
108 SWTBotTree tree
= fBot
.tree();
109 fBot
.waitUntil(Conditions
.widgetIsEnabled(tree
));
110 final SWTBotTreeItem genericCtfTreeItem
= tree
.getTreeItem("/");
111 fBot
.waitUntil(Conditions
.widgetIsEnabled(genericCtfTreeItem
));
112 genericCtfTreeItem
.check();
115 private static void importOpenWizard() {
116 fWizard
= new ImportTraceWizard();
118 UIThreadRunnable
.asyncExec(new VoidResult() {
121 final IWorkbench workbench
= PlatformUI
.getWorkbench();
122 // Fire the Import Trace Wizard
123 if (workbench
!= null) {
124 final IWorkbenchWindow activeWorkbenchWindow
= workbench
.getActiveWorkbenchWindow();
125 Shell shell
= activeWorkbenchWindow
.getShell();
126 assertNotNull(shell
);
127 ((ImportTraceWizard
) fWizard
).init(PlatformUI
.getWorkbench(), StructuredSelection
.EMPTY
);
128 WizardDialog dialog
= new WizardDialog(shell
, fWizard
);
134 fBot
.waitUntil(ConditionHelpers
.isWizardReady(fWizard
));
137 private static void importAddDirectory() {
138 SWTBotRadio button
= fBot
.radio("Select roo&t directory:");
141 SWTBotCombo sourceCombo
= fBot
.comboBox();
142 File traceFolderParent
= new File(TRACE_FOLDER_PARENT_PATH
);
143 sourceCombo
.setText(traceFolderParent
.getAbsolutePath());
145 SWTBotText text
= fBot
.text();
149 SWTBotTree tree
= fBot
.tree();
150 fBot
.waitUntil(Conditions
.widgetIsEnabled(tree
));
152 final String traceFolderParentName
= new Path(traceFolderParent
.getAbsolutePath()).lastSegment();
153 fBot
.waitUntil(ConditionHelpers
.IsTreeNodeAvailable(traceFolderParentName
, tree
));
154 final SWTBotTreeItem folderParentNode
= tree
.getTreeItem(traceFolderParentName
);
155 folderParentNode
.expand();
157 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(TRACE_FOLDER
, folderParentNode
));
158 final SWTBotTreeItem folderNode
= folderParentNode
.getNode(TRACE_FOLDER
);
163 protected String
getProjectName() {
164 return TRACE_PROJECT_NAME
;
168 protected boolean supportsFolderStructure() {