ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests / src / org / eclipse / linuxtools / tmf / ctf / ui / swtbot / tests / ImportAndReadSmokeTest.java
CommitLineData
4b451cbe 1/*******************************************************************************
2f7b3dd7 2 * Copyright (c) 2013, 2014 Ericsson
4b451cbe
MK
3 *
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 *
9 * Contributors:
10 * Matthew Khouzam - Initial API and implementation
11 * Marc-Andre Laperle
2f7b3dd7 12 * Bernd Hufmann - Extracted functionality to class AbstractImportAndReadSmokeTest
4b451cbe
MK
13 *******************************************************************************/
14
91e7f946 15package org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests;
4b451cbe
MK
16
17import static org.junit.Assert.assertNotNull;
4b451cbe 18
9b3f4afe 19import org.eclipse.core.runtime.Path;
4b451cbe
MK
20import org.eclipse.jface.viewers.StructuredSelection;
21import org.eclipse.jface.wizard.IWizardPage;
4b451cbe 22import org.eclipse.jface.wizard.WizardDialog;
1de10308 23import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.importtrace.BatchImportTraceWizard;
4b451cbe 24import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor;
93c91230 25import org.eclipse.linuxtools.tmf.ui.swtbot.tests.SWTBotUtil;
4b451cbe 26import org.eclipse.linuxtools.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
4b451cbe 27import org.eclipse.swt.widgets.Shell;
4b451cbe 28import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
cbbd323f 29import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
4b451cbe 30import org.eclipse.swtbot.swt.finder.results.VoidResult;
4b451cbe
MK
31import org.eclipse.swtbot.swt.finder.waits.Conditions;
32import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
4b451cbe
MK
33import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
34import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
4b451cbe
MK
35import org.eclipse.ui.IWorkbench;
36import org.eclipse.ui.IWorkbenchWindow;
37import org.eclipse.ui.PlatformUI;
4b451cbe 38import org.junit.Test;
cbbd323f 39import org.junit.runner.RunWith;
4b451cbe
MK
40
41/**
42 * SWTBot Smoke test. base for other tests
43 *
44 * @author Matthew Khouzam
45 */
cbbd323f 46@RunWith(SWTBotJunit4ClassRunner.class)
2f7b3dd7 47public class ImportAndReadSmokeTest extends AbstractImportAndReadSmokeTest {
306e18d0 48
4b451cbe 49 private static final String TRACE_PROJECT_NAME = "test";
4b451cbe
MK
50
51 /**
52 * Main test case
53 */
54 @Test
55 public void test() {
56 createProject();
57
58 batchImportOpenWizard();
59 batchImportSelecTraceType();
60 batchImportAddDirectory();
61 batchImportSelectTrace();
2f7b3dd7 62 importFinish();
4b451cbe 63
9b3f4afe 64 TmfEventsEditor tmfEd = openEditor(new Path(TRACE_NAME));
4b451cbe
MK
65
66 testHistogramView(getViewPart("Histogram"), tmfEd);
67 testPropertyView(getViewPart("Properties"));
68 testStatisticsView(getViewPart("Statistics"));
93c91230 69 fBot.closeAllEditors();
4b451cbe 70
93c91230 71 SWTBotUtil.deleteProject(getProjectName(), fBot);
4b451cbe
MK
72 }
73
4b451cbe
MK
74 private static void batchImportOpenWizard() {
75 fWizard = new BatchImportTraceWizard();
76
77 UIThreadRunnable.asyncExec(new VoidResult() {
78 @Override
79 public void run() {
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();
85 assertNotNull(shell);
86 ((BatchImportTraceWizard) fWizard).init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
87 WizardDialog dialog = new WizardDialog(shell, fWizard);
88 dialog.open();
89 }
90 }
91 });
92
93 fBot.waitUntil(ConditionHelpers.isWizardReady(fWizard));
94 }
95
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();
103 }
104
105 private static void batchImportAddDirectory() {
106 UIThreadRunnable.syncExec(new VoidResult() {
107 @Override
108 public void run() {
109 ((BatchImportTraceWizard) fWizard).addFileToScan(fTrace.getPath());
110 }
111 });
112 final SWTBotButton removeButton = fBot.button("Remove");
113 fBot.waitUntil(Conditions.widgetIsEnabled(removeButton));
114 removeButton.click();
115 fBot.waitUntil(Conditions.tableHasRows(fBot.table(), 1));
116
117 batchImportClickNext();
118 }
119
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();
128 }
129
130 private static void batchImportClickNext() {
131 IWizardPage currentPage = fWizard.getContainer().getCurrentPage();
132 IWizardPage desiredPage = fWizard.getNextPage(currentPage);
133 SWTBotButton nextButton = fBot.button("Next >");
134 nextButton.click();
135 fBot.waitUntil(ConditionHelpers.isWizardOnPage(fWizard, desiredPage));
136 }
137
2f7b3dd7
BH
138 @Override
139 protected String getProjectName() {
140 return TRACE_PROJECT_NAME;
4b451cbe 141 }
4b451cbe 142}
This page took 0.040601 seconds and 5 git commands to generate.