tmf: Re-organize the SWTBot test plugin
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 9 Jan 2015 00:15:09 +0000 (19:15 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 12 Jan 2015 21:17:38 +0000 (16:17 -0500)
* Move each test family in packages named similarly to their
  runtime equivalents.
* Move the things meant to be reused by other swtbot test plugins
  in a "shared" folder.
* Simplify the ConditionHelpers class.

Change-Id: I00cce218695d73f02722a14d248b456242d091f7
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/39243
Reviewed-by: Hudson CI
40 files changed:
org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ImportAndReadKernelSmokeTest.java
org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/KernelPerspectiveChecker.java
org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/OpenTraceStressTest.java
org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java
org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/ImportAndReadSmokeTest.java
org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/StandardImportAndReadSmokeTest.java
org.eclipse.tracecompass.tmf.pcap.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/pcap/ui/swtbot/tests/ImportAndReadPcapTest.java
org.eclipse.tracecompass.tmf.pcap.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/pcap/ui/swtbot/tests/NetworkPerspectiveChecker.java
org.eclipse.tracecompass.tmf.ui.swtbot.tests/.classpath
org.eclipse.tracecompass.tmf.ui.swtbot.tests/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.ui.swtbot.tests/build.properties
org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/AbstractPerspectiveChecker.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/ConditionHelpers.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotUtils.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/AbstractCustomParserWizard.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/AbstractPerspectiveChecker.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/AllTmfUISWTBotTests.java
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/SWTBotUtil.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/TestCustomTxtWizard.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/TestCustomXmlWizard.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/TracingPerspectiveChecker.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/ConditionHelpers.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/TableCellFilled.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/TreeItemNodeAvailable.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/TreeNodeAvailable.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/ViewClosed.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/WizardOnPage.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/WizardReady.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/AbstractCustomParserWizard.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/AllTests.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomTxtWizard.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomXmlWizard.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/perspectives/AllTests.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/perspectives/TracingPerspectiveChecker.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/table/AllTests.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/table/CallsiteEventsInTableTest.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/table/CollapseEventsInTableTest.java [deleted file]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/AllTests.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CallsiteEventsInTableTest.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CollapseEventsInTableTest.java [new file with mode: 0644]

index 106b147f340bbcda923881e3122d5445f1accc22..d43f33de900e10f4a6ebb3387fc66c542bd565f3 100644 (file)
@@ -42,8 +42,8 @@ import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
 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;
@@ -81,7 +81,7 @@ public class ImportAndReadKernelSmokeTest {
      */
     @BeforeClass
     public static void init() {
-        SWTBotUtil.failIfUIThread();
+        SWTBotUtils.failIfUIThread();
 
         /* set up for swtbot */
         SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
@@ -98,7 +98,7 @@ public class ImportAndReadKernelSmokeTest {
         /* Switch perspectives */
         switchKernelPerspective();
         /* Finish waiting for eclipse to load */
-        SWTBotUtil.waitForJobs();
+        SWTBotUtils.waitForJobs();
     }
 
     private static void switchKernelPerspective() {
@@ -126,15 +126,15 @@ public class ImportAndReadKernelSmokeTest {
      */
     @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() {
@@ -151,8 +151,8 @@ public class ImportAndReadKernelSmokeTest {
             }
         });
 
-        SWTBotUtil.waitForJobs();
-        SWTBotUtil.delay(1000);
+        SWTBotUtils.waitForJobs();
+        SWTBotUtils.delay(1000);
         assertNotNull(tmfEd);
     }
 
@@ -172,18 +172,18 @@ public class ImportAndReadKernelSmokeTest {
         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);
     }
 
index 7508079ab5b629c1976758cdacd188ed08247bf7..a9ca3f96d63e62feaf94f65b397bc934bcb31704 100644 (file)
@@ -17,9 +17,9 @@ import java.util.Arrays;
 
 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;
index af84f2805e013ba3572cafb71d90cd5e1a502c4e..c7d6d26fceddfbb595f9fbd7fc17bbc533b41e90 100644 (file)
@@ -33,7 +33,7 @@ import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
 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;
@@ -58,7 +58,7 @@ public class OpenTraceStressTest {
      */
     @BeforeClass
     public static void init() {
-        SWTBotUtil.failIfUIThread();
+        SWTBotUtils.failIfUIThread();
 
         /* Set up for swtbot */
         SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
@@ -66,13 +66,13 @@ public class OpenTraceStressTest {
         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();
     }
 
     /**
@@ -80,7 +80,7 @@ public class OpenTraceStressTest {
      */
     @Test
     public void testOpenAndCloseConcurrency() {
-        SWTBotUtil.createProject(TRACE_PROJECT_NAME);
+        SWTBotUtils.createProject(TRACE_PROJECT_NAME);
 
         File fTestFile = new File(CTF_TRACE.getPath());
 
@@ -112,21 +112,21 @@ public class OpenTraceStressTest {
         };
         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) {
index 4ef744761196ddca138aa0bc7cc739a2d1d2ecb3..16f4de2b25ba2ddf4bfb7f8423d45bfdd3f3a276 100644 (file)
@@ -42,8 +42,8 @@ import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
 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;
@@ -82,25 +82,25 @@ public abstract class AbstractImportAndReadSmokeTest {
     @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();
@@ -128,7 +128,7 @@ public abstract class AbstractImportAndReadSmokeTest {
         text.setText(getProjectName());
 
         fBot.button("Finish").click();
-        SWTBotUtil.waitForJobs();
+        SWTBotUtils.waitForJobs();
     }
 
     /**
@@ -139,7 +139,7 @@ public abstract class AbstractImportAndReadSmokeTest {
         final SWTBotButton finishButton = fBot.button("Finish");
         finishButton.click();
         fBot.waitUntil(Conditions.shellCloses(shell));
-        SWTBotUtil.waitForJobs();
+        SWTBotUtils.waitForJobs();
     }
 
     /**
@@ -180,8 +180,8 @@ public abstract class AbstractImportAndReadSmokeTest {
             }
         });
 
-        SWTBotUtil.waitForJobs();
-        SWTBotUtil.delay(1000);
+        SWTBotUtils.waitForJobs();
+        SWTBotUtils.delay(1000);
 
         final CtfTmfEvent desiredEvent2 = getEvent(10000);
         SWTBotView hvBot = fBot.viewById(HistogramView.ID);
@@ -195,18 +195,18 @@ public abstract class AbstractImportAndReadSmokeTest {
         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);
     }
 
index 44d5023fa36c7a9270cf6d08be9940a3705e87fc..84b935bbcb4512b2c6b397924f26ed7b84a3c777 100644 (file)
@@ -30,8 +30,8 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 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;
@@ -61,14 +61,14 @@ public class ImportAndReadSmokeTest extends AbstractImportAndReadSmokeTest {
         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() {
index 238ea5179b12fe6265c3f467f7a400c9c6e3a38a..380482add140d4af8919d8b9167649b12a1b1090 100644 (file)
@@ -49,8 +49,8 @@ import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
 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;
@@ -150,14 +150,14 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         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) {
index 022bfd31b7aa1194c75dd0c0934e18c80446e66b..f8712dd1d601af8ba9f7fb313e68292d014b8ca5 100644 (file)
@@ -49,8 +49,8 @@ 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.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;
@@ -85,7 +85,7 @@ public class ImportAndReadPcapTest {
     @BeforeClass
     public static void init() {
 
-        SWTBotUtil.failIfUIThread();
+        SWTBotUtils.failIfUIThread();
 
         /* set up for swtbot */
         SWTBotPreferences.TIMEOUT = 300000; /* 300 second timeout */
@@ -102,7 +102,7 @@ public class ImportAndReadPcapTest {
         /* Switch perspectives */
         switchNetworkPerspective();
         /* Finish waiting for eclipse to load */
-        SWTBotUtil.waitForJobs();
+        SWTBotUtils.waitForJobs();
     }
 
     private static void switchNetworkPerspective() {
@@ -131,13 +131,13 @@ public class ImportAndReadPcapTest {
     @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) {
@@ -148,11 +148,11 @@ public class ImportAndReadPcapTest {
         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);
 
     }
 
@@ -176,8 +176,8 @@ public class ImportAndReadPcapTest {
             fail(exception[0].getMessage());
         }
 
-        SWTBotUtil.delay(1000);
-        SWTBotUtil.waitForJobs();
+        SWTBotUtils.delay(1000);
+        SWTBotUtils.waitForJobs();
     }
 
     private void openEditor() {
@@ -209,8 +209,8 @@ public class ImportAndReadPcapTest {
             }
         });
 
-        SWTBotUtil.waitForJobs();
-        SWTBotUtil.delay(1000);
+        SWTBotUtils.waitForJobs();
+        SWTBotUtils.delay(1000);
         assertNotNull(tmfEd);
     }
 
index 61fffc318ae0c069621004763f8cb572d3f2861a..aaf12de88f736673ae50bb4bf4ad85ac30c1540c 100644 (file)
@@ -17,7 +17,7 @@ import java.util.Arrays;
 
 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;
index 098194ca4b7d8f45177f94e735506ae3a26b5c94..baa43a1105f19ff74db290ec62f28f441f6499a4 100644 (file)
@@ -3,5 +3,6 @@
        <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>
index 98f1a6d0dbc11fb8e7b2b11ed9eb1bb407ed7639..009f92b6d4f2e2250df2b8c8dd5f087c3450722e 100644 (file)
@@ -7,8 +7,6 @@ Bundle-Localization: plugin
 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,
@@ -32,3 +30,5 @@ Import-Package: org.apache.log4j,
  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
index f7a0b9854edfa67ce606de3a44afb7246d144b9a..e27cd9217b9c622f70bb34b42940fd3c9a8ad44e 100644 (file)
@@ -10,7 +10,8 @@
 #     Ericsson - Initial API and implementation
 ###############################################################################
 
-source.. = src/
+source.. = src/,\
+           shared/
 output.. = bin/
 bin.includes = META-INF/,\
                .,\
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/AbstractPerspectiveChecker.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/AbstractPerspectiveChecker.java
new file mode 100644 (file)
index 0000000..493c607
--- /dev/null
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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()));
+        }
+    }
+
+}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/ConditionHelpers.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/ConditionHelpers.java
new file mode 100644 (file)
index 0000000..436f598
--- /dev/null
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * 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
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotUtils.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotUtils.java
new file mode 100644 (file)
index 0000000..f659ce9
--- /dev/null
@@ -0,0 +1,367 @@
+/*******************************************************************************
+ * 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;
+    }
+}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/AbstractCustomParserWizard.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/AbstractCustomParserWizard.java
deleted file mode 100644 (file)
index ca52225..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * 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
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/AbstractPerspectiveChecker.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/AbstractPerspectiveChecker.java
deleted file mode 100644 (file)
index ae23a4c..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * 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()));
-        }
-    }
-
-}
index 9c3e3b64c7d6acb1b96aeb98effac47dc5d8e83f..d00aa89b629d4820dc1d36c21cdb34f159967ae3 100644 (file)
@@ -22,10 +22,9 @@ import org.junit.runners.Suite;
  */
 @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 {
 }
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/SWTBotUtil.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/SWTBotUtil.java
deleted file mode 100644 (file)
index 439b7c5..0000000
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * 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;
-    }
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/TestCustomTxtWizard.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/TestCustomTxtWizard.java
deleted file mode 100644 (file)
index c912355..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * 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);
-    }
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/TestCustomXmlWizard.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/TestCustomXmlWizard.java
deleted file mode 100644 (file)
index f3abde8..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * 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);
-    }
-
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/TracingPerspectiveChecker.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/TracingPerspectiveChecker.java
deleted file mode 100644 (file)
index 8d5e58f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * 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
-        }));
-    }
-
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/ConditionHelpers.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/ConditionHelpers.java
deleted file mode 100644 (file)
index 83a6042..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * 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);
-    }
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/TableCellFilled.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/TableCellFilled.java
deleted file mode 100644 (file)
index 3ebc1b4..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * 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;
-    }
-
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/TreeItemNodeAvailable.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/TreeItemNodeAvailable.java
deleted file mode 100644 (file)
index fdf2e9c..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * 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;
-    }
-
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/TreeNodeAvailable.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/TreeNodeAvailable.java
deleted file mode 100644 (file)
index 6cd0219..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * 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;
-    }
-
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/ViewClosed.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/ViewClosed.java
deleted file mode 100644 (file)
index 2b38e2b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * 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;
-    }
-
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/WizardOnPage.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/WizardOnPage.java
deleted file mode 100644 (file)
index 03eed89..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * 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;
-    }
-
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/WizardReady.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/conditions/WizardReady.java
deleted file mode 100644 (file)
index 6cdb367..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * 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;
-    }
-
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/AbstractCustomParserWizard.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/AbstractCustomParserWizard.java
new file mode 100644 (file)
index 0000000..7c05dbf
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/AllTests.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/AllTests.java
new file mode 100644 (file)
index 0000000..cca7f79
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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 {
+}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomTxtWizard.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomTxtWizard.java
new file mode 100644 (file)
index 0000000..fc97524
--- /dev/null
@@ -0,0 +1,262 @@
+/*******************************************************************************
+ * 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);
+    }
+}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomXmlWizard.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomXmlWizard.java
new file mode 100644 (file)
index 0000000..f855145
--- /dev/null
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * 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);
+    }
+
+}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/perspectives/AllTests.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/perspectives/AllTests.java
new file mode 100644 (file)
index 0000000..b2977b9
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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 {
+}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/perspectives/TracingPerspectiveChecker.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/perspectives/TracingPerspectiveChecker.java
new file mode 100644 (file)
index 0000000..cf594dd
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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
+        }));
+    }
+
+}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/table/AllTests.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/table/AllTests.java
deleted file mode 100644 (file)
index f4dcd8b..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * 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 {
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/table/CallsiteEventsInTableTest.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/table/CallsiteEventsInTableTest.java
deleted file mode 100644 (file)
index 9598ee3..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * 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();
-        }
-    }
-
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/table/CollapseEventsInTableTest.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/table/CollapseEventsInTableTest.java
deleted file mode 100644 (file)
index d9d3fc3..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * 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();
-        }
-    }
-
-}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/AllTests.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/AllTests.java
new file mode 100644 (file)
index 0000000..11e22cb
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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 {
+}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CallsiteEventsInTableTest.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CallsiteEventsInTableTest.java
new file mode 100644 (file)
index 0000000..3039572
--- /dev/null
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * 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();
+        }
+    }
+
+}
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CollapseEventsInTableTest.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CollapseEventsInTableTest.java
new file mode 100644 (file)
index 0000000..8079d24
--- /dev/null
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * 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();
+        }
+    }
+
+}
This page took 0.077999 seconds and 5 git commands to generate.