import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.SWTBotUtil;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
import org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramView;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
*/
@BeforeClass
public static void init() {
- SWTBotUtil.failIfUIThread();
+ SWTBotUtils.failIfUIThread();
/* set up for swtbot */
SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
/* Switch perspectives */
switchKernelPerspective();
/* Finish waiting for eclipse to load */
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
}
private static void switchKernelPerspective() {
*/
@Test
public void test() {
- SWTBotUtil.createProject(TRACE_PROJECT_NAME);
- SWTBotUtil.openTrace(TRACE_PROJECT_NAME, CTT.getPath(), TRACE_TYPE);
+ SWTBotUtils.createProject(TRACE_PROJECT_NAME);
+ SWTBotUtils.openTrace(TRACE_PROJECT_NAME, CTT.getPath(), TRACE_TYPE);
openEditor();
testHV(getViewPart("Histogram"));
testCFV((ControlFlowView) getViewPart("Control Flow"));
testRV((ResourcesView) getViewPart("Resources"));
fBot.closeAllEditors();
- SWTBotUtil.deleteProject(TRACE_PROJECT_NAME, fBot);
+ SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
}
private void openEditor() {
}
});
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
+ SWTBotUtils.waitForJobs();
+ SWTBotUtils.delay(1000);
assertNotNull(tmfEd);
}
final TmfTimeSynchSignal signal = new TmfTimeSynchSignal(hv, fDesired1.getTimestamp());
final TmfTimeSynchSignal signal2 = new TmfTimeSynchSignal(hv, fDesired2.getTimestamp());
hv.updateTimeRange(100000);
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
hv.currentTimeUpdated(signal);
hv.broadcast(signal);
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
+ SWTBotUtils.waitForJobs();
+ SWTBotUtils.delay(1000);
hv.updateTimeRange(1000000000);
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
hv.currentTimeUpdated(signal2);
hv.broadcast(signal2);
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
+ SWTBotUtils.waitForJobs();
+ SWTBotUtils.delay(1000);
assertNotNull(hv);
}
import org.eclipse.tracecompass.analysis.os.linux.ui.views.controlflow.ControlFlowView;
import org.eclipse.tracecompass.analysis.os.linux.ui.views.resources.ResourcesView;
-import org.eclipse.tracecompass.internal.lttng2.kernel.ui.views.PerspectiveFactory;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.AbstractPerspectiveChecker;
+import org.eclipse.tracecompass.internal.lttng2.kernel.ui.views.PerspectiveFactory;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.AbstractPerspectiveChecker;
import org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramView;
import org.eclipse.tracecompass.tmf.ui.views.statistics.TmfStatisticsView;
import org.eclipse.ui.IPageLayout;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.tracecompass.tmf.core.analysis.Messages;
import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.SWTBotUtil;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
*/
@BeforeClass
public static void init() {
- SWTBotUtil.failIfUIThread();
+ SWTBotUtils.failIfUIThread();
/* Set up for swtbot */
SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
workbenchbot = new SWTWorkbenchBot();
/* Close welcome view */
- SWTBotUtil.closeView("Welcome", workbenchbot);
+ SWTBotUtils.closeView("Welcome", workbenchbot);
/* Switch perspectives */
- SWTBotUtil.switchToPerspective(KERNEL_PERSPECTIVE_ID);
+ SWTBotUtils.switchToPerspective(KERNEL_PERSPECTIVE_ID);
/* Finish waiting for eclipse to load */
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
}
/**
*/
@Test
public void testOpenAndCloseConcurrency() {
- SWTBotUtil.createProject(TRACE_PROJECT_NAME);
+ SWTBotUtils.createProject(TRACE_PROJECT_NAME);
File fTestFile = new File(CTF_TRACE.getPath());
};
mgr.addJobChangeListener(changeListener);
for (int i = 0; i < 10; i++) {
- SWTBotUtil.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false);
- SWTBotUtil.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false);
- SWTBotUtil.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false);
- SWTBotUtil.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false);
- SWTBotUtil.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false);
+ SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false);
+ SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false);
+ SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false);
+ SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false);
+ SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false);
// Add little delay so that treads have a chance to start
- SWTBotUtil.delay(1000);
+ SWTBotUtils.delay(1000);
workbenchbot.closeAllEditors();
if (!status.isOK()) {
- SWTBotUtil.deleteProject(TRACE_PROJECT_NAME, workbenchbot);
+ SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, workbenchbot);
fail(handleErrorStatus(status));
}
}
- SWTBotUtil.deleteProject(TRACE_PROJECT_NAME, workbenchbot);
+ SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, workbenchbot);
}
private static String handleErrorStatus(MultiStatus status) {
import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.SWTBotUtil;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
import org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramView;
import org.eclipse.tracecompass.tmf.ui.views.statistics.TmfStatisticsView;
import org.eclipse.ui.IViewPart;
@BeforeClass
public static void init() {
assumeTrue(fTrace.exists());
- SWTBotUtil.failIfUIThread();
+ SWTBotUtils.failIfUIThread();
/* set up for swtbot */
SWTBotPreferences.TIMEOUT = 50000; /* 50 second timeout */
fLogger.addAppender(new NullAppender());
fBot = new SWTWorkbenchBot();
- SWTBotUtil.closeView("welcome", fBot);
+ SWTBotUtils.closeView("welcome", fBot);
- SWTBotUtil.switchToTracingPerspective();
+ SWTBotUtils.switchToTracingPerspective();
/* finish waiting for eclipse to load */
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
}
/**
* Creates a tracing projects
*/
protected void createProject() {
- SWTBotUtil.focusMainWindow(fBot.shells());
+ SWTBotUtils.focusMainWindow(fBot.shells());
fBot.menu("File").menu("New").menu("Project...").click();
fBot.shell("New Project").setFocus();
text.setText(getProjectName());
fBot.button("Finish").click();
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
}
/**
final SWTBotButton finishButton = fBot.button("Finish");
finishButton.click();
fBot.waitUntil(Conditions.shellCloses(shell));
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
}
/**
}
});
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
+ SWTBotUtils.waitForJobs();
+ SWTBotUtils.delay(1000);
final CtfTmfEvent desiredEvent2 = getEvent(10000);
SWTBotView hvBot = fBot.viewById(HistogramView.ID);
final TmfTimeSynchSignal signal = new TmfTimeSynchSignal(hv, desiredEvent1.getTimestamp());
final TmfTimeSynchSignal signal2 = new TmfTimeSynchSignal(hv, desiredEvent2.getTimestamp());
hv.updateTimeRange(100000);
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
hv.currentTimeUpdated(signal);
hv.broadcast(signal);
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
+ SWTBotUtils.waitForJobs();
+ SWTBotUtils.delay(1000);
hv.updateTimeRange(1000000000);
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
hv.currentTimeUpdated(signal2);
hv.broadcast(signal2);
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
+ SWTBotUtils.waitForJobs();
+ SWTBotUtils.delay(1000);
assertNotNull(hv);
}
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.BatchImportTraceWizard;
import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.SWTBotUtil;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
batchImportSelectTrace();
importFinish();
- TmfEventsEditor tmfEd = SWTBotUtil.openEditor(fBot, getProjectName(), new Path(TRACE_NAME));
+ TmfEventsEditor tmfEd = SWTBotUtils.openEditor(fBot, getProjectName(), new Path(TRACE_NAME));
testHistogramView(getViewPart("Histogram"), tmfEd);
testPropertyView(getViewPart("Properties"));
testStatisticsView(getViewPart("Statistics"));
fBot.closeAllEditors();
- SWTBotUtil.deleteProject(getProjectName(), fBot);
+ SWTBotUtils.deleteProject(getProjectName(), fBot);
}
private static void batchImportOpenWizard() {
import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement;
import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder;
import org.eclipse.tracecompass.tmf.ui.project.model.TmfTracesFolder;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.SWTBotUtil;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
importFinish();
checkOptions(options);
- TmfEventsEditor tmfEd = SWTBotUtil.openEditor(fBot, getProjectName(), getTraceElementPath(options));
+ TmfEventsEditor tmfEd = SWTBotUtils.openEditor(fBot, getProjectName(), getTraceElementPath(options));
if (testViews) {
testViews(tmfEd);
}
fBot.closeAllEditors();
- SWTBotUtil.deleteProject(getProjectName(), fBot);
+ SWTBotUtils.deleteProject(getProjectName(), fBot);
}
private void testViews(TmfEventsEditor editor) {
import org.eclipse.tracecompass.tmf.ui.project.model.TmfOpenTraceHelper;
import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.SWTBotUtil;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IViewPart;
@BeforeClass
public static void init() {
- SWTBotUtil.failIfUIThread();
+ SWTBotUtils.failIfUIThread();
/* set up for swtbot */
SWTBotPreferences.TIMEOUT = 300000; /* 300 second timeout */
/* Switch perspectives */
switchNetworkPerspective();
/* Finish waiting for eclipse to load */
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
}
private static void switchNetworkPerspective() {
@Test
public void test() {
assumeTrue(pttt.exists());
- SWTBotUtil.createProject(TRACE_PROJECT_NAME);
+ SWTBotUtils.createProject(TRACE_PROJECT_NAME);
openTrace();
openEditor();
testHV(getViewPart("Histogram"));
testStreamView(getViewPartRef("Stream List"));
fBot.closeAllEditors();
- SWTBotUtil.deleteProject(TRACE_PROJECT_NAME, fBot);
+ SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
}
private void testStreamView(IViewReference viewPart) {
assertNotNull(botTree);
final TmfTimeSynchSignal signal = new TmfTimeSynchSignal(slv, fDesired1.getTimestamp());
slv.broadcast(signal);
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.waitForJobs();
// FIXME This is a race condition:
// TmfEventsTable launches an async exec that may be run after the wait
// for jobs. This last delay catches it.
- SWTBotUtil.delay(1000);
+ SWTBotUtils.delay(1000);
}
fail(exception[0].getMessage());
}
- SWTBotUtil.delay(1000);
- SWTBotUtil.waitForJobs();
+ SWTBotUtils.delay(1000);
+ SWTBotUtils.waitForJobs();
}
private void openEditor() {
}
});
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
+ SWTBotUtils.waitForJobs();
+ SWTBotUtils.delay(1000);
assertNotNull(tmfEd);
}
import org.eclipse.tracecompass.internal.tmf.pcap.ui.NetworkingPerspectiveFactory;
import org.eclipse.tracecompass.internal.tmf.pcap.ui.stream.StreamListView;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.AbstractPerspectiveChecker;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.AbstractPerspectiveChecker;
import org.eclipse.tracecompass.tmf.ui.views.colors.ColorsView;
import org.eclipse.tracecompass.tmf.ui.views.filter.FilterView;
import org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramView;
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="shared"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Bundle-SymbolicName: org.eclipse.tracecompass.tmf.ui.swtbot.tests;singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Export-Package: org.eclipse.tracecompass.tmf.ui.swtbot.tests,
- org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions
Require-Bundle: org.junit;bundle-version="4.0.0",
org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.swtbot.swt.finder.utils,
org.eclipse.swtbot.swt.finder.waits,
org.eclipse.swtbot.swt.finder.widgets
+Export-Package: org.eclipse.tracecompass.tmf.ui.swtbot.tests,
+ org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared
# Ericsson - Initial API and implementation
###############################################################################
-source.. = src/
+source.. = src/,\
+ shared/
output.. = bin/
bin.includes = META-INF/,\
.,\
--- /dev/null
+/*******************************************************************************
+ * 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:
+ * Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.varia.NullAppender;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.ui.IViewReference;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests perspectives to make sure they have all the views
+ *
+ * @author Matthew Khouzam
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public abstract class AbstractPerspectiveChecker {
+
+ private static SWTWorkbenchBot fBot;
+ /** The Log4j logger instance. */
+ private static final Logger fLogger = Logger.getRootLogger();
+
+ /**
+ * The perspective id
+ */
+ protected String fPerspectiveId;
+ /**
+ * the view id collection
+ */
+ protected Collection<String> fViewIds;
+
+ /** Test Class setup */
+ @BeforeClass
+ public static void beforeInit() {
+ SWTBotUtils.failIfUIThread();
+
+ /* set up for swtbot */
+ SWTBotPreferences.TIMEOUT = 50000; /* 50 second timeout */
+ fLogger.addAppender(new NullAppender());
+ fBot = new SWTWorkbenchBot();
+
+ SWTBotUtils.closeView("welcome", fBot);
+
+ }
+
+ /**
+ * Gets the perspective and checks if all the views specified in the list
+ * are present in the perspective
+ */
+ @Test
+ public void testPerspectiveForViews() {
+ SWTBotUtils.switchToPerspective(fPerspectiveId);
+ SWTBotUtils.waitForJobs();
+ for (final String viewID : fViewIds) {
+ List<SWTBotView> view = fBot.views(new BaseMatcher<String>() {
+
+ @Override
+ public boolean matches(Object item) {
+ if (!(item instanceof IViewReference)) {
+ return false;
+ }
+ IViewReference reference = (IViewReference) item;
+ return reference.getId().equals(viewID);
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ }
+
+ });
+ assertEquals("view " + viewID + "is present", 1, view.size());
+ }
+ }
+
+ /**
+ * Gets the perspective and checks if all the views of that perspective are
+ * in the list
+ */
+ @Test
+ public void testPerspectiveComplete() {
+ SWTBotUtils.switchToPerspective(fPerspectiveId);
+ SWTBotUtils.waitForJobs();
+ for (SWTBotView view : fBot.views()) {
+ assertTrue("view " + view.toString() + "is present", fViewIds.contains(view.getViewReference().getId()));
+ }
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ * Matthew Khouzam - Initial API and implementation
+ * Alexandre Montplaisir - Replaced separate Condition objects by anonymous classes
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared;
+
+
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+/**
+ * Is a tree node available
+ *
+ * @author Matthew Khouzam
+ */
+public final class ConditionHelpers {
+
+ private ConditionHelpers() {}
+
+ /**
+ * Provide default implementations for some {@link ICondition} methods.
+ */
+ private abstract static class SWTBotTestCondition implements ICondition {
+
+ @Override
+ public abstract boolean test() throws Exception;
+
+ @Override
+ public final void init(SWTBot bot) {
+ }
+
+ @Override
+ public final String getFailureMessage() {
+ return null;
+ }
+ }
+
+ /**
+ * Is a tree node available
+ *
+ * @param name
+ * the name of the node
+ * @param tree
+ * the parent tree
+ * @return true or false, it should swallow all exceptions
+ */
+ public static ICondition IsTreeNodeAvailable(final String name, final SWTBotTree tree) {
+ return new SWTBotTestCondition() {
+ @Override
+ public boolean test() throws Exception {
+ try {
+ final SWTBotTreeItem[] treeItems = tree.getAllItems();
+ for (SWTBotTreeItem ti : treeItems) {
+ final String text = ti.getText();
+ if (text.equals(name)) {
+ return true;
+ }
+ }
+ } catch (Exception e) {
+ }
+ return false;
+ }
+ };
+ }
+
+ /**
+ * Is the treeItem's node available
+ *
+ * @param name
+ * the name of the node
+ * @param treeItem
+ * the treeItem
+ * @return true or false, it should swallow all exceptions
+ */
+ public static ICondition IsTreeChildNodeAvailable(final String name, final SWTBotTreeItem treeItem) {
+ return new SWTBotTestCondition() {
+ @Override
+ public boolean test() throws Exception {
+ try {
+ return treeItem.getNode(name) != null;
+ } catch (Exception e) {
+ }
+ return false;
+ }
+ };
+ }
+
+ /**
+ * Checks if the wizard's shell is null
+ *
+ * @param wizard
+ * the null
+ * @return false if either are null
+ */
+ public static ICondition isWizardReady(final Wizard wizard) {
+ return new SWTBotTestCondition() {
+ @Override
+ public boolean test() throws Exception {
+ if (wizard.getShell() == null) {
+ return false;
+ }
+ return true;
+ }
+ };
+ }
+
+ /**
+ * Is the wizard on the page you want?
+ *
+ * @param wizard
+ * wizard
+ * @param page
+ * the desired page
+ * @return true or false
+ */
+ public static ICondition isWizardOnPage(final Wizard wizard, final IWizardPage page) {
+ return new SWTBotTestCondition() {
+ @Override
+ public boolean test() throws Exception {
+ if (wizard == null || page == null) {
+ return false;
+ }
+ final IWizardContainer container = wizard.getContainer();
+ if (container == null) {
+ return false;
+ }
+ IWizardPage currentPage = container.getCurrentPage();
+ return page.equals(currentPage);
+ }
+ };
+ }
+
+ /**
+ * Wait for a view to close
+ *
+ * @param view
+ * bot view for the view
+ * @return true if the view is closed, false if it's active.
+ */
+ public static ICondition ViewIsClosed(final SWTBotView view) {
+ return new SWTBotTestCondition() {
+ @Override
+ public boolean test() throws Exception {
+ return (view != null) && (!view.isActive());
+ }
+ };
+ }
+
+ /**
+ * Wait till table cell has a given content.
+ *
+ * @param table
+ * the table bot reference
+ * @param content
+ * the content to check
+ * @param row
+ * the row of the cell
+ * @param column
+ * the column of the cell
+ * @return ICondition for verification
+ */
+ public static ICondition isTableCellFilled(final SWTBotTable table,
+ final String content, final int row, final int column) {
+ return new SWTBotTestCondition() {
+ @Override
+ public boolean test() throws Exception {
+ try {
+ return content.equals(table.cell(row, column));
+ } catch (Exception e) {
+ }
+ return false;
+ }
+ };
+ }
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * 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:
+ * Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor;
+import org.eclipse.tracecompass.tmf.ui.project.model.TmfOpenTraceHelper;
+import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
+import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder;
+import org.eclipse.tracecompass.tmf.ui.project.model.TmfTracesFolder;
+import org.eclipse.tracecompass.tmf.ui.views.TracingPerspectiveFactory;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.WorkbenchException;
+import org.hamcrest.Matcher;
+
+
+/**
+ * SWTBot Helper functions
+ *
+ * @author Matthew Khouzam
+ */
+public final class SWTBotUtils {
+
+ private SWTBotUtils() {}
+
+ private static final String TRACING_PERSPECTIVE_ID = TracingPerspectiveFactory.ID;
+
+ /**
+ * Waits for all Eclipse jobs to finish
+ */
+ public static void waitForJobs() {
+ while (!Job.getJobManager().isIdle()) {
+ delay(100);
+ }
+ }
+
+ /**
+ * Sleeps current thread for a given time.
+ *
+ * @param waitTimeMillis
+ * time in milliseconds to wait
+ */
+ public static void delay(final long waitTimeMillis) {
+ try {
+ Thread.sleep(waitTimeMillis);
+ } catch (final InterruptedException e) {
+ // Ignored
+ }
+ }
+
+ /**
+ * Create a tracing project
+ *
+ * @param projectName
+ * the name of the tracing project
+ */
+ public static void createProject(final String projectName) {
+ /*
+ * Make a new test
+ */
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ IProject project = TmfProjectRegistry.createProject(projectName, null, new NullProgressMonitor());
+ assertNotNull(project);
+ }
+ });
+
+ SWTBotUtils.waitForJobs();
+ }
+
+ /**
+ * Deletes a tracing project
+ *
+ * @param projectName
+ * the name of the tracing project
+ * @param bot
+ * the workbench bot
+ */
+ public static void deleteProject(String projectName, SWTWorkbenchBot bot) {
+ // Wait for any analysis to complete because it might create
+ // supplementary files
+ SWTBotUtils.waitForJobs();
+ try {
+ ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ }
+
+ SWTBotUtils.waitForJobs();
+
+ final SWTBotView projectViewBot = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
+ projectViewBot.setFocus();
+
+ SWTBotTree treeBot = projectViewBot.bot().tree();
+ SWTBotTreeItem treeItem = treeBot.getTreeItem(projectName);
+ SWTBotMenu contextMenu = treeItem.contextMenu("Delete");
+ contextMenu.click();
+
+ bot.shell("Delete Resources").setFocus();
+ final SWTBotCheckBox checkBox = bot.checkBox();
+ bot.waitUntil(Conditions.widgetIsEnabled(checkBox));
+ checkBox.click();
+
+ final SWTBotButton okButton = bot.button("OK");
+ bot.waitUntil(Conditions.widgetIsEnabled(okButton));
+ okButton.click();
+
+ SWTBotUtils.waitForJobs();
+ }
+
+ /**
+ * Focus on the main window
+ *
+ * @param shellBots
+ * swtbotshells for all the shells
+ */
+ public static void focusMainWindow(SWTBotShell[] shellBots) {
+ for (SWTBotShell shellBot : shellBots) {
+ if (shellBot.getText().toLowerCase().contains("eclipse")) {
+ shellBot.activate();
+ }
+ }
+ }
+
+ /**
+ * Close a view with a title
+ *
+ * @param title
+ * the title, like "welcome"
+ * @param bot
+ * the workbench bot
+ */
+ public static void closeView(String title, SWTWorkbenchBot bot) {
+ final List<SWTBotView> openViews = bot.views();
+ for (SWTBotView view : openViews) {
+ if (view.getTitle().equalsIgnoreCase(title)) {
+ view.close();
+ bot.waitUntil(ConditionHelpers.ViewIsClosed(view));
+ }
+ }
+ }
+
+ /**
+ * Switch to the tracing perspective
+ */
+ public static void switchToTracingPerspective() {
+ switchToPerspective(TRACING_PERSPECTIVE_ID);
+ }
+
+ /**
+ * Switch to a given perspective
+ *
+ * @param id
+ * the perspective id (like
+ * "org.eclipse.linuxtools.tmf.ui.perspective"
+ */
+ public static void switchToPerspective(final String id) {
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ try {
+ PlatformUI.getWorkbench().showPerspective(id, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
+ } catch (WorkbenchException e) {
+ fail(e.getMessage());
+ }
+ }
+ });
+ }
+
+ /**
+ * If the test is running in the UI thread then fail
+ */
+ public static void failIfUIThread() {
+ if (Display.getCurrent() != null && Display.getCurrent().getThread() == Thread.currentThread()) {
+ fail("SWTBot test needs to run in a non-UI thread. Make sure that \"Run in UI thread\" is unchecked in your launch configuration or"
+ + " that useUIThread is set to false in the pom.xml");
+ }
+
+ }
+
+ /**
+ * Open a trace, this does not perform any validation though
+ *
+ * @param projectName
+ * The project name
+ * @param tracePath
+ * the path of the trace file (absolute or relative)
+ * @param traceType
+ * the trace canonical string (eg:
+ * org.eclipse.linuxtools.btf.trace)
+ */
+ public static void openTrace(final String projectName, final String tracePath, final String traceType) {
+ openTrace(projectName, tracePath, traceType, true);
+ }
+
+ /**
+ * Open a trace, this does not perform any validation though
+ *
+ * @param projectName
+ * The project name
+ * @param tracePath
+ * the path of the trace file (absolute or relative)
+ * @param traceType
+ * the trace canonical string (eg:
+ * org.eclipse.linuxtools.btf.trace)
+ * @param delay
+ * delay and wait for jobs
+ */
+ public static void openTrace(final String projectName, final String tracePath, final String traceType, boolean delay) {
+ final Exception exception[] = new Exception[1];
+ exception[0] = null;
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ try {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ TmfTraceFolder destinationFolder = TmfProjectRegistry.getProject(project, true).getTracesFolder();
+ TmfOpenTraceHelper.openTraceFromPath(destinationFolder, tracePath, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), traceType);
+ } catch (CoreException e) {
+ exception[0] = e;
+ }
+ }
+ });
+ if (exception[0] != null) {
+ fail(exception[0].getMessage());
+ }
+
+ if (delay) {
+ delay(1000);
+ waitForJobs();
+ }
+ }
+
+ /**
+ * Finds an editor and sets focus to the editor
+ *
+ * @param bot
+ * the workbench bot
+ * @param editorName
+ * the editor name
+ * @return the corresponding SWTBotEditor
+ */
+ public static SWTBotEditor activateEditor(SWTWorkbenchBot bot, String editorName) {
+ Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(editorName);
+ final SWTBotEditor editorBot = bot.editor(matcher);
+ IEditorPart iep = editorBot.getReference().getEditor(true);
+ final TmfEventsEditor tmfEd = (TmfEventsEditor) iep;
+ editorBot.show();
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ tmfEd.setFocus();
+ }
+ });
+
+ SWTBotUtils.waitForJobs();
+ SWTBotUtils.delay(1000);
+ assertNotNull(tmfEd);
+ return editorBot;
+ }
+
+ /**
+ * Opens a trace in an editor and get the TmfEventsEditor
+ *
+ * @param bot
+ * the workbench bot
+ * @param projectName
+ * the name of the project that contains the trace
+ * @param elementPath
+ * the trace element path (relative to Traces folder)
+ * @return TmfEventsEditor the opened editor
+ */
+ public static TmfEventsEditor openEditor(SWTWorkbenchBot bot, String projectName, IPath elementPath) {
+ final SWTBotView projectExplorerBot = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
+ projectExplorerBot.setFocus();
+
+ final SWTBotTree tree = bot.tree();
+ final SWTBotTreeItem treeItem = tree.getTreeItem(projectName);
+ treeItem.expand();
+
+ String nodeName = getFullNodeName(treeItem, TmfTracesFolder.TRACES_FOLDER_NAME);
+ bot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(nodeName, treeItem));
+ SWTBotTreeItem tracesNode = treeItem.getNode(nodeName);
+ tracesNode.expand();
+
+ SWTBotTreeItem currentNode = tracesNode;
+ for (String segment : elementPath.segments()) {
+ String fullNodeName = getFullNodeName(currentNode, segment);
+ bot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(fullNodeName, currentNode));
+ SWTBotTreeItem newNode = currentNode.getNode(fullNodeName);
+ newNode.select();
+ newNode.doubleClick();
+ currentNode = newNode;
+ }
+
+ SWTBotUtils.delay(1000);
+ SWTBotUtils.waitForJobs();
+ final String expectedTitle = elementPath.toString();
+
+ 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(expectedTitle)) {
+ iep[0] = ied.getEditor(true);
+ break;
+ }
+ }
+ }
+ });
+ assertNotNull(iep[0]);
+ return (TmfEventsEditor) iep[0];
+ }
+
+ private static String getFullNodeName(final SWTBotTreeItem treeItem, String prefix) {
+ List<String> nodes = treeItem.getNodes();
+ String nodeName = "";
+ for (String node : nodes) {
+ if (node.startsWith(prefix)) {
+ nodeName = node;
+ }
+ }
+ return nodeName;
+ }
+}
+++ /dev/null
-/*******************************************************************************
- * 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.SimpleLayout;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
-import org.junit.BeforeClass;
-
-/**
- * Abstract custom parser
- * @author Matthew Khouzam
- *
- */
-public class AbstractCustomParserWizard {
-
- /** The Log4j logger instance. */
- static final Logger fLogger = Logger.getRootLogger();
-
- /**
- * The SWTBot running the test
- */
- protected static SWTWorkbenchBot fBot;
-
- /** Test Class setup */
- @BeforeClass
- public static void init() {
- SWTBotUtil.failIfUIThread();
- Thread.currentThread().setName("SWTBot Thread"); // for the debugger
- /* set up for swtbot */
- SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
- fLogger.addAppender(new ConsoleAppender(new SimpleLayout()));
- fBot = new SWTWorkbenchBot();
-
- SWTBotUtil.closeView("welcome", fBot);
-
- SWTBotUtil.switchToTracingPerspective();
- /* finish waiting for eclipse to load */
- SWTBotUtil.waitForJobs();
-
- }
-
- /**
- * Extract test XML file
- *
- * @param xmlFile
- * the XML file to open
- * @param category
- * the category of the parser
- * @param definitionName
- * the name of the definition
- * @return an XML string of the definition
- * @throws IOException
- * Error reading the file
- * @throws FileNotFoundException
- * File is not found
- */
- protected static String extractTestXml(File xmlFile, String category, String definitionName) throws IOException, FileNotFoundException {
- StringBuilder xmlPart = new StringBuilder();
- boolean started = false;
- try (RandomAccessFile raf = new RandomAccessFile(xmlFile, "r");) {
- String s = raf.readLine();
- while (s != null) {
- if (s.equals("<Definition category=\"" + category + "\" name=\"" + definitionName + "\">")) {
- started = true;
- }
- if (started) {
- if (s.equals("</Definition>")) {
- break;
- }
- xmlPart.append(s);
- xmlPart.append('\n');
- }
- s = raf.readLine();
- }
- }
- return xmlPart.toString();
- }
-}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.varia.NullAppender;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
-import org.eclipse.ui.IViewReference;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests perspectives to make sure they have all the views
- *
- * @author Matthew Khouzam
- */
-@RunWith(SWTBotJunit4ClassRunner.class)
-public abstract class AbstractPerspectiveChecker {
-
- private static SWTWorkbenchBot fBot;
- /** The Log4j logger instance. */
- private static final Logger fLogger = Logger.getRootLogger();
-
- /**
- * The perspective id
- */
- protected String fPerspectiveId;
- /**
- * the view id collection
- */
- protected Collection<String> fViewIds;
-
- /** Test Class setup */
- @BeforeClass
- public static void beforeInit() {
- SWTBotUtil.failIfUIThread();
-
- /* set up for swtbot */
- SWTBotPreferences.TIMEOUT = 50000; /* 50 second timeout */
- fLogger.addAppender(new NullAppender());
- fBot = new SWTWorkbenchBot();
-
- SWTBotUtil.closeView("welcome", fBot);
-
- }
-
- /**
- * Gets the perspective and checks if all the views specified in the list
- * are present in the perspective
- */
- @Test
- public void testPerspectiveForViews() {
- SWTBotUtil.switchToPerspective(fPerspectiveId);
- SWTBotUtil.waitForJobs();
- for (final String viewID : fViewIds) {
- List<SWTBotView> view = fBot.views(new BaseMatcher<String>() {
-
- @Override
- public boolean matches(Object item) {
- if (!(item instanceof IViewReference)) {
- return false;
- }
- IViewReference reference = (IViewReference) item;
- return reference.getId().equals(viewID);
- }
-
- @Override
- public void describeTo(Description description) {
- }
-
- });
- assertEquals("view " + viewID + "is present", 1, view.size());
- }
- }
-
- /**
- * Gets the perspective and checks if all the views of that perspective are
- * in the list
- */
- @Test
- public void testPerspectiveComplete() {
- SWTBotUtil.switchToPerspective(fPerspectiveId);
- SWTBotUtil.waitForJobs();
- for (SWTBotView view : fBot.views()) {
- assertTrue("view " + view.toString() + "is present", fViewIds.contains(view.getViewReference().getId()));
- }
- }
-
-}
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- TestCustomTxtWizard.class,
- TestCustomXmlWizard.class,
- TracingPerspectiveChecker.class,
- org.eclipse.tracecompass.tmf.ui.swtbot.tests.table.AllTests.class
+ org.eclipse.tracecompass.tmf.ui.swtbot.tests.parsers.custom.AllTests.class,
+ org.eclipse.tracecompass.tmf.ui.swtbot.tests.perspectives.TracingPerspectiveChecker.class,
+ org.eclipse.tracecompass.tmf.ui.swtbot.tests.viewers.events.AllTests.class
})
public class AllTmfUISWTBotTests {
}
+++ /dev/null
-/*******************************************************************************
- * 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
-import org.eclipse.swtbot.swt.finder.results.VoidResult;
-import org.eclipse.swtbot.swt.finder.waits.Conditions;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor;
-import org.eclipse.tracecompass.tmf.ui.project.model.TmfOpenTraceHelper;
-import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
-import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder;
-import org.eclipse.tracecompass.tmf.ui.project.model.TmfTracesFolder;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
-import org.eclipse.tracecompass.tmf.ui.views.TracingPerspectiveFactory;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.WorkbenchException;
-import org.hamcrest.Matcher;
-
-
-/**
- * SWTBot Helper functions
- *
- * @author Matthew Khouzam
- */
-public abstract class SWTBotUtil {
- private static final String TRACING_PERSPECTIVE_ID = TracingPerspectiveFactory.ID;
-
- /**
- * Waits for all Eclipse jobs to finish
- */
- public static void waitForJobs() {
- while (!Job.getJobManager().isIdle()) {
- delay(100);
- }
- }
-
- /**
- * Sleeps current thread for a given time.
- *
- * @param waitTimeMillis
- * time in milliseconds to wait
- */
- public static void delay(final long waitTimeMillis) {
- try {
- Thread.sleep(waitTimeMillis);
- } catch (final InterruptedException e) {
- // Ignored
- }
- }
-
- /**
- * Create a tracing project
- *
- * @param projectName
- * the name of the tracing project
- */
- public static void createProject(final String projectName) {
- /*
- * Make a new test
- */
- UIThreadRunnable.syncExec(new VoidResult() {
- @Override
- public void run() {
- IProject project = TmfProjectRegistry.createProject(projectName, null, new NullProgressMonitor());
- assertNotNull(project);
- }
- });
-
- SWTBotUtil.waitForJobs();
- }
-
- /**
- * Deletes a tracing project
- *
- * @param projectName
- * the name of the tracing project
- * @param bot
- * the workbench bot
- */
- public static void deleteProject(String projectName, SWTWorkbenchBot bot) {
- // Wait for any analysis to complete because it might create
- // supplementary files
- SWTBotUtil.waitForJobs();
- try {
- ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- }
-
- SWTBotUtil.waitForJobs();
-
- final SWTBotView projectViewBot = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
- projectViewBot.setFocus();
-
- SWTBotTree treeBot = projectViewBot.bot().tree();
- SWTBotTreeItem treeItem = treeBot.getTreeItem(projectName);
- SWTBotMenu contextMenu = treeItem.contextMenu("Delete");
- contextMenu.click();
-
- bot.shell("Delete Resources").setFocus();
- final SWTBotCheckBox checkBox = bot.checkBox();
- bot.waitUntil(Conditions.widgetIsEnabled(checkBox));
- checkBox.click();
-
- final SWTBotButton okButton = bot.button("OK");
- bot.waitUntil(Conditions.widgetIsEnabled(okButton));
- okButton.click();
-
- SWTBotUtil.waitForJobs();
- }
-
- /**
- * Focus on the main window
- *
- * @param shellBots
- * swtbotshells for all the shells
- */
- public static void focusMainWindow(SWTBotShell[] shellBots) {
- for (SWTBotShell shellBot : shellBots) {
- if (shellBot.getText().toLowerCase().contains("eclipse")) {
- shellBot.activate();
- }
- }
- }
-
- /**
- * Close a view with a title
- *
- * @param title
- * the title, like "welcome"
- * @param bot
- * the workbench bot
- */
- public static void closeView(String title, SWTWorkbenchBot bot) {
- final List<SWTBotView> openViews = bot.views();
- for (SWTBotView view : openViews) {
- if (view.getTitle().equalsIgnoreCase(title)) {
- view.close();
- bot.waitUntil(ConditionHelpers.ViewIsClosed(view));
- }
- }
- }
-
- /**
- * Switch to the tracing perspective
- */
- public static void switchToTracingPerspective() {
- switchToPerspective(TRACING_PERSPECTIVE_ID);
- }
-
- /**
- * Switch to a given perspective
- *
- * @param id
- * the perspective id (like
- * "org.eclipse.linuxtools.tmf.ui.perspective"
- */
- public static void switchToPerspective(final String id) {
- UIThreadRunnable.syncExec(new VoidResult() {
- @Override
- public void run() {
- try {
- PlatformUI.getWorkbench().showPerspective(id, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
- } catch (WorkbenchException e) {
- fail(e.getMessage());
- }
- }
- });
- }
-
- /**
- * If the test is running in the UI thread then fail
- */
- public static void failIfUIThread() {
- if (Display.getCurrent() != null && Display.getCurrent().getThread() == Thread.currentThread()) {
- fail("SWTBot test needs to run in a non-UI thread. Make sure that \"Run in UI thread\" is unchecked in your launch configuration or"
- + " that useUIThread is set to false in the pom.xml");
- }
-
- }
-
- /**
- * Open a trace, this does not perform any validation though
- *
- * @param projectName
- * The project name
- * @param tracePath
- * the path of the trace file (absolute or relative)
- * @param traceType
- * the trace canonical string (eg:
- * org.eclipse.linuxtools.btf.trace)
- */
- public static void openTrace(final String projectName, final String tracePath, final String traceType) {
- openTrace(projectName, tracePath, traceType, true);
- }
-
- /**
- * Open a trace, this does not perform any validation though
- *
- * @param projectName
- * The project name
- * @param tracePath
- * the path of the trace file (absolute or relative)
- * @param traceType
- * the trace canonical string (eg:
- * org.eclipse.linuxtools.btf.trace)
- * @param delay
- * delay and wait for jobs
- */
- public static void openTrace(final String projectName, final String tracePath, final String traceType, boolean delay) {
- final Exception exception[] = new Exception[1];
- exception[0] = null;
- UIThreadRunnable.syncExec(new VoidResult() {
- @Override
- public void run() {
- try {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- TmfTraceFolder destinationFolder = TmfProjectRegistry.getProject(project, true).getTracesFolder();
- TmfOpenTraceHelper.openTraceFromPath(destinationFolder, tracePath, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), traceType);
- } catch (CoreException e) {
- exception[0] = e;
- }
- }
- });
- if (exception[0] != null) {
- fail(exception[0].getMessage());
- }
-
- if (delay) {
- delay(1000);
- waitForJobs();
- }
- }
-
- /**
- * Finds an editor and sets focus to the editor
- *
- * @param bot
- * the workbench bot
- * @param editorName
- * the editor name
- * @return the corresponding SWTBotEditor
- */
- public static SWTBotEditor activateEditor(SWTWorkbenchBot bot, String editorName) {
- Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(editorName);
- final SWTBotEditor editorBot = bot.editor(matcher);
- IEditorPart iep = editorBot.getReference().getEditor(true);
- final TmfEventsEditor tmfEd = (TmfEventsEditor) iep;
- editorBot.show();
- UIThreadRunnable.syncExec(new VoidResult() {
- @Override
- public void run() {
- tmfEd.setFocus();
- }
- });
-
- SWTBotUtil.waitForJobs();
- SWTBotUtil.delay(1000);
- assertNotNull(tmfEd);
- return editorBot;
- }
-
- /**
- * Opens a trace in an editor and get the TmfEventsEditor
- *
- * @param bot
- * the workbench bot
- * @param projectName
- * the name of the project that contains the trace
- * @param elementPath
- * the trace element path (relative to Traces folder)
- * @return TmfEventsEditor the opened editor
- */
- public static TmfEventsEditor openEditor(SWTWorkbenchBot bot, String projectName, IPath elementPath) {
- final SWTBotView projectExplorerBot = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
- projectExplorerBot.setFocus();
-
- final SWTBotTree tree = bot.tree();
- final SWTBotTreeItem treeItem = tree.getTreeItem(projectName);
- treeItem.expand();
-
- String nodeName = getFullNodeName(treeItem, TmfTracesFolder.TRACES_FOLDER_NAME);
- bot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(nodeName, treeItem));
- SWTBotTreeItem tracesNode = treeItem.getNode(nodeName);
- tracesNode.expand();
-
- SWTBotTreeItem currentNode = tracesNode;
- for (String segment : elementPath.segments()) {
- String fullNodeName = getFullNodeName(currentNode, segment);
- bot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(fullNodeName, currentNode));
- SWTBotTreeItem newNode = currentNode.getNode(fullNodeName);
- newNode.select();
- newNode.doubleClick();
- currentNode = newNode;
- }
-
- SWTBotUtil.delay(1000);
- SWTBotUtil.waitForJobs();
- final String expectedTitle = elementPath.toString();
-
- 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(expectedTitle)) {
- iep[0] = ied.getEditor(true);
- break;
- }
- }
- }
- });
- assertNotNull(iep[0]);
- return (TmfEventsEditor) iep[0];
- }
-
- private static String getFullNodeName(final SWTBotTreeItem treeItem, String prefix) {
- List<String> nodes = treeItem.getNodes();
- String nodeName = "";
- for (String node : nodes) {
- if (node.startsWith(prefix)) {
- nodeName = node;
- }
- }
- return nodeName;
- }
-}
+++ /dev/null
-/*******************************************************************************
- * 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Custom text wizard tests
- *
- * Some reminders to help making tests (javadoc to keep formatting)
- *
- * Button reminder
- *
- * <pre>
- * 0 Time Stamp Format Help
- * 1 Remove line
- * 2 Add next line
- * 3 Add child line
- * 4 Move up
- * 5 Move down
- * 6 Regular Expression Help
- * 7 Remove group (group 1 toggle)
- * 8 Remove group (group 2 toggle)
- * 9 Add group (group 3 toggle ...)
- * 10 Show parsing result
- * 11 Preview Legend
- * </pre>
- *
- * Combo box reminder
- *
- * <pre>
- * 0 cardinality
- * 1 event type (message, timestamp...)
- * 2 how to handle the data (set, append...)
- * repeat
- * </pre>
- *
- * @author Matthew Khouzam
- *
- */
-@RunWith(SWTBotJunit4ClassRunner.class)
-public class TestCustomTxtWizard extends AbstractCustomParserWizard {
-
- private static final String MANAGE_CUSTOM_PARSERS_SHELL_TITLE = "Manage Custom Parsers";
- private static final String PROJECT_NAME = "TestText";
- private static final String CATEGORY_NAME = "Test Category";
- private static final String TRACETYPE_NAME = "Test Trace";
- private static final String EXPECTED_TEST_DEFINITION = "<Definition category=\"Test Category\" name=\"Test Trace\">\n" +
- "<TimeStampOutputFormat>ss</TimeStampOutputFormat>\n" +
- "<InputLine>\n" +
- "<Cardinality max=\"2147483647\" min=\"0\"/>\n" +
- "<RegEx>\\s*(\\d\\d)\\s(.*\\S)</RegEx>\n" +
- "<InputData action=\"0\" format=\"ss\" name=\"Time Stamp\"/>\n" +
- "<InputData action=\"0\" name=\"Message\"/>\n" +
- "</InputLine>\n" +
- "<InputLine>\n" +
- "<Cardinality max=\"2147483647\" min=\"0\"/>\n" +
- "<RegEx>([^0-9]*)</RegEx>\n" +
- "<InputData action=\"2\" name=\"Message\"/>\n" +
- "</InputLine>\n" +
- "<OutputColumn name=\"Time Stamp\"/>\n" +
- "<OutputColumn name=\"Message\"/>\n";
-
- /**
- * Test to create a custom txt trace and compare the xml
- *
- * @throws IOException
- * the xml file is not accessible, this is bad
- * @throws FileNotFoundException
- * the xml file wasn't written, this is bad
- */
- @Test
- public void testNew() throws FileNotFoundException, IOException {
- File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_txt_parsers.xml").toFile();
- SWTBotUtil.createProject(PROJECT_NAME);
- SWTBotView proejctExplorerBot = fBot.viewByTitle("Project Explorer");
- proejctExplorerBot.show();
- SWTBotTreeItem treeItem = proejctExplorerBot.bot().tree().getTreeItem(PROJECT_NAME);
- treeItem.select();
- treeItem.expand();
- SWTBotTreeItem treeNode = null;
- for (String node : treeItem.getNodes()) {
- if (node.startsWith("Trace")) {
- treeNode = treeItem.getNode(node);
- break;
- }
-
- }
- assertNotNull(treeNode);
- treeNode.contextMenu("Manage Custom Parsers...").click();
- fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).setFocus();
-
- fBot.button("New...").click();
-
- fBot.textWithLabel("Category:").setText(CATEGORY_NAME);
- fBot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
- fBot.textWithLabel("Time Stamp format:").setText("ss");
- fBot.comboBox(1).setSelection("Time Stamp");
- fBot.textWithLabel("format:").setText("ss");
- fBot.button(8).click();
- fBot.button(2).click();
- SWTBotTreeItem[] treeItems = fBot.tree().getAllItems();
- SWTBotTreeItem eventLine[] = new SWTBotTreeItem[2];
- treeItems = fBot.tree().getAllItems();
- for (SWTBotTreeItem item : treeItems) {
- if (item.getText().startsWith("Root Line 1")) {
- eventLine[0] = item;
- }
- if (item.getText().startsWith("Root Line 2")) {
- eventLine[1] = item;
- }
- }
- assertNotNull(eventLine[0]);
- assertNotNull(eventLine[1]);
- fBot.styledText().setText("12 Hello\nWorld\n23 Goodbye\ncruel world");
- eventLine[0].select();
- SWTBotUtil.waitForJobs();
- fBot.textWithLabel("Regular expression:").setText("\\s*(\\d\\d)\\s(.*\\S)");
- eventLine[1].select();
- fBot.textWithLabel("Regular expression:").setText("([^0-9]*)");
- fBot.button(7).click();
- fBot.comboBox("Set").setSelection("Append with |");
- fBot.button("Highlight All").click();
- fBot.button("Next >").click();
- fBot.button("Finish").click();
- String xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
- assertEquals(EXPECTED_TEST_DEFINITION, xmlPart);
- fBot.list().select(CATEGORY_NAME + " : " + TRACETYPE_NAME);
- fBot.button("Delete").click();
- fBot.button("Yes").click();
- fBot.button("Close").click();
- xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
- assertEquals("", xmlPart);
-
- SWTBotUtil.deleteProject(PROJECT_NAME, fBot);
- }
-
- /**
- * Test to edit a custom txt trace and compare the xml
- *
- * @throws IOException
- * the xml file is not accessible, this is bad
- * @throws FileNotFoundException
- * the xml file wasn't written, this is bad
- */
- @Test
- public void testEdit() throws FileNotFoundException, IOException {
- File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_txt_parsers.xml").toFile();
- try (FileWriter fw = new FileWriter(xmlFile)) {
- String xmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
- "<CustomTxtTraceDefinitionList>\n" +
- "<Definition category=\"Demo Category\" name=\"Demo trace\">\n" +
- "<TimeStampOutputFormat>sss</TimeStampOutputFormat>\n" +
- "<InputLine>\n" +
- "<Cardinality max=\"2147483647\" min=\"0\"/>\n" +
- "<RegEx>\\s*(\\d*)\\s(.*)</RegEx>\n" +
- "<InputData action=\"0\" format=\"sss\" name=\"Time Stamp\"/>\n" +
- "<InputData action=\"0\" name=\"Message\"/>\n" +
- "</InputLine>\n" +
- "<OutputColumn name=\"Time Stamp\"/>\n" +
- "<OutputColumn name=\"Message\"/>\n" +
- "</Definition>\n" +
- "<Definition name=\"dmesg\">\n" +
- "<TimeStampOutputFormat>sssssss.ssssss</TimeStampOutputFormat>\n" +
- "<InputLine>\n" +
- "<Cardinality max=\"2147483647\" min=\"0\"/>\n" +
- "<RegEx>^[([0-9]*\\.[0.9]*)]\\s(.*)</RegEx>\n" +
- "<InputData action=\"0\" format=\"sssss.sssss\" name=\"Time Stamp\"/>\n" +
- "<InputData action=\"0\" name=\"Message\"/>\n" +
- "</InputLine>\n" +
- "<OutputColumn name=\"Time Stamp\"/>\n" +
- "<OutputColumn name=\"Message\"/>\n" +
- "</Definition>\n" +
- "</CustomTxtTraceDefinitionList>";
- fw.write(xmlContent);
- fw.flush();
- }
- SWTBotUtil.createProject(PROJECT_NAME);
- SWTBotView proejctExplorerBot = fBot.viewByTitle("Project Explorer");
- proejctExplorerBot.show();
- SWTBotTreeItem treeItem = proejctExplorerBot.bot().tree().getTreeItem(PROJECT_NAME);
- treeItem.select();
- treeItem.expand();
- SWTBotTreeItem treeNode = null;
- for (String node : treeItem.getNodes()) {
- if (node.startsWith("Trace")) {
- treeNode = treeItem.getNode(node);
- break;
- }
-
- }
- assertNotNull(treeNode);
- treeNode.contextMenu("Manage Custom Parsers...").click();
- fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).setFocus();
- fBot.list().select("Demo Category : Demo trace");
- fBot.button("Edit...").click();
-
- fBot.textWithLabel("Category:").setText(CATEGORY_NAME);
- fBot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
- fBot.textWithLabel("Time Stamp format:").setText("ss");
- fBot.comboBox(1).setSelection("Time Stamp");
- fBot.textWithLabel("format:").setText("ss");
- fBot.button(2).click();
- SWTBotTreeItem[] treeItems = fBot.tree().getAllItems();
- SWTBotTreeItem eventLine[] = new SWTBotTreeItem[2];
- for (SWTBotTreeItem item : treeItems) {
- if (item.getText().startsWith("Root Line 1")) {
- eventLine[0] = item;
- }
- if (item.getText().startsWith("Root Line 2")) {
- eventLine[1] = item;
- }
- }
- treeItems = fBot.tree().getAllItems();
- assertNotNull(eventLine[0]);
- assertNotNull(eventLine[1]);
- fBot.styledText().setText("12 Hello\nWorld\n23 Goodbye\ncruel world");
- eventLine[0].select();
- SWTBotUtil.waitForJobs();
- fBot.textWithLabel("Regular expression:").setText("\\s*(\\d\\d)\\s(.*\\S)");
- eventLine[1].select();
- fBot.textWithLabel("Regular expression:").setText("([^0-9]*)");
- fBot.button(7).click();
- fBot.comboBox("Set").setSelection("Append with |");
- fBot.button("Highlight All").click();
- fBot.button("Next >").click();
- fBot.button("Finish").click();
- String xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
- assertEquals(EXPECTED_TEST_DEFINITION, xmlPart);
- fBot.list().select(CATEGORY_NAME + " : " + TRACETYPE_NAME);
- fBot.button("Delete").click();
- fBot.button("Yes").click();
- fBot.button("Close").click();
- xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
- assertEquals("", xmlPart);
-
- SWTBotUtil.deleteProject(PROJECT_NAME, fBot);
- }
-}
+++ /dev/null
-/*******************************************************************************
- * 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Custom XML wizard tests
- *
- * This test will help validate the CustomXmlParserInputWizardPage
- *
- * @author Matthew Khouzam
- *
- */
-@RunWith(SWTBotJunit4ClassRunner.class)
-public class TestCustomXmlWizard extends AbstractCustomParserWizard {
-
- private static final String EVENT = "event";
- private static final String TRACE = "trace";
- private static final String XML_TRACE1 = "<trace>\n\t<event time=\"100\" msg=\"hello\"/>\n\t<event time=\"200\" msg=\"world\"/></trace>";
- private static final String MANAGE_CUSTOM_PARSERS_SHELL_TITLE = "Manage Custom Parsers";
- private static final String PROJECT_NAME = "TestXML";
- private static final String CATEGORY_NAME = "Test Category";
- private static final String TRACETYPE_NAME = "Test Trace";
- private static final String EXPECTED_TEST_DEFINITION = "<Definition category=\"Test Category\" name=\"" + TRACETYPE_NAME + "\">\n" +
- "<TimeStampOutputFormat>ss</TimeStampOutputFormat>\n" +
- "<InputElement name=\"trace\">\n" +
- "<InputElement logentry=\"true\" name=\"event\">\n" +
- "<InputData action=\"0\" format=\"\" name=\"Ignore\"/>\n" +
- "<Attribute name=\"msg\">\n" +
- "<InputData action=\"0\" name=\"msg\"/>\n" +
- "</Attribute>\n" +
- "<Attribute name=\"time\">\n" +
- "<InputData action=\"0\" name=\"time\"/>\n" +
- "</Attribute>\n" +
- "</InputElement>\n" +
- "</InputElement>\n" +
- "<OutputColumn name=\"msg\"/>\n" +
- "<OutputColumn name=\"time\"/>\n";
-
- /**
- * Test to create a custom XML trace and compare the XML generated
- *
- * @throws IOException
- * the xml file is not accessible, this is bad
- * @throws FileNotFoundException
- * the xml file wasn't written, this is bad
- */
- @Test
- public void testNew() throws FileNotFoundException, IOException {
- File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_xml_parsers.xml").toFile();
- SWTBotUtil.createProject(PROJECT_NAME);
- SWTBotView proejctExplorerBot = fBot.viewByTitle("Project Explorer");
- proejctExplorerBot.show();
- SWTBotTreeItem treeItem = proejctExplorerBot.bot().tree().getTreeItem(PROJECT_NAME);
- treeItem.select();
- treeItem.expand();
- SWTBotTreeItem treeNode = null;
- for (String node : treeItem.getNodes()) {
- if (node.startsWith("Trace")) {
- treeNode = treeItem.getNode(node);
- break;
- }
-
- }
- assertNotNull(treeNode);
- treeNode.contextMenu("Manage Custom Parsers...").click();
- fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).setFocus();
- fBot.radio("XML").click();
- fBot.button("New...").click();
- fBot.textWithLabel("Category:").setText(CATEGORY_NAME);
- fBot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
- fBot.textWithLabel("Time Stamp format:").setText("ss");
-
- fBot.styledText().setText(XML_TRACE1);
- fBot.buttonWithTooltip("Feeling lucky").click();
-
- fBot.tree().getTreeItem(TRACE).getNode(EVENT).select();
- fBot.checkBox("Log Entry").click();
- fBot.button("Next >").click();
- fBot.button("Finish").click();
-
- String xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
- assertEquals(EXPECTED_TEST_DEFINITION, xmlPart);
- fBot.list().select(CATEGORY_NAME + " : " + TRACETYPE_NAME);
- fBot.button("Delete").click();
- fBot.button("Yes").click();
- fBot.button("Close").click();
- xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
- assertEquals("", xmlPart);
-
- SWTBotUtil.deleteProject(PROJECT_NAME, fBot);
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.tracecompass.tmf.ui.views.TracingPerspectiveFactory;
-import org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramView;
-import org.eclipse.tracecompass.tmf.ui.views.statistics.TmfStatisticsView;
-import org.eclipse.ui.IPageLayout;
-import org.junit.Before;
-
-/**
- * Tracing perspective view checker
- *
- * @author Matthew Khouzam
- */
-public class TracingPerspectiveChecker extends AbstractPerspectiveChecker {
-
- /**
- * Set up arrays for test
- */
- @Before
- public void init() {
- fPerspectiveId = TracingPerspectiveFactory.ID;
- fViewIds = new ArrayList<>();
- fViewIds.addAll(Arrays.asList(new String[] {
- HistogramView.ID,
- TmfStatisticsView.ID,
- // Standard Eclipse views
- IPageLayout.ID_PROJECT_EXPLORER,
- IPageLayout.ID_PROP_SHEET,
- IPageLayout.ID_BOOKMARKS
- }));
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions;
-
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.waits.ICondition;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-
-/**
- * Is a tree node available
- *
- * @author Matthew Khouzam
- */
-public abstract class ConditionHelpers {
-
- /**
- * Is a tree node available
- *
- * @param name
- * the name of the node
- * @param tree
- * the parent tree
- * @return true or false, it should swallow all exceptions
- */
- public static ICondition IsTreeNodeAvailable(String name, SWTBotTree tree) {
- return new TreeNodeAvailable(name, tree);
- }
-
- /**
- * Is the treeItem's node available
- *
- * @param name
- * the name of the node
- * @param treeItem
- * the treeItem
- * @return true or false, it should swallow all exceptions
- */
- public static ICondition IsTreeChildNodeAvailable(String name, SWTBotTreeItem treeItem) {
- return new TreeItemNodeAvailable(name, treeItem);
- }
-
- /**
- * Checks if the wizard's shell is null
- *
- * @param wizard
- * the null
- * @return false if either are null
- */
- public static ICondition isWizardReady(Wizard wizard) {
- return new WizardReady(wizard);
- }
-
- /**
- * Is the wizard on the page you want?
- *
- * @param wizard
- * wizard
- * @param desiredPage
- * the desired page
- * @return true or false
- */
- public static ICondition isWizardOnPage(Wizard wizard, IWizardPage desiredPage) {
- return new WizardOnPage(wizard, desiredPage);
- }
-
- /**
- * Wait for a view to close
- *
- * @param view
- * bot view for the view
- * @return true if the view is closed, false if it's active.
- */
- public static ICondition ViewIsClosed(SWTBotView view) {
- return new ViewClosed(view);
- }
-
- /**
- * Wait till table cell has a given content.
- *
- * @param table
- * the table bot reference
- * @param content
- * the content to check
- * @param row
- * the row of the cell
- * @param column
- * the column of the cell
- * @return ICondition for verification
- */
- public static ICondition isTableCellFilled(SWTBotTable table, String content, int row, int column) {
- return new TableCellFilled(table, content, row, column);
- }
-}
+++ /dev/null
-/*******************************************************************************
- * 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.tracecompass.tmf.ui.swtbot.tests.conditions;
-
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.waits.ICondition;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-
-/**
- * Is a table cell filled? tests if the table cell has a given content.
- *
- * @author Bernd Hufmann
- */
-class TableCellFilled implements ICondition {
-
- private final SWTBotTable fTable;
- private final String fContent;
- private final int fRow;
- private final int fColumn;
-
- public TableCellFilled(SWTBotTable table, String content, int row, int column) {
- fTable = table;
- fContent = content;
- fRow = row;
- fColumn = column;
- }
-
- @Override
- public boolean test() throws Exception {
- try {
- return fContent.equals(fTable.cell(fRow, fColumn));
- } catch (Exception e) {
- }
- return false;
- }
-
- @Override
- public void init(SWTBot bot) {
- }
-
- @Override
- public String getFailureMessage() {
- return null;
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions;
-
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.waits.ICondition;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-
-/**
- * Is a TreeItem's node available? tests if the tree has an item with a given name
- *
- * @author Matthew Khouzam
- */
-class TreeItemNodeAvailable implements ICondition {
-
- private final SWTBotTreeItem fTreeItem;
- private final String fName;
-
- public TreeItemNodeAvailable(String name, SWTBotTreeItem treeItem) {
- fName = name;
- fTreeItem = treeItem;
- }
-
- @Override
- public boolean test() throws Exception {
- try {
- return fTreeItem.getNode(fName) != null;
- } catch (Exception e) {
- }
- return false;
- }
-
- @Override
- public void init(SWTBot bot) {
- }
-
- @Override
- public String getFailureMessage() {
- return null;
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions;
-
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.waits.ICondition;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-
-/**
- * Is a tree node available?
- *
- * @author Matthew Khouzam
- */
-class TreeNodeAvailable implements ICondition {
-
- private final SWTBotTree fTree;
- private final String fName;
-
- /**
- * Is a tree node available
- *
- * @param name
- * The name of the node
- * @param tree
- * the swtbotTree
- */
- public TreeNodeAvailable(String name, SWTBotTree tree) {
- fTree = tree;
- fName = name;
- }
-
- @Override
- public boolean test() throws Exception {
- try {
- final SWTBotTreeItem[] treeItems = fTree.getAllItems();
- for( SWTBotTreeItem ti : treeItems){
- final String text = ti.getText();
- if( text.equals(fName)) {
- return true;
- }
- }
- } catch (Exception e) {
- }
- return false;
- }
-
- @Override
- public void init(SWTBot bot) {
- }
-
- @Override
- public String getFailureMessage() {
- return null;
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions;
-
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.waits.ICondition;
-
-/**
- * Is a view closed?
- *
- * @author Matthew Khouzam
- */
-class ViewClosed implements ICondition {
- private final SWTBotView fView;
-
- public ViewClosed(SWTBotView view) {
- fView = view;
- }
-
- @Override
- public boolean test() throws Exception {
- return (fView != null) && (!fView.isActive());
- }
-
- @Override
- public void init(SWTBot bot) {
- }
-
- @Override
- public String getFailureMessage() {
- return null;
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions;
-
-import org.eclipse.jface.wizard.IWizardContainer;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.waits.ICondition;
-
-/**
- * Is the wizard on the page you want?
- * @author Matthew Khouzam
- */
-class WizardOnPage implements ICondition {
-
- private final Wizard fWizard;
- private final IWizardPage fPage;
-
- public WizardOnPage(Wizard wizard, IWizardPage desiredPage) {
- fWizard = wizard;
- fPage = desiredPage;
- }
-
- @Override
- public boolean test() throws Exception {
- if (fWizard == null || fPage == null) {
- return false;
- }
- final IWizardContainer container = fWizard.getContainer();
- if (container == null) {
- return false;
- }
- IWizardPage currentPage = container.getCurrentPage();
- return fPage.equals(currentPage);
- }
-
- @Override
- public void init(SWTBot bot) {
- }
-
- @Override
- public String getFailureMessage() {
- return null;
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2013 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions;
-
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.waits.ICondition;
-
-/**
- * Is a given wizard ready?
- *
- * @author Matthew Khouzam
- */
-class WizardReady implements ICondition {
-
- private final Wizard fWizard;
-
- public WizardReady(Wizard wizard) {
- fWizard = wizard;
- }
-
- @Override
- public boolean test() throws Exception {
- if (fWizard.getShell() == null) {
- return false;
- }
- return true;
- }
-
- @Override
- public void init(SWTBot bot) {
- }
-
- @Override
- public String getFailureMessage() {
- return null;
- }
-
-}
--- /dev/null
+/*******************************************************************************
+ * 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:
+ * Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ui.swtbot.tests.parsers.custom;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.junit.BeforeClass;
+
+/**
+ * Abstract custom parser
+ *
+ * @author Matthew Khouzam
+ */
+public class AbstractCustomParserWizard {
+
+ /** The Log4j logger instance. */
+ private static final Logger fLogger = Logger.getRootLogger();
+
+ /**
+ * The SWTBot running the test
+ */
+ protected static SWTWorkbenchBot fBot;
+
+ /** Test Class setup */
+ @BeforeClass
+ public static void init() {
+ SWTBotUtils.failIfUIThread();
+ Thread.currentThread().setName("SWTBot Thread"); // for the debugger
+ /* set up for swtbot */
+ SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
+ fLogger.addAppender(new ConsoleAppender(new SimpleLayout()));
+ fBot = new SWTWorkbenchBot();
+
+ SWTBotUtils.closeView("welcome", fBot);
+
+ SWTBotUtils.switchToTracingPerspective();
+ /* finish waiting for eclipse to load */
+ SWTBotUtils.waitForJobs();
+
+ }
+
+ /**
+ * Extract test XML file
+ *
+ * @param xmlFile
+ * the XML file to open
+ * @param category
+ * the category of the parser
+ * @param definitionName
+ * the name of the definition
+ * @return an XML string of the definition
+ * @throws IOException
+ * Error reading the file
+ * @throws FileNotFoundException
+ * File is not found
+ */
+ protected static String extractTestXml(File xmlFile, String category, String definitionName) throws IOException, FileNotFoundException {
+ StringBuilder xmlPart = new StringBuilder();
+ boolean started = false;
+ try (RandomAccessFile raf = new RandomAccessFile(xmlFile, "r");) {
+ String s = raf.readLine();
+ while (s != null) {
+ if (s.equals("<Definition category=\"" + category + "\" name=\"" + definitionName + "\">")) {
+ started = true;
+ }
+ if (started) {
+ if (s.equals("</Definition>")) {
+ break;
+ }
+ xmlPart.append(s);
+ xmlPart.append('\n');
+ }
+ s = raf.readLine();
+ }
+ }
+ return xmlPart.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 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.tracecompass.tmf.ui.swtbot.tests.parsers.custom;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TestCustomTxtWizard.class,
+ TestCustomXmlWizard.class
+})
+public class AllTests {
+}
--- /dev/null
+/*******************************************************************************
+ * 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:
+ * Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ui.swtbot.tests.parsers.custom;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Custom text wizard tests
+ *
+ * Some reminders to help making tests (javadoc to keep formatting)
+ *
+ * Button reminder
+ *
+ * <pre>
+ * 0 Time Stamp Format Help
+ * 1 Remove line
+ * 2 Add next line
+ * 3 Add child line
+ * 4 Move up
+ * 5 Move down
+ * 6 Regular Expression Help
+ * 7 Remove group (group 1 toggle)
+ * 8 Remove group (group 2 toggle)
+ * 9 Add group (group 3 toggle ...)
+ * 10 Show parsing result
+ * 11 Preview Legend
+ * </pre>
+ *
+ * Combo box reminder
+ *
+ * <pre>
+ * 0 cardinality
+ * 1 event type (message, timestamp...)
+ * 2 how to handle the data (set, append...)
+ * repeat
+ * </pre>
+ *
+ * @author Matthew Khouzam
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class TestCustomTxtWizard extends AbstractCustomParserWizard {
+
+ private static final String MANAGE_CUSTOM_PARSERS_SHELL_TITLE = "Manage Custom Parsers";
+ private static final String PROJECT_NAME = "TestText";
+ private static final String CATEGORY_NAME = "Test Category";
+ private static final String TRACETYPE_NAME = "Test Trace";
+ private static final String EXPECTED_TEST_DEFINITION = "<Definition category=\"Test Category\" name=\"Test Trace\">\n" +
+ "<TimeStampOutputFormat>ss</TimeStampOutputFormat>\n" +
+ "<InputLine>\n" +
+ "<Cardinality max=\"2147483647\" min=\"0\"/>\n" +
+ "<RegEx>\\s*(\\d\\d)\\s(.*\\S)</RegEx>\n" +
+ "<InputData action=\"0\" format=\"ss\" name=\"Time Stamp\"/>\n" +
+ "<InputData action=\"0\" name=\"Message\"/>\n" +
+ "</InputLine>\n" +
+ "<InputLine>\n" +
+ "<Cardinality max=\"2147483647\" min=\"0\"/>\n" +
+ "<RegEx>([^0-9]*)</RegEx>\n" +
+ "<InputData action=\"2\" name=\"Message\"/>\n" +
+ "</InputLine>\n" +
+ "<OutputColumn name=\"Time Stamp\"/>\n" +
+ "<OutputColumn name=\"Message\"/>\n";
+
+ /**
+ * Test to create a custom txt trace and compare the xml
+ *
+ * @throws IOException
+ * the xml file is not accessible, this is bad
+ * @throws FileNotFoundException
+ * the xml file wasn't written, this is bad
+ */
+ @Test
+ public void testNew() throws FileNotFoundException, IOException {
+ File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_txt_parsers.xml").toFile();
+ SWTBotUtils.createProject(PROJECT_NAME);
+ SWTBotView proejctExplorerBot = fBot.viewByTitle("Project Explorer");
+ proejctExplorerBot.show();
+ SWTBotTreeItem treeItem = proejctExplorerBot.bot().tree().getTreeItem(PROJECT_NAME);
+ treeItem.select();
+ treeItem.expand();
+ SWTBotTreeItem treeNode = null;
+ for (String node : treeItem.getNodes()) {
+ if (node.startsWith("Trace")) {
+ treeNode = treeItem.getNode(node);
+ break;
+ }
+
+ }
+ assertNotNull(treeNode);
+ treeNode.contextMenu("Manage Custom Parsers...").click();
+ fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).setFocus();
+
+ fBot.button("New...").click();
+
+ fBot.textWithLabel("Category:").setText(CATEGORY_NAME);
+ fBot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
+ fBot.textWithLabel("Time Stamp format:").setText("ss");
+ fBot.comboBox(1).setSelection("Time Stamp");
+ fBot.textWithLabel("format:").setText("ss");
+ fBot.button(8).click();
+ fBot.button(2).click();
+ SWTBotTreeItem[] treeItems = fBot.tree().getAllItems();
+ SWTBotTreeItem eventLine[] = new SWTBotTreeItem[2];
+ treeItems = fBot.tree().getAllItems();
+ for (SWTBotTreeItem item : treeItems) {
+ if (item.getText().startsWith("Root Line 1")) {
+ eventLine[0] = item;
+ }
+ if (item.getText().startsWith("Root Line 2")) {
+ eventLine[1] = item;
+ }
+ }
+ assertNotNull(eventLine[0]);
+ assertNotNull(eventLine[1]);
+ fBot.styledText().setText("12 Hello\nWorld\n23 Goodbye\ncruel world");
+ eventLine[0].select();
+ SWTBotUtils.waitForJobs();
+ fBot.textWithLabel("Regular expression:").setText("\\s*(\\d\\d)\\s(.*\\S)");
+ eventLine[1].select();
+ fBot.textWithLabel("Regular expression:").setText("([^0-9]*)");
+ fBot.button(7).click();
+ fBot.comboBox("Set").setSelection("Append with |");
+ fBot.button("Highlight All").click();
+ fBot.button("Next >").click();
+ fBot.button("Finish").click();
+ String xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
+ assertEquals(EXPECTED_TEST_DEFINITION, xmlPart);
+ fBot.list().select(CATEGORY_NAME + " : " + TRACETYPE_NAME);
+ fBot.button("Delete").click();
+ fBot.button("Yes").click();
+ fBot.button("Close").click();
+ xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
+ assertEquals("", xmlPart);
+
+ SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
+ }
+
+ /**
+ * Test to edit a custom txt trace and compare the xml
+ *
+ * @throws IOException
+ * the xml file is not accessible, this is bad
+ * @throws FileNotFoundException
+ * the xml file wasn't written, this is bad
+ */
+ @Test
+ public void testEdit() throws FileNotFoundException, IOException {
+ File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_txt_parsers.xml").toFile();
+ try (FileWriter fw = new FileWriter(xmlFile)) {
+ String xmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<CustomTxtTraceDefinitionList>\n" +
+ "<Definition category=\"Demo Category\" name=\"Demo trace\">\n" +
+ "<TimeStampOutputFormat>sss</TimeStampOutputFormat>\n" +
+ "<InputLine>\n" +
+ "<Cardinality max=\"2147483647\" min=\"0\"/>\n" +
+ "<RegEx>\\s*(\\d*)\\s(.*)</RegEx>\n" +
+ "<InputData action=\"0\" format=\"sss\" name=\"Time Stamp\"/>\n" +
+ "<InputData action=\"0\" name=\"Message\"/>\n" +
+ "</InputLine>\n" +
+ "<OutputColumn name=\"Time Stamp\"/>\n" +
+ "<OutputColumn name=\"Message\"/>\n" +
+ "</Definition>\n" +
+ "<Definition name=\"dmesg\">\n" +
+ "<TimeStampOutputFormat>sssssss.ssssss</TimeStampOutputFormat>\n" +
+ "<InputLine>\n" +
+ "<Cardinality max=\"2147483647\" min=\"0\"/>\n" +
+ "<RegEx>^[([0-9]*\\.[0.9]*)]\\s(.*)</RegEx>\n" +
+ "<InputData action=\"0\" format=\"sssss.sssss\" name=\"Time Stamp\"/>\n" +
+ "<InputData action=\"0\" name=\"Message\"/>\n" +
+ "</InputLine>\n" +
+ "<OutputColumn name=\"Time Stamp\"/>\n" +
+ "<OutputColumn name=\"Message\"/>\n" +
+ "</Definition>\n" +
+ "</CustomTxtTraceDefinitionList>";
+ fw.write(xmlContent);
+ fw.flush();
+ }
+ SWTBotUtils.createProject(PROJECT_NAME);
+ SWTBotView proejctExplorerBot = fBot.viewByTitle("Project Explorer");
+ proejctExplorerBot.show();
+ SWTBotTreeItem treeItem = proejctExplorerBot.bot().tree().getTreeItem(PROJECT_NAME);
+ treeItem.select();
+ treeItem.expand();
+ SWTBotTreeItem treeNode = null;
+ for (String node : treeItem.getNodes()) {
+ if (node.startsWith("Trace")) {
+ treeNode = treeItem.getNode(node);
+ break;
+ }
+
+ }
+ assertNotNull(treeNode);
+ treeNode.contextMenu("Manage Custom Parsers...").click();
+ fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).setFocus();
+ fBot.list().select("Demo Category : Demo trace");
+ fBot.button("Edit...").click();
+
+ fBot.textWithLabel("Category:").setText(CATEGORY_NAME);
+ fBot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
+ fBot.textWithLabel("Time Stamp format:").setText("ss");
+ fBot.comboBox(1).setSelection("Time Stamp");
+ fBot.textWithLabel("format:").setText("ss");
+ fBot.button(2).click();
+ SWTBotTreeItem[] treeItems = fBot.tree().getAllItems();
+ SWTBotTreeItem eventLine[] = new SWTBotTreeItem[2];
+ for (SWTBotTreeItem item : treeItems) {
+ if (item.getText().startsWith("Root Line 1")) {
+ eventLine[0] = item;
+ }
+ if (item.getText().startsWith("Root Line 2")) {
+ eventLine[1] = item;
+ }
+ }
+ treeItems = fBot.tree().getAllItems();
+ assertNotNull(eventLine[0]);
+ assertNotNull(eventLine[1]);
+ fBot.styledText().setText("12 Hello\nWorld\n23 Goodbye\ncruel world");
+ eventLine[0].select();
+ SWTBotUtils.waitForJobs();
+ fBot.textWithLabel("Regular expression:").setText("\\s*(\\d\\d)\\s(.*\\S)");
+ eventLine[1].select();
+ fBot.textWithLabel("Regular expression:").setText("([^0-9]*)");
+ fBot.button(7).click();
+ fBot.comboBox("Set").setSelection("Append with |");
+ fBot.button("Highlight All").click();
+ fBot.button("Next >").click();
+ fBot.button("Finish").click();
+ String xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
+ assertEquals(EXPECTED_TEST_DEFINITION, xmlPart);
+ fBot.list().select(CATEGORY_NAME + " : " + TRACETYPE_NAME);
+ fBot.button("Delete").click();
+ fBot.button("Yes").click();
+ fBot.button("Close").click();
+ xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
+ assertEquals("", xmlPart);
+
+ SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * 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:
+ * Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ui.swtbot.tests.parsers.custom;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Custom XML wizard tests
+ *
+ * This test will help validate the CustomXmlParserInputWizardPage
+ *
+ * @author Matthew Khouzam
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class TestCustomXmlWizard extends AbstractCustomParserWizard {
+
+ private static final String EVENT = "event";
+ private static final String TRACE = "trace";
+ private static final String XML_TRACE1 = "<trace>\n\t<event time=\"100\" msg=\"hello\"/>\n\t<event time=\"200\" msg=\"world\"/></trace>";
+ private static final String MANAGE_CUSTOM_PARSERS_SHELL_TITLE = "Manage Custom Parsers";
+ private static final String PROJECT_NAME = "TestXML";
+ private static final String CATEGORY_NAME = "Test Category";
+ private static final String TRACETYPE_NAME = "Test Trace";
+ private static final String EXPECTED_TEST_DEFINITION = "<Definition category=\"Test Category\" name=\"" + TRACETYPE_NAME + "\">\n" +
+ "<TimeStampOutputFormat>ss</TimeStampOutputFormat>\n" +
+ "<InputElement name=\"trace\">\n" +
+ "<InputElement logentry=\"true\" name=\"event\">\n" +
+ "<InputData action=\"0\" format=\"\" name=\"Ignore\"/>\n" +
+ "<Attribute name=\"msg\">\n" +
+ "<InputData action=\"0\" name=\"msg\"/>\n" +
+ "</Attribute>\n" +
+ "<Attribute name=\"time\">\n" +
+ "<InputData action=\"0\" name=\"time\"/>\n" +
+ "</Attribute>\n" +
+ "</InputElement>\n" +
+ "</InputElement>\n" +
+ "<OutputColumn name=\"msg\"/>\n" +
+ "<OutputColumn name=\"time\"/>\n";
+
+ /**
+ * Test to create a custom XML trace and compare the XML generated
+ *
+ * @throws IOException
+ * the xml file is not accessible, this is bad
+ * @throws FileNotFoundException
+ * the xml file wasn't written, this is bad
+ */
+ @Test
+ public void testNew() throws FileNotFoundException, IOException {
+ File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_xml_parsers.xml").toFile();
+ SWTBotUtils.createProject(PROJECT_NAME);
+ SWTBotView proejctExplorerBot = fBot.viewByTitle("Project Explorer");
+ proejctExplorerBot.show();
+ SWTBotTreeItem treeItem = proejctExplorerBot.bot().tree().getTreeItem(PROJECT_NAME);
+ treeItem.select();
+ treeItem.expand();
+ SWTBotTreeItem treeNode = null;
+ for (String node : treeItem.getNodes()) {
+ if (node.startsWith("Trace")) {
+ treeNode = treeItem.getNode(node);
+ break;
+ }
+
+ }
+ assertNotNull(treeNode);
+ treeNode.contextMenu("Manage Custom Parsers...").click();
+ fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).setFocus();
+ fBot.radio("XML").click();
+ fBot.button("New...").click();
+ fBot.textWithLabel("Category:").setText(CATEGORY_NAME);
+ fBot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
+ fBot.textWithLabel("Time Stamp format:").setText("ss");
+
+ fBot.styledText().setText(XML_TRACE1);
+ fBot.buttonWithTooltip("Feeling lucky").click();
+
+ fBot.tree().getTreeItem(TRACE).getNode(EVENT).select();
+ fBot.checkBox("Log Entry").click();
+ fBot.button("Next >").click();
+ fBot.button("Finish").click();
+
+ String xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
+ assertEquals(EXPECTED_TEST_DEFINITION, xmlPart);
+ fBot.list().select(CATEGORY_NAME + " : " + TRACETYPE_NAME);
+ fBot.button("Delete").click();
+ fBot.button("Yes").click();
+ fBot.button("Close").click();
+ xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
+ assertEquals("", xmlPart);
+
+ SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * 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.tracecompass.tmf.ui.swtbot.tests.perspectives;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * SWTBot test suite
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TracingPerspectiveChecker.class
+})
+public class AllTests {
+}
--- /dev/null
+/*******************************************************************************
+ * 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:
+ * Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ui.swtbot.tests.perspectives;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.AbstractPerspectiveChecker;
+import org.eclipse.tracecompass.tmf.ui.views.TracingPerspectiveFactory;
+import org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramView;
+import org.eclipse.tracecompass.tmf.ui.views.statistics.TmfStatisticsView;
+import org.eclipse.ui.IPageLayout;
+import org.junit.Before;
+
+/**
+ * Tracing perspective view checker
+ *
+ * @author Matthew Khouzam
+ */
+public class TracingPerspectiveChecker extends AbstractPerspectiveChecker {
+
+ /**
+ * Set up arrays for test
+ */
+ @Before
+ public void init() {
+ fPerspectiveId = TracingPerspectiveFactory.ID;
+ fViewIds = new ArrayList<>();
+ fViewIds.addAll(Arrays.asList(new String[] {
+ HistogramView.ID,
+ TmfStatisticsView.ID,
+ // Standard Eclipse views
+ IPageLayout.ID_PROJECT_EXPLORER,
+ IPageLayout.ID_PROP_SHEET,
+ IPageLayout.ID_BOOKMARKS
+ }));
+ }
+
+}
+++ /dev/null
-/*******************************************************************************
- * 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.tracecompass.tmf.ui.swtbot.tests.table;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * SWTBot test suite for testing of the TMF events table.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- CallsiteEventsInTableTest.class,
- CollapseEventsInTableTest.class
-})
-public class AllTests {
-}
+++ /dev/null
-/*******************************************************************************
- * 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.tracecompass.tmf.ui.swtbot.tests.table;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.SimpleLayout;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.bindings.keys.IKeyLookup;
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.tracecompass.internal.tmf.core.Activator;
-import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.SWTBotUtil;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-import org.eclipse.ui.IEditorReference;
-import org.hamcrest.Matcher;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * SWTBot test for testing callsite feature.
- *
- * @author Bernd Hufmann
- */
-@RunWith(SWTBotJunit4ClassRunner.class)
-public class CallsiteEventsInTableTest {
-
- private static final String TRACE_PROJECT_NAME = "test";
- private static final String CALLSITE_TRACE_NAME = "syslog_collapse";
- private static final String CALLSITE_TRACE_PATH = "testfiles/" + CALLSITE_TRACE_NAME;
- private static final String CALLSITE_TRACE_TYPE = "org.eclipse.linuxtools.tmf.tests.stubs.trace.text.testsyslog";
- private static final String SOURCE_FILE_NAME = "SourceFile";
- private static final String SOURCE_FILE_PATH = "testfiles/" + SOURCE_FILE_NAME;
-
- private static File fTestFile = null;
- private static File fSourceFile = null;
-
- private static SWTWorkbenchBot fBot;
-
- /** The Log4j logger instance. */
- private static final Logger fLogger = Logger.getRootLogger();
-
- /**
- * Test Class setup
- */
- @BeforeClass
- public static void init() {
- SWTBotUtil.failIfUIThread();
-
- /* set up test trace*/
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(CALLSITE_TRACE_PATH), null);
- URI uri;
- try {
- uri = FileLocator.toFileURL(location).toURI();
- fTestFile = new File(uri);
- } catch (URISyntaxException | IOException e) {
- e.printStackTrace();
- fail();
- }
-
- assumeTrue(fTestFile.exists());
-
- IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
- defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, "MMM d HH:mm:ss");
- defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NO_FMT);
- TmfTimestampFormat.updateDefaultFormats();
-
- /* Create source file link */
- location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(SOURCE_FILE_PATH), null);
- try {
- uri = FileLocator.toFileURL(location).toURI();
- fSourceFile = new File(uri);
- } catch (URISyntaxException | IOException e) {
- e.printStackTrace();
- fail();
- }
-
- assumeTrue(fSourceFile.exists());
-
-
-
- /* Set up for swtbot */
- SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
- fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
- fBot = new SWTWorkbenchBot();
-
- /* Close welcome view */
- SWTBotUtil.closeView("Welcome", fBot);
-
- /* Switch perspectives */
- SWTBotUtil.switchToTracingPerspective();
-
- /* Finish waiting for eclipse to load */
- SWTBotUtil.waitForJobs();
- }
-
- /**
- * Test class tear down method.
- */
- @AfterClass
- public static void tearDown() {
- /* Set timestamp defaults */
- IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
- defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, ITmfTimePreferencesConstants.TIME_HOUR_FMT);
- defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NANO_FMT);
- TmfTimestampFormat.updateDefaultFormats();
- }
-
- /**
- * Main test case
- */
- @Test
- public void test() {
- SWTBotUtil.createProject(TRACE_PROJECT_NAME);
-
- // Open source file as a unknown trace
- SWTBotUtil.openTrace(TRACE_PROJECT_NAME, fSourceFile.getAbsolutePath(), null);
-
- // Open the actual trace
- SWTBotUtil.openTrace(TRACE_PROJECT_NAME, fTestFile.getAbsolutePath(), CALLSITE_TRACE_TYPE);
- SWTBotEditor editorBot = SWTBotUtil.activateEditor(fBot, fTestFile.getName());
-
- SWTBotTable tableBot = editorBot.bot().table();
-
- // Maximize editor area
- maximizeTable(tableBot);
- tableBot.click(1, 0);
-
- // Open source code location
- SWTBotMenu menuBot = tableBot.contextMenu("Open Source Code");
- menuBot.click();
-
- // Verify that source code was actually opened
- Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(fSourceFile.getName());
- final SWTBotEditor sourceEditorBot = fBot.editor(matcher);
- assertTrue(sourceEditorBot.isActive());
-
- maximizeTable(tableBot);
-
- fBot.closeAllEditors();
- SWTBotUtil.deleteProject(TRACE_PROJECT_NAME, fBot);
- }
-
- private static void maximizeTable(SWTBotTable tableBot) {
- try {
- tableBot.pressShortcut(KeyStroke.getInstance(IKeyLookup.CTRL_NAME + "+"), KeyStroke.getInstance("M"));
- } catch (ParseException e) {
- fail();
- }
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * 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
- * 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.tracecompass.tmf.ui.swtbot.tests.table;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.SimpleLayout;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.bindings.keys.IKeyLookup;
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.tracecompass.internal.tmf.core.Activator;
-import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.SWTBotUtil;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.conditions.ConditionHelpers;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * SWTBot test for testing collapsing feature.
- *
- * @author Bernd Hufmann
- */
-@RunWith(SWTBotJunit4ClassRunner.class)
-public class CollapseEventsInTableTest {
-
- private static final String TRACE_PROJECT_NAME = "test";
- private static final String COLLAPSE_TRACE_NAME = "syslog_collapse";
- private static final String COLLAPSE_TRACE_PATH = "testfiles/" + COLLAPSE_TRACE_NAME;
- private static final String COLLAPSE_TRACE_TYPE = "org.eclipse.linuxtools.tmf.tests.stubs.trace.text.testsyslog";
-
- private static File fTestFile = null;
-
- private static SWTWorkbenchBot fBot;
-
- /** The Log4j logger instance. */
- private static final Logger fLogger = Logger.getRootLogger();
-
- /**
- * Test Class setup
- */
- @BeforeClass
- public static void init() {
- SWTBotUtil.failIfUIThread();
-
- /* set up test trace*/
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(COLLAPSE_TRACE_PATH), null);
- URI uri;
- try {
- uri = FileLocator.toFileURL(location).toURI();
- fTestFile = new File(uri);
- } catch (URISyntaxException | IOException e) {
- e.printStackTrace();
- fail();
- }
-
- assumeTrue(fTestFile.exists());
-
- IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
- defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, "MMM d HH:mm:ss");
- defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NO_FMT);
- TmfTimestampFormat.updateDefaultFormats();
-
- /* Set up for swtbot */
- SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
- fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
- fBot = new SWTWorkbenchBot();
-
- /* Close welcome view */
- SWTBotUtil.closeView("Welcome", fBot);
-
- /* Switch perspectives */
- SWTBotUtil.switchToTracingPerspective();
-
- /* Finish waiting for eclipse to load */
- SWTBotUtil.waitForJobs();
- }
-
- /**
- * Test class tear down method.
- */
- @AfterClass
- public static void tearDown() {
- /* Set timestamp defaults */
- IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
- defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, ITmfTimePreferencesConstants.TIME_HOUR_FMT);
- defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NANO_FMT);
- TmfTimestampFormat.updateDefaultFormats();
- }
-
- /**
- * Main test case
- */
- @Test
- public void test() {
- SWTBotUtil.createProject(TRACE_PROJECT_NAME);
- SWTBotUtil.openTrace(TRACE_PROJECT_NAME, fTestFile.getAbsolutePath(), COLLAPSE_TRACE_TYPE);
- SWTBotEditor editorBot = SWTBotUtil.activateEditor(fBot, fTestFile.getName());
-
- SWTBotTable tableBot = editorBot.bot().table();
-
- /* Maximize editor area */
- maximizeTable(tableBot);
- tableBot.click(1, 0);
-
- /* Collapse Events */
- SWTBotMenu menuBot = tableBot.contextMenu("Collapse Events");
- menuBot.click();
- fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "7/22", 1, 1));
-
- String filterString = tableBot.cell(1, 1);
- assertEquals("filterString", "7/22", filterString);
-
- /* Verify collapsed event */
- filterString = tableBot.cell(7, 0);
- assertEquals("repeatCount", "+14", filterString);
-
- filterString = tableBot.cell(7, 1);
- assertEquals("first timestamp", "Jan 1 06:06:06", filterString);
-
- filterString = tableBot.cell(7, 2);
- assertEquals("type", "Syslog", filterString);
-
- filterString = tableBot.cell(7, 3);
- assertEquals("content", "Timestamp=Jan 1 06:06:06, Host=HostF, Logger=LoggerF, File=SourceFile, Line=9, Message=Message F", filterString);
-
- filterString = tableBot.cell(8, 0);
- assertEquals("repeatCount", "+1", filterString);
-
- filterString = tableBot.cell(8, 1);
- assertEquals("first timestamp (2nd collapse)", "Jan 1 06:06:21", filterString);
-
- filterString = tableBot.cell(8, 3);
- assertEquals("content", "Timestamp=Jan 1 06:06:21, Host=HostF, Logger=LoggerF, File=SourceFile, Line=10, Message=Message D", filterString);
-
- /* Clear Filter */
- menuBot = tableBot.contextMenu("Clear Filters");
- menuBot.click();
- fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "Jan 1 01:01:01", 1, 1));
- assertEquals("timestamp", "Jan 1 01:01:01", tableBot.cell(1, 1));
-
- maximizeTable(tableBot);
-
- fBot.closeAllEditors();
- SWTBotUtil.deleteProject(TRACE_PROJECT_NAME, fBot);
- }
-
- private static void maximizeTable(SWTBotTable tableBot) {
- try {
- tableBot.pressShortcut(KeyStroke.getInstance(IKeyLookup.CTRL_NAME + "+"), KeyStroke.getInstance("M"));
- } catch (ParseException e) {
- fail();
- }
- }
-
-}
--- /dev/null
+/*******************************************************************************
+ * 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.tracecompass.tmf.ui.swtbot.tests.viewers.events;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * SWTBot test suite for testing of the TMF events table.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ CallsiteEventsInTableTest.class,
+ CollapseEventsInTableTest.class
+})
+public class AllTests {
+}
--- /dev/null
+/*******************************************************************************
+ * 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.tracecompass.tmf.ui.swtbot.tests.viewers.events;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.bindings.keys.IKeyLookup;
+import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.bindings.keys.ParseException;
+import org.eclipse.tracecompass.internal.tmf.core.Activator;
+import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.ui.IEditorReference;
+import org.hamcrest.Matcher;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * SWTBot test for testing callsite feature.
+ *
+ * @author Bernd Hufmann
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class CallsiteEventsInTableTest {
+
+ private static final String TRACE_PROJECT_NAME = "test";
+ private static final String CALLSITE_TRACE_NAME = "syslog_collapse";
+ private static final String CALLSITE_TRACE_PATH = "testfiles/" + CALLSITE_TRACE_NAME;
+ private static final String CALLSITE_TRACE_TYPE = "org.eclipse.linuxtools.tmf.tests.stubs.trace.text.testsyslog";
+ private static final String SOURCE_FILE_NAME = "SourceFile";
+ private static final String SOURCE_FILE_PATH = "testfiles/" + SOURCE_FILE_NAME;
+
+ private static File fTestFile = null;
+ private static File fSourceFile = null;
+
+ private static SWTWorkbenchBot fBot;
+
+ /** The Log4j logger instance. */
+ private static final Logger fLogger = Logger.getRootLogger();
+
+ /**
+ * Test Class setup
+ */
+ @BeforeClass
+ public static void init() {
+ SWTBotUtils.failIfUIThread();
+
+ /* set up test trace*/
+ URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(CALLSITE_TRACE_PATH), null);
+ URI uri;
+ try {
+ uri = FileLocator.toFileURL(location).toURI();
+ fTestFile = new File(uri);
+ } catch (URISyntaxException | IOException e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ assumeTrue(fTestFile.exists());
+
+ IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, "MMM d HH:mm:ss");
+ defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NO_FMT);
+ TmfTimestampFormat.updateDefaultFormats();
+
+ /* Create source file link */
+ location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(SOURCE_FILE_PATH), null);
+ try {
+ uri = FileLocator.toFileURL(location).toURI();
+ fSourceFile = new File(uri);
+ } catch (URISyntaxException | IOException e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ assumeTrue(fSourceFile.exists());
+
+
+
+ /* Set up for swtbot */
+ SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
+ fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
+ fBot = new SWTWorkbenchBot();
+
+ /* Close welcome view */
+ SWTBotUtils.closeView("Welcome", fBot);
+
+ /* Switch perspectives */
+ SWTBotUtils.switchToTracingPerspective();
+
+ /* Finish waiting for eclipse to load */
+ SWTBotUtils.waitForJobs();
+ }
+
+ /**
+ * Test class tear down method.
+ */
+ @AfterClass
+ public static void tearDown() {
+ /* Set timestamp defaults */
+ IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, ITmfTimePreferencesConstants.TIME_HOUR_FMT);
+ defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NANO_FMT);
+ TmfTimestampFormat.updateDefaultFormats();
+ }
+
+ /**
+ * Main test case
+ */
+ @Test
+ public void test() {
+ SWTBotUtils.createProject(TRACE_PROJECT_NAME);
+
+ // Open source file as a unknown trace
+ SWTBotUtils.openTrace(TRACE_PROJECT_NAME, fSourceFile.getAbsolutePath(), null);
+
+ // Open the actual trace
+ SWTBotUtils.openTrace(TRACE_PROJECT_NAME, fTestFile.getAbsolutePath(), CALLSITE_TRACE_TYPE);
+ SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName());
+
+ SWTBotTable tableBot = editorBot.bot().table();
+
+ // Maximize editor area
+ maximizeTable(tableBot);
+ tableBot.click(1, 0);
+
+ // Open source code location
+ SWTBotMenu menuBot = tableBot.contextMenu("Open Source Code");
+ menuBot.click();
+
+ // Verify that source code was actually opened
+ Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(fSourceFile.getName());
+ final SWTBotEditor sourceEditorBot = fBot.editor(matcher);
+ assertTrue(sourceEditorBot.isActive());
+
+ maximizeTable(tableBot);
+
+ fBot.closeAllEditors();
+ SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
+ }
+
+ private static void maximizeTable(SWTBotTable tableBot) {
+ try {
+ tableBot.pressShortcut(KeyStroke.getInstance(IKeyLookup.CTRL_NAME + "+"), KeyStroke.getInstance("M"));
+ } catch (ParseException e) {
+ fail();
+ }
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * 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
+ * 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.tracecompass.tmf.ui.swtbot.tests.viewers.events;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.bindings.keys.IKeyLookup;
+import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.bindings.keys.ParseException;
+import org.eclipse.tracecompass.internal.tmf.core.Activator;
+import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * SWTBot test for testing collapsing feature.
+ *
+ * @author Bernd Hufmann
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class CollapseEventsInTableTest {
+
+ private static final String TRACE_PROJECT_NAME = "test";
+ private static final String COLLAPSE_TRACE_NAME = "syslog_collapse";
+ private static final String COLLAPSE_TRACE_PATH = "testfiles/" + COLLAPSE_TRACE_NAME;
+ private static final String COLLAPSE_TRACE_TYPE = "org.eclipse.linuxtools.tmf.tests.stubs.trace.text.testsyslog";
+
+ private static File fTestFile = null;
+
+ private static SWTWorkbenchBot fBot;
+
+ /** The Log4j logger instance. */
+ private static final Logger fLogger = Logger.getRootLogger();
+
+ /**
+ * Test Class setup
+ */
+ @BeforeClass
+ public static void init() {
+ SWTBotUtils.failIfUIThread();
+
+ /* set up test trace*/
+ URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(COLLAPSE_TRACE_PATH), null);
+ URI uri;
+ try {
+ uri = FileLocator.toFileURL(location).toURI();
+ fTestFile = new File(uri);
+ } catch (URISyntaxException | IOException e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ assumeTrue(fTestFile.exists());
+
+ IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, "MMM d HH:mm:ss");
+ defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NO_FMT);
+ TmfTimestampFormat.updateDefaultFormats();
+
+ /* Set up for swtbot */
+ SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
+ fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
+ fBot = new SWTWorkbenchBot();
+
+ /* Close welcome view */
+ SWTBotUtils.closeView("Welcome", fBot);
+
+ /* Switch perspectives */
+ SWTBotUtils.switchToTracingPerspective();
+
+ /* Finish waiting for eclipse to load */
+ SWTBotUtils.waitForJobs();
+ }
+
+ /**
+ * Test class tear down method.
+ */
+ @AfterClass
+ public static void tearDown() {
+ /* Set timestamp defaults */
+ IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, ITmfTimePreferencesConstants.TIME_HOUR_FMT);
+ defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NANO_FMT);
+ TmfTimestampFormat.updateDefaultFormats();
+ }
+
+ /**
+ * Main test case
+ */
+ @Test
+ public void test() {
+ SWTBotUtils.createProject(TRACE_PROJECT_NAME);
+ SWTBotUtils.openTrace(TRACE_PROJECT_NAME, fTestFile.getAbsolutePath(), COLLAPSE_TRACE_TYPE);
+ SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName());
+
+ SWTBotTable tableBot = editorBot.bot().table();
+
+ /* Maximize editor area */
+ maximizeTable(tableBot);
+ tableBot.click(1, 0);
+
+ /* Collapse Events */
+ SWTBotMenu menuBot = tableBot.contextMenu("Collapse Events");
+ menuBot.click();
+ fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "7/22", 1, 1));
+
+ String filterString = tableBot.cell(1, 1);
+ assertEquals("filterString", "7/22", filterString);
+
+ /* Verify collapsed event */
+ filterString = tableBot.cell(7, 0);
+ assertEquals("repeatCount", "+14", filterString);
+
+ filterString = tableBot.cell(7, 1);
+ assertEquals("first timestamp", "Jan 1 06:06:06", filterString);
+
+ filterString = tableBot.cell(7, 2);
+ assertEquals("type", "Syslog", filterString);
+
+ filterString = tableBot.cell(7, 3);
+ assertEquals("content", "Timestamp=Jan 1 06:06:06, Host=HostF, Logger=LoggerF, File=SourceFile, Line=9, Message=Message F", filterString);
+
+ filterString = tableBot.cell(8, 0);
+ assertEquals("repeatCount", "+1", filterString);
+
+ filterString = tableBot.cell(8, 1);
+ assertEquals("first timestamp (2nd collapse)", "Jan 1 06:06:21", filterString);
+
+ filterString = tableBot.cell(8, 3);
+ assertEquals("content", "Timestamp=Jan 1 06:06:21, Host=HostF, Logger=LoggerF, File=SourceFile, Line=10, Message=Message D", filterString);
+
+ /* Clear Filter */
+ menuBot = tableBot.contextMenu("Clear Filters");
+ menuBot.click();
+ fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "Jan 1 01:01:01", 1, 1));
+ assertEquals("timestamp", "Jan 1 01:01:01", tableBot.cell(1, 1));
+
+ maximizeTable(tableBot);
+
+ fBot.closeAllEditors();
+ SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
+ }
+
+ private static void maximizeTable(SWTBotTable tableBot) {
+ try {
+ tableBot.pressShortcut(KeyStroke.getInstance(IKeyLookup.CTRL_NAME + "+"), KeyStroke.getInstance("M"));
+ } catch (ParseException e) {
+ fail();
+ }
+ }
+
+}