Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Hufmann2014-05-08 13:31:28 -0400
committerBernd Hufmann2014-05-12 07:10:47 -0400
commit2773a5db6028c9be788b8f93b54d7c3a2b8a8395 (patch)
treed255ee6cda970b5633b7edb6cd0fcbce521e0b40
parent9f6d636657cd6aeb92ca1e6c92dcb1591bec4d79 (diff)
downloadorg.eclipse.linuxtools-2773a5db6028c9be788b8f93b54d7c3a2b8a8395.tar.gz
org.eclipse.linuxtools-2773a5db6028c9be788b8f93b54d7c3a2b8a8395.tar.xz
org.eclipse.linuxtools-2773a5db6028c9be788b8f93b54d7c3a2b8a8395.zip
tmf: Add initial SWTBot test for ImportTraceWizard
Change-Id: If533ffb1fcd9d7df865480f0e1c679ea3b4afa80 Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com> Reviewed-on: https://git.eclipse.org/r/26230 Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Hudson CI Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com> Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java350
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/AllTests.java5
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/ImportAndReadSmokeTest.java265
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/StandardImportAndReadSmokeTest.java109
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardPage.java11
5 files changed, 478 insertions, 262 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java b/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java
new file mode 100644
index 0000000000..a9c6054186
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java
@@ -0,0 +1,350 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ * (Extracted from ImportAndReadSmokeTest.java)
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.varia.NullAppender;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfEvent;
+import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
+import org.eclipse.linuxtools.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
+import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor;
+import org.eclipse.linuxtools.tmf.ui.swtbot.tests.SWTBotUtil;
+import org.eclipse.linuxtools.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
+import org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramView;
+import org.eclipse.linuxtools.tmf.ui.views.statistics.TmfStatisticsView;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.PropertySheet;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+/**
+ * Abstract SWTBot Smoke test class.
+ *
+ * @author Matthew Khouzam
+ * @author Bernd Hufmann
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public abstract class AbstractImportAndReadSmokeTest {
+
+ /** Trace name */
+ protected static final String TRACE_NAME = "synthetic-trace";
+ /** Trace type name for generic CTF traces */
+ protected static final String TRACE_TYPE_NAME = "Generic CTF Trace";
+ /** A Generic CTF Trace*/
+ protected static final CtfTmfTestTrace fTrace = CtfTmfTestTrace.SYNTHETIC_TRACE;
+ /** SWT BOT workbench reference */
+ protected static SWTWorkbenchBot fBot;
+ /** Wizard to use */
+ protected static Wizard fWizard;
+
+ /** The Log4j logger instance. */
+ protected static final Logger fLogger = Logger.getRootLogger();
+
+ /** Test Class setup */
+ @BeforeClass
+ public static void init() {
+ SWTBotUtil.failIfUIThread();
+
+ /* set up for swtbot */
+ SWTBotPreferences.TIMEOUT = 50000; /* 50 second timeout */
+ fLogger.addAppender(new NullAppender());
+ fBot = new SWTWorkbenchBot();
+
+ SWTBotUtil.closeView("welcome", fBot);
+
+ SWTBotUtil.switchToTracingPerspective();
+ /* finish waiting for eclipse to load */
+ SWTBotUtil.waitForJobs();
+ }
+
+ /**
+ * Creates a tracing projects
+ */
+ protected void createProject() {
+ SWTBotUtil.focusMainWindow(fBot.shells());
+ fBot.menu("File").menu("New").menu("Project...").click();
+
+ fBot.waitUntil(Conditions.shellIsActive("New Project"));
+ SWTBotTree tree = fBot.tree();
+ assertNotNull(tree);
+ final String tracingKey = "Tracing";
+ fBot.waitUntil(ConditionHelpers.IsTreeNodeAvailable(tracingKey, tree));
+ final SWTBotTreeItem tracingNode = tree.expandNode(tracingKey);
+
+ tracingNode.select();
+ final String projectKey = "Tracing Project";
+ fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(projectKey, tracingNode));
+ final SWTBotTreeItem tracingProject = tracingNode.getNode(projectKey);
+ assertNotNull(tracingProject);
+
+ tracingProject.select();
+ tracingProject.click();
+
+ SWTBotButton nextButton = fBot.button("Next >");
+ fBot.waitUntil(Conditions.widgetIsEnabled(nextButton));
+ nextButton.click();
+ fBot.waitUntil(Conditions.shellIsActive("Tracing Project"));
+
+ final SWTBotText text = fBot.text();
+ text.setText(getProjectName());
+
+ fBot.button("Finish").click();
+ SWTBotUtil.waitForJobs();
+ }
+
+ /**
+ * Opens and get the TmfEventsEditor
+ * @return TmfEventsEditor
+ */
+ protected TmfEventsEditor openEditor() {
+ final SWTBotView projectExplorerBot = fBot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
+ projectExplorerBot.setFocus();
+
+ final SWTBotTree tree = fBot.tree();
+ final SWTBotTreeItem treeItem = tree.getTreeItem(getProjectName());
+ treeItem.expand();
+
+ List<String> nodes = treeItem.getNodes();
+ String nodeName = "";
+ for (String node : nodes) {
+ if (node.startsWith("Traces")) {
+ nodeName = node;
+ }
+ }
+ fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(nodeName, treeItem));
+ treeItem.getNode(nodeName).expand();
+ fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(TRACE_NAME, treeItem.getNode(nodeName)));
+ treeItem.getNode(nodeName).getNode(TRACE_NAME).select();
+ treeItem.getNode(nodeName).getNode(TRACE_NAME).doubleClick();
+ SWTBotUtil.delay(1000);
+ SWTBotUtil.waitForJobs();
+
+ final IEditorPart iep[] = new IEditorPart[1];
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ IEditorReference[] ieds = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
+ assertNotNull(ieds);
+ iep[0] = null;
+ for (IEditorReference ied : ieds) {
+ if (ied.getTitle().equals(TRACE_NAME)) {
+ iep[0] = ied.getEditor(true);
+ break;
+ }
+ }
+ }
+ });
+ assertNotNull(iep[0]);
+ return (TmfEventsEditor) iep[0];
+ }
+
+ /**
+ * Deletes the tracing project
+ */
+ protected void deleteProject() {
+ // Wait for any analysis to complete because it might create supplementary files
+ SWTBotUtil.waitForJobs();
+ try {
+ ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName()).refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ }
+
+ SWTBotUtil.waitForJobs();
+
+ final SWTBotView projectViewBot = fBot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
+ projectViewBot.setFocus();
+
+ SWTBotTree treeBot = fBot.tree();
+ SWTBotTreeItem treeItem = treeBot.getTreeItem(getProjectName());
+ SWTBotMenu contextMenu = treeItem.contextMenu("Delete");
+ contextMenu.click();
+
+ String shellText = "Delete Resources";
+ fBot.waitUntil(Conditions.shellIsActive(shellText));
+ final SWTBotButton okButton = fBot.button("OK");
+ fBot.waitUntil(Conditions.widgetIsEnabled(okButton));
+ okButton.click();
+
+ SWTBotUtil.waitForJobs();
+ }
+
+ /**
+ * Finishes the wizard
+ */
+ protected void importFinish() {
+ SWTBotShell shell = fBot.activeShell();
+ final SWTBotButton finishButton = fBot.button("Finish");
+ finishButton.click();
+ fBot.waitUntil(Conditions.shellCloses(shell));
+ SWTBotUtil.waitForJobs();
+ }
+
+ /**
+ * Gets the project Name
+ * @return the project name
+ */
+ protected abstract String getProjectName();
+
+ // ---------------------------------------------
+ // Helpers for testing views
+ // ---------------------------------------------
+
+ /**
+ * Verifies the properties view for a given view part
+ *
+ * @param vp
+ * a view part
+ */
+ protected void testPropertyView(IViewPart vp) {
+ PropertySheet pv = (PropertySheet) vp;
+ assertNotNull(pv);
+ }
+
+ /**
+ * Verifies the Histogram View
+ * @param vp
+ * the view part
+ * @param tmfEd
+ * the events editor
+ */
+ protected void testHistogramView(IViewPart vp, final TmfEventsEditor tmfEd) {
+ final CtfTmfEvent desiredEvent1 = getEvent(100);
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ tmfEd.setFocus();
+ tmfEd.selectionChanged(new SelectionChangedEvent(tmfEd, new StructuredSelection(desiredEvent1)));
+ }
+ });
+
+ SWTBotUtil.waitForJobs();
+ SWTBotUtil.delay(1000);
+
+ final CtfTmfEvent desiredEvent2 = getEvent(10000);
+ SWTBotView hvBot = fBot.viewById(HistogramView.ID);
+ List<SWTBotToolbarButton> hvTools = hvBot.getToolbarButtons();
+ for (SWTBotToolbarButton hvTool : hvTools) {
+ if (hvTool.getToolTipText().toLowerCase().contains("lost")) {
+ hvTool.click();
+ }
+ }
+ HistogramView hv = (HistogramView) vp;
+ final TmfTimeSynchSignal signal = new TmfTimeSynchSignal(hv, desiredEvent1.getTimestamp());
+ final TmfTimeSynchSignal signal2 = new TmfTimeSynchSignal(hv, desiredEvent2.getTimestamp());
+ hv.updateTimeRange(100000);
+ SWTBotUtil.waitForJobs();
+ hv.currentTimeUpdated(signal);
+ hv.broadcast(signal);
+ SWTBotUtil.waitForJobs();
+ SWTBotUtil.delay(1000);
+
+ hv.updateTimeRange(1000000000);
+ SWTBotUtil.waitForJobs();
+ hv.currentTimeUpdated(signal2);
+ hv.broadcast(signal2);
+ SWTBotUtil.waitForJobs();
+ SWTBotUtil.delay(1000);
+ assertNotNull(hv);
+ }
+
+ /**
+ * Verifies the statistics view
+ * @param vp
+ * the view part
+ */
+ protected void testStatisticsView(IViewPart vp) {
+ TmfStatisticsView sv = (TmfStatisticsView) vp;
+ assertNotNull(sv);
+ }
+
+ // ---------------------------------------------
+ // Trace helpers
+ // ---------------------------------------------
+
+ /**
+ * Gets an event at a given rank
+ * @param rank
+ * a rank
+ * @return the event at given rank
+ */
+ protected CtfTmfEvent getEvent(int rank) {
+ CtfTmfTrace trace = fTrace.getTrace();
+ if (trace == null) {
+ return null;
+ }
+ ITmfContext ctx = trace.seekEvent(0);
+ for (int i = 0; i < rank; i++) {
+ trace.getNext(ctx);
+ }
+ final CtfTmfEvent retVal = trace.getNext(ctx);
+ trace.dispose();
+ return retVal;
+ }
+
+ /**
+ * Gets a view part based on view title
+ * @param viewTile
+ * a view title
+ * @return the view part
+ */
+ protected IViewPart getViewPart(final String viewTile) {
+ final IViewPart[] vps = new IViewPart[1];
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ IViewReference[] viewRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
+ for (IViewReference viewRef : viewRefs) {
+ IViewPart vp = viewRef.getView(true);
+ if (vp.getTitle().equals(viewTile)) {
+ vps[0] = vp;
+ return;
+ }
+ }
+ }
+ });
+
+ return vps[0];
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/AllTests.java
index ef1c31e16e..bb3df9e919 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/AllTests.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Ericsson
+ * Copyright (c) 2013, 2014 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -22,7 +22,8 @@ import org.junit.runners.Suite;
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- ImportAndReadSmokeTest.class
+ ImportAndReadSmokeTest.class,
+ StandardImportAndReadSmokeTest.class
})
public class AllTests {
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/ImportAndReadSmokeTest.java b/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/ImportAndReadSmokeTest.java
index 41bdcc972a..9607d9c582 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/ImportAndReadSmokeTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/ImportAndReadSmokeTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Ericsson
+ * Copyright (c) 2013, 2014 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -9,60 +9,30 @@
* Contributors:
* Matthew Khouzam - Initial API and implementation
* Marc-Andre Laperle
+ * Bernd Hufmann - Extracted functionality to class AbstractImportAndReadSmokeTest
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests;
import static org.junit.Assert.assertNotNull;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.varia.NullAppender;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfEvent;
-import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor;
import org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace.BatchImportTraceWizard;
-import org.eclipse.linuxtools.tmf.ui.swtbot.tests.SWTBotUtil;
import org.eclipse.linuxtools.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
-import org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramView;
-import org.eclipse.linuxtools.tmf.ui.views.statistics.TmfStatisticsView;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.properties.PropertySheet;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -72,36 +42,9 @@ import org.junit.runner.RunWith;
* @author Matthew Khouzam
*/
@RunWith(SWTBotJunit4ClassRunner.class)
-public class ImportAndReadSmokeTest {
-
+public class ImportAndReadSmokeTest extends AbstractImportAndReadSmokeTest {
private static final String TRACE_PROJECT_NAME = "test";
- private static final String TRACE_NAME = "synthetic-trace";
- private static final String TRACE_TYPE_NAME = "Generic CTF Trace";
- private static final CtfTmfTestTrace fTrace = CtfTmfTestTrace.SYNTHETIC_TRACE;
-
- private static SWTWorkbenchBot fBot;
- private static Wizard fWizard;
-
- /** The Log4j logger instance. */
- private static final Logger fLogger = Logger.getRootLogger();
-
- /** Test Class setup */
- @BeforeClass
- public static void init() {
- SWTBotUtil.failIfUIThread();
-
- /* set up for swtbot */
- SWTBotPreferences.TIMEOUT = 50000; /* 50 second timeout */
- fLogger.addAppender(new NullAppender());
- fBot = new SWTWorkbenchBot();
-
- SWTBotUtil.closeView("welcome", fBot);
-
- SWTBotUtil.switchToTracingPerspective();
- /* finish waiting for eclipse to load */
- SWTBotUtil.waitForJobs();
- }
/**
* Main test case
@@ -114,7 +57,7 @@ public class ImportAndReadSmokeTest {
batchImportSelecTraceType();
batchImportAddDirectory();
batchImportSelectTrace();
- batchImportFinish();
+ importFinish();
TmfEventsEditor tmfEd = openEditor();
@@ -125,38 +68,6 @@ public class ImportAndReadSmokeTest {
deleteProject();
}
- private static void createProject() {
- SWTBotUtil.focusMainWindow(fBot.shells());
- fBot.menu("File").menu("New").menu("Project...").click();
-
- fBot.waitUntil(Conditions.shellIsActive("New Project"));
- SWTBotTree tree = fBot.tree();
- assertNotNull(tree);
- final String tracingKey = "Tracing";
- fBot.waitUntil(ConditionHelpers.IsTreeNodeAvailable(tracingKey, tree));
- final SWTBotTreeItem tracingNode = tree.expandNode(tracingKey);
-
- tracingNode.select();
- final String projectKey = "Tracing Project";
- fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(projectKey, tracingNode));
- final SWTBotTreeItem tracingProject = tracingNode.getNode(projectKey);
- assertNotNull(tracingProject);
-
- tracingProject.select();
- tracingProject.click();
-
- SWTBotButton nextButton = fBot.button("Next >");
- fBot.waitUntil(Conditions.widgetIsEnabled(nextButton));
- nextButton.click();
- fBot.waitUntil(Conditions.shellIsActive("Tracing Project"));
-
- final SWTBotText text = fBot.text();
- text.setText(TRACE_PROJECT_NAME);
-
- fBot.button("Finish").click();
- SWTBotUtil.waitForJobs();
- }
-
private static void batchImportOpenWizard() {
fWizard = new BatchImportTraceWizard();
@@ -221,171 +132,9 @@ public class ImportAndReadSmokeTest {
fBot.waitUntil(ConditionHelpers.isWizardOnPage(fWizard, desiredPage));
}
- private static void batchImportFinish() {
- SWTBotShell shell = fBot.activeShell();
- final SWTBotButton finishButton = fBot.button("Finish");
- finishButton.click();
- fBot.waitUntil(Conditions.shellCloses(shell));
- SWTBotUtil.waitForJobs();
+ @Override
+ protected String getProjectName() {
+ return TRACE_PROJECT_NAME;
}
- private static TmfEventsEditor openEditor() {
- final SWTBotView projectExplorerBot = fBot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
- projectExplorerBot.setFocus();
-
- final SWTBotTree tree = fBot.tree();
- final SWTBotTreeItem treeItem = tree.getTreeItem(TRACE_PROJECT_NAME);
- treeItem.expand();
-
- List<String> nodes = treeItem.getNodes();
- String nodeName = "";
- for (String node : nodes) {
- if (node.startsWith("Traces")) {
- nodeName = node;
- }
- }
- fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(nodeName, treeItem));
- treeItem.getNode(nodeName).expand();
- fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(TRACE_NAME, treeItem.getNode(nodeName)));
- treeItem.getNode(nodeName).getNode(TRACE_NAME).select();
- treeItem.getNode(nodeName).getNode(TRACE_NAME).doubleClick();
- SWTBotUtil.delay(1000);
- SWTBotUtil.waitForJobs();
-
- final IEditorPart iep[] = new IEditorPart[1];
- UIThreadRunnable.syncExec(new VoidResult() {
- @Override
- public void run() {
- IEditorReference[] ieds = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
- assertNotNull(ieds);
- iep[0] = null;
- for (IEditorReference ied : ieds) {
- if (ied.getTitle().equals(TRACE_NAME)) {
- iep[0] = ied.getEditor(true);
- break;
- }
- }
- }
- });
- assertNotNull(iep[0]);
- return (TmfEventsEditor) iep[0];
- }
-
- private static void deleteProject() {
- // Wait for any analysis to complete because it might create supplementary files
- SWTBotUtil.waitForJobs();
- try {
- ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME).refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- }
-
- SWTBotUtil.waitForJobs();
-
- final SWTBotView projectViewBot = fBot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
- projectViewBot.setFocus();
-
- SWTBotTree treeBot = fBot.tree();
- SWTBotTreeItem treeItem = treeBot.getTreeItem(TRACE_PROJECT_NAME);
- SWTBotMenu contextMenu = treeItem.contextMenu("Delete");
- contextMenu.click();
-
- String shellText = "Delete Resources";
- fBot.waitUntil(Conditions.shellIsActive(shellText));
- final SWTBotButton okButton = fBot.button("OK");
- fBot.waitUntil(Conditions.widgetIsEnabled(okButton));
- okButton.click();
-
- SWTBotUtil.waitForJobs();
- }
-
- // ---------------------------------------------
- // Helpers for testing views
- // ---------------------------------------------
-
- private static void testPropertyView(IViewPart vp) {
- PropertySheet pv = (PropertySheet) vp;
- assertNotNull(pv);
- }
-
- private static void testHistogramView(IViewPart vp, final TmfEventsEditor tmfEd) {
- final CtfTmfEvent desiredEvent1 = getEvent(100);
- UIThreadRunnable.syncExec(new VoidResult() {
- @Override
- public void run() {
- tmfEd.setFocus();
- tmfEd.selectionChanged(new SelectionChangedEvent(tmfEd, new StructuredSelection(desiredEvent1)));
- }
- });
-
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
-
- final CtfTmfEvent desiredEvent2 = getEvent(10000);
- SWTBotView hvBot = fBot.viewById(HistogramView.ID);
- List<SWTBotToolbarButton> hvTools = hvBot.getToolbarButtons();
- for (SWTBotToolbarButton hvTool : hvTools) {
- if (hvTool.getToolTipText().toLowerCase().contains("lost")) {
- hvTool.click();
- }
- }
- HistogramView hv = (HistogramView) vp;
- final TmfTimeSynchSignal signal = new TmfTimeSynchSignal(hv, desiredEvent1.getTimestamp());
- final TmfTimeSynchSignal signal2 = new TmfTimeSynchSignal(hv, desiredEvent2.getTimestamp());
- hv.updateTimeRange(100000);
- SWTBotUtil.waitForJobs();
- hv.currentTimeUpdated(signal);
- hv.broadcast(signal);
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
-
- hv.updateTimeRange(1000000000);
- SWTBotUtil.waitForJobs();
- hv.currentTimeUpdated(signal2);
- hv.broadcast(signal2);
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
- assertNotNull(hv);
- }
-
- private static void testStatisticsView(IViewPart vp) {
- TmfStatisticsView sv = (TmfStatisticsView) vp;
- assertNotNull(sv);
- }
-
- // ---------------------------------------------
- // Trace helpers
- // ---------------------------------------------
-
- private static CtfTmfEvent getEvent(int rank) {
- CtfTmfTrace trace = fTrace.getTrace();
- if (trace == null) {
- return null;
- }
- ITmfContext ctx = trace.seekEvent(0);
- for (int i = 0; i < rank; i++) {
- trace.getNext(ctx);
- }
- final CtfTmfEvent retVal = trace.getNext(ctx);
- trace.dispose();
- return retVal;
- }
-
- private static IViewPart getViewPart(final String viewTile) {
- final IViewPart[] vps = new IViewPart[1];
- UIThreadRunnable.syncExec(new VoidResult() {
- @Override
- public void run() {
- IViewReference[] viewRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
- for (IViewReference viewRef : viewRefs) {
- IViewPart vp = viewRef.getView(true);
- if (vp.getTitle().equals(viewTile)) {
- vps[0] = vp;
- return;
- }
- }
- }
- });
-
- return vps[0];
- }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/StandardImportAndReadSmokeTest.java b/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/StandardImportAndReadSmokeTest.java
new file mode 100644
index 0000000000..9a98d72c9c
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests/src/org/eclipse/linuxtools/tmf/ctf/ui/swtbot/tests/StandardImportAndReadSmokeTest.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ctf.ui.swtbot.tests;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor;
+import org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace.ImportTraceWizard;
+import org.eclipse.linuxtools.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * SWTBot Smoke test using ImportTraceWizard.
+ *
+ * @author Bernd Hufmann
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTest {
+
+ private static final String TRACE_PROJECT_NAME = "Tracing";
+
+ /**
+ * Main test case
+ */
+ @Test
+ public void test() {
+ createProject();
+
+ importOpenWizard();
+ importAddDirectory();
+ importFinish();
+
+ TmfEventsEditor tmfEd = openEditor();
+
+ testHistogramView(getViewPart("Histogram"), tmfEd);
+ testPropertyView(getViewPart("Properties"));
+ testStatisticsView(getViewPart("Statistics"));
+
+ deleteProject();
+ }
+
+ private static void importOpenWizard() {
+ fWizard = new ImportTraceWizard();
+
+ UIThreadRunnable.asyncExec(new VoidResult() {
+ @Override
+ public void run() {
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ // Fire the Import Trace Wizard
+ if (workbench != null) {
+ final IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
+ Shell shell = activeWorkbenchWindow.getShell();
+ assertNotNull(shell);
+ ((ImportTraceWizard) fWizard).init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
+ WizardDialog dialog = new WizardDialog(shell, fWizard);
+ dialog.open();
+ }
+ }
+ });
+
+ fBot.waitUntil(ConditionHelpers.isWizardReady(fWizard));
+ }
+
+ private static void importAddDirectory() {
+ SWTBotCombo sourceCombo = fBot.comboBox();
+ sourceCombo.setText(fTrace.getPath());
+
+ SWTBotText text = fBot.text();
+ text.setFocus();
+
+ fBot.activeShell();
+ SWTBotTree tree = fBot.tree();
+ fBot.waitUntil(Conditions.widgetIsEnabled(tree));
+ final SWTBotTreeItem genericCtfTreeItem = tree.getTreeItem(TRACE_NAME);
+ fBot.waitUntil(Conditions.widgetIsEnabled(genericCtfTreeItem));
+ genericCtfTreeItem.check();
+ }
+
+ @Override
+ protected String getProjectName() {
+ return TRACE_PROJECT_NAME;
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardPage.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardPage.java
index 1d00000ab6..18f643c7df 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardPage.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardPage.java
@@ -73,6 +73,8 @@ import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
@@ -352,8 +354,6 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
directoryNameField.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
- // If there has been a key pressed then mark as dirty
- entryChanged = true;
if (e.character == SWT.CR) { // Windows...
entryChanged = false;
updateFromSourceField();
@@ -380,6 +380,13 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
}
});
+ directoryNameField.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ entryChanged = true;
+ }
+ });
+
// Browse button
directoryBrowseButton = new Button(directoryContainerGroup, SWT.PUSH);
directoryBrowseButton.setText(Messages.ImportTraceWizard_BrowseButton);

Back to the top