1 /*******************************************************************************
2 * Copyright (c) 2013, 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
10 * Matthew Khouzam - Initial API and implementation
12 * Bernd Hufmann - Extracted functionality to class AbstractImportAndReadSmokeTest
13 *******************************************************************************/
15 package org
.eclipse
.tracecompass
.tmf
.ctf
.ui
.swtbot
.tests
;
17 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
.IWizardPage
;
22 import org
.eclipse
.jface
.wizard
.WizardDialog
;
23 import org
.eclipse
.swt
.widgets
.Shell
;
24 import org
.eclipse
.swtbot
.swt
.finder
.finders
.UIThreadRunnable
;
25 import org
.eclipse
.swtbot
.swt
.finder
.junit
.SWTBotJunit4ClassRunner
;
26 import org
.eclipse
.swtbot
.swt
.finder
.results
.VoidResult
;
27 import org
.eclipse
.swtbot
.swt
.finder
.waits
.Conditions
;
28 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotButton
;
29 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTree
;
30 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTreeItem
;
31 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
.BatchImportTraceWizard
;
32 import org
.eclipse
.tracecompass
.tmf
.ui
.editors
.TmfEventsEditor
;
33 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.ConditionHelpers
;
34 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.SWTBotUtils
;
35 import org
.eclipse
.ui
.IWorkbench
;
36 import org
.eclipse
.ui
.IWorkbenchWindow
;
37 import org
.eclipse
.ui
.PlatformUI
;
38 import org
.junit
.Test
;
39 import org
.junit
.runner
.RunWith
;
42 * SWTBot Smoke test. base for other tests
44 * @author Matthew Khouzam
46 @RunWith(SWTBotJunit4ClassRunner
.class)
47 public class ImportAndReadSmokeTest
extends AbstractImportAndReadSmokeTest
{
49 private static final String TRACE_PROJECT_NAME
= "test";
58 batchImportOpenWizard();
59 batchImportSelecTraceType();
60 batchImportAddDirectory();
61 batchImportSelectTrace();
64 TmfEventsEditor tmfEd
= SWTBotUtils
.openEditor(fBot
, getProjectName(), new Path(TRACE_NAME
));
66 testHistogramView(getViewPart("Histogram"), tmfEd
);
67 testPropertyView(getViewPart("Properties"));
68 testStatisticsView(getViewPart("Statistics"));
69 fBot
.closeAllEditors();
71 SWTBotUtils
.deleteProject(getProjectName(), fBot
);
74 private static void batchImportOpenWizard() {
75 fWizard
= new BatchImportTraceWizard();
77 UIThreadRunnable
.asyncExec(new VoidResult() {
80 final IWorkbench workbench
= PlatformUI
.getWorkbench();
81 // Fire the Import Trace Wizard
82 if (workbench
!= null) {
83 final IWorkbenchWindow activeWorkbenchWindow
= workbench
.getActiveWorkbenchWindow();
84 Shell shell
= activeWorkbenchWindow
.getShell();
86 ((BatchImportTraceWizard
) fWizard
).init(PlatformUI
.getWorkbench(), StructuredSelection
.EMPTY
);
87 WizardDialog dialog
= new WizardDialog(shell
, fWizard
);
93 fBot
.waitUntil(ConditionHelpers
.isWizardReady(fWizard
));
96 private static void batchImportSelecTraceType() {
97 final SWTBotTree tree
= fBot
.tree();
98 final String ctfId
= "Common Trace Format";
99 fBot
.waitUntil(ConditionHelpers
.IsTreeNodeAvailable(ctfId
, tree
));
100 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(TRACE_TYPE_NAME
, tree
.getTreeItem(ctfId
)));
101 tree
.getTreeItem(ctfId
).getNode(TRACE_TYPE_NAME
).check();
102 batchImportClickNext();
105 private static void batchImportAddDirectory() {
106 UIThreadRunnable
.syncExec(new VoidResult() {
109 ((BatchImportTraceWizard
) fWizard
).addFileToScan(fTrace
.getPath());
112 final SWTBotButton removeButton
= fBot
.button("Remove");
113 fBot
.waitUntil(Conditions
.widgetIsEnabled(removeButton
));
114 removeButton
.click();
115 fBot
.waitUntil(Conditions
.tableHasRows(fBot
.table(), 1));
117 batchImportClickNext();
120 private static void batchImportSelectTrace() {
121 SWTBotTree tree
= fBot
.tree();
122 fBot
.waitUntil(Conditions
.widgetIsEnabled(tree
));
123 final SWTBotTreeItem genericCtfTreeItem
= tree
.getTreeItem(TRACE_TYPE_NAME
);
124 fBot
.waitUntil(Conditions
.widgetIsEnabled(genericCtfTreeItem
));
125 genericCtfTreeItem
.expand();
126 genericCtfTreeItem
.check();
127 batchImportClickNext();
130 private static void batchImportClickNext() {
131 IWizardPage currentPage
= fWizard
.getContainer().getCurrentPage();
132 IWizardPage desiredPage
= fWizard
.getNextPage(currentPage
);
133 SWTBotButton nextButton
= fBot
.button("Next >");
135 fBot
.waitUntil(ConditionHelpers
.isWizardOnPage(fWizard
, desiredPage
));
139 protected String
getProjectName() {
140 return TRACE_PROJECT_NAME
;