1 /*******************************************************************************
2 * Copyright (c) 2013, 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 * Matthew Khouzam - Initial API and implementation
12 * Bernd Hufmann - Extracted functionality to class AbstractImportAndReadSmokeTest
13 *******************************************************************************/
15 package org
.eclipse
.linuxtools
.tmf
.ctf
.ui
.swtbot
.tests
;
17 import static org
.junit
.Assert
.assertNotNull
;
19 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
20 import org
.eclipse
.jface
.wizard
.IWizardPage
;
21 import org
.eclipse
.jface
.wizard
.WizardDialog
;
22 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.project
.wizards
.importtrace
.BatchImportTraceWizard
;
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
.SWTBotButton
;
32 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTree
;
33 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTreeItem
;
34 import org
.eclipse
.ui
.IWorkbench
;
35 import org
.eclipse
.ui
.IWorkbenchWindow
;
36 import org
.eclipse
.ui
.PlatformUI
;
37 import org
.junit
.Test
;
38 import org
.junit
.runner
.RunWith
;
41 * SWTBot Smoke test. base for other tests
43 * @author Matthew Khouzam
45 @RunWith(SWTBotJunit4ClassRunner
.class)
46 public class ImportAndReadSmokeTest
extends AbstractImportAndReadSmokeTest
{
48 private static final String TRACE_PROJECT_NAME
= "test";
57 batchImportOpenWizard();
58 batchImportSelecTraceType();
59 batchImportAddDirectory();
60 batchImportSelectTrace();
63 TmfEventsEditor tmfEd
= openEditor();
65 testHistogramView(getViewPart("Histogram"), tmfEd
);
66 testPropertyView(getViewPart("Properties"));
67 testStatisticsView(getViewPart("Statistics"));
68 fBot
.closeAllEditors();
70 SWTBotUtil
.deleteProject(getProjectName(), fBot
);
73 private static void batchImportOpenWizard() {
74 fWizard
= new BatchImportTraceWizard();
76 UIThreadRunnable
.asyncExec(new VoidResult() {
79 final IWorkbench workbench
= PlatformUI
.getWorkbench();
80 // Fire the Import Trace Wizard
81 if (workbench
!= null) {
82 final IWorkbenchWindow activeWorkbenchWindow
= workbench
.getActiveWorkbenchWindow();
83 Shell shell
= activeWorkbenchWindow
.getShell();
85 ((BatchImportTraceWizard
) fWizard
).init(PlatformUI
.getWorkbench(), StructuredSelection
.EMPTY
);
86 WizardDialog dialog
= new WizardDialog(shell
, fWizard
);
92 fBot
.waitUntil(ConditionHelpers
.isWizardReady(fWizard
));
95 private static void batchImportSelecTraceType() {
96 final SWTBotTree tree
= fBot
.tree();
97 final String ctfId
= "Common Trace Format";
98 fBot
.waitUntil(ConditionHelpers
.IsTreeNodeAvailable(ctfId
, tree
));
99 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(TRACE_TYPE_NAME
, tree
.getTreeItem(ctfId
)));
100 tree
.getTreeItem(ctfId
).getNode(TRACE_TYPE_NAME
).check();
101 batchImportClickNext();
104 private static void batchImportAddDirectory() {
105 UIThreadRunnable
.syncExec(new VoidResult() {
108 ((BatchImportTraceWizard
) fWizard
).addFileToScan(fTrace
.getPath());
111 final SWTBotButton removeButton
= fBot
.button("Remove");
112 fBot
.waitUntil(Conditions
.widgetIsEnabled(removeButton
));
113 removeButton
.click();
114 fBot
.waitUntil(Conditions
.tableHasRows(fBot
.table(), 1));
116 batchImportClickNext();
119 private static void batchImportSelectTrace() {
120 SWTBotTree tree
= fBot
.tree();
121 fBot
.waitUntil(Conditions
.widgetIsEnabled(tree
));
122 final SWTBotTreeItem genericCtfTreeItem
= tree
.getTreeItem(TRACE_TYPE_NAME
);
123 fBot
.waitUntil(Conditions
.widgetIsEnabled(genericCtfTreeItem
));
124 genericCtfTreeItem
.expand();
125 genericCtfTreeItem
.check();
126 batchImportClickNext();
129 private static void batchImportClickNext() {
130 IWizardPage currentPage
= fWizard
.getContainer().getCurrentPage();
131 IWizardPage desiredPage
= fWizard
.getNextPage(currentPage
);
132 SWTBotButton nextButton
= fBot
.button("Next >");
134 fBot
.waitUntil(ConditionHelpers
.isWizardOnPage(fWizard
, desiredPage
));
138 protected String
getProjectName() {
139 return TRACE_PROJECT_NAME
;
143 protected boolean supportsFolderStructure() {