Upgrade jarsigner to final 1.1.2 release
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests / src / org / eclipse / tracecompass / lttng2 / kernel / ui / swtbot / tests / ImportAndReadKernelSmokeTest.java
index d43f33de900e10f4a6ebb3387fc66c542bd565f3..c71f7a0f5719dced19bee2f7385d9fc22d36eac2 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 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
@@ -9,19 +9,15 @@
  * Contributors:
  *   Matthew Khouzam - Initial API and implementation
  *   Marc-Andre Laperle
- *   Patrick Tasse - Add support for folder elements
+ *   Patrick Tasse - Extract base class from ImportAndReadKernelSmokeTest
  *******************************************************************************/
 
 package org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests;
 
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
 
 import java.util.List;
 
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.SimpleLayout;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
@@ -29,20 +25,17 @@ import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
 import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
 import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.results.BoolResult;
 import org.eclipse.swtbot.swt.finder.results.VoidResult;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
 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.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.signal.TmfTimeSynchSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
 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.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;
@@ -50,9 +43,7 @@ import org.eclipse.ui.IEditorReference;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IViewReference;
 import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.WorkbenchException;
 import org.hamcrest.Matcher;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -62,87 +53,23 @@ import org.junit.runner.RunWith;
  * @author Matthew Khouzam
  */
 @RunWith(SWTBotJunit4ClassRunner.class)
-public class ImportAndReadKernelSmokeTest {
+public class ImportAndReadKernelSmokeTest extends KernelTest {
 
-    private static final String TRACE_TYPE = "org.eclipse.linuxtools.lttng2.kernel.tracetype";
-    private static final String KERNEL_PERSPECTIVE_ID = "org.eclipse.linuxtools.lttng2.kernel.ui.perspective";
-    private static final String TRACE_PROJECT_NAME = "test";
     private static final CtfTmfTestTrace CTT = CtfTmfTestTrace.SYNTHETIC_TRACE;
 
-    private static SWTWorkbenchBot fBot;
     private ITmfEvent fDesired1;
     private ITmfEvent fDesired2;
 
-    /** The Log4j logger instance. */
-    private static final Logger fLogger = Logger.getRootLogger();
-
-    /**
-     * Test Class setup
-     */
-    @BeforeClass
-    public static void init() {
-        SWTBotUtils.failIfUIThread();
-
-        /* set up for swtbot */
-        SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
-        fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
-        fBot = new SWTWorkbenchBot();
-
-        final List<SWTBotView> openViews = fBot.views();
-        for (SWTBotView view : openViews) {
-            if (view.getTitle().equals("Welcome")) {
-                view.close();
-                fBot.waitUntil(ConditionHelpers.ViewIsClosed(view));
-            }
-        }
-        /* Switch perspectives */
-        switchKernelPerspective();
-        /* Finish waiting for eclipse to load */
-        SWTBotUtils.waitForJobs();
-    }
-
-    private static void switchKernelPerspective() {
-        final Exception retE[] = new Exception[1];
-        if (!UIThreadRunnable.syncExec(new BoolResult() {
-            @Override
-            public Boolean run() {
-                try {
-                    PlatformUI.getWorkbench().showPerspective(KERNEL_PERSPECTIVE_ID,
-                            PlatformUI.getWorkbench().getActiveWorkbenchWindow());
-                } catch (WorkbenchException e) {
-                    retE[0] = e;
-                    return false;
-                }
-                return true;
-            }
-        })) {
-            fail(retE[0].getMessage());
-        }
-
-    }
-
     /**
      * Main test case
      */
     @Test
     public void test() {
-        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();
-        SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
-    }
-
-    private void openEditor() {
         Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(CTT.getTrace().getName());
         IEditorPart iep = fBot.editor(matcher).getReference().getEditor(true);
+        final TmfEventsEditor tmfEd = (TmfEventsEditor) iep;
         fDesired1 = getEvent(100);
         fDesired2 = getEvent(10000);
-        final TmfEventsEditor tmfEd = (TmfEventsEditor) iep;
         UIThreadRunnable.syncExec(new VoidResult() {
             @Override
             public void run() {
@@ -150,10 +77,9 @@ public class ImportAndReadKernelSmokeTest {
                 tmfEd.selectionChanged(new SelectionChangedEvent(tmfEd, new StructuredSelection(fDesired1)));
             }
         });
-
-        SWTBotUtils.waitForJobs();
-        SWTBotUtils.delay(1000);
-        assertNotNull(tmfEd);
+        testHV(getViewPart("Histogram"));
+        testCFV((ControlFlowView) getViewPart("Control Flow"));
+        testRV((ResourcesView) getViewPart("Resources"));
     }
 
     private static void testCFV(ControlFlowView vp) {
@@ -169,18 +95,18 @@ public class ImportAndReadKernelSmokeTest {
             }
         }
         HistogramView hv = (HistogramView) vp;
-        final TmfTimeSynchSignal signal = new TmfTimeSynchSignal(hv, fDesired1.getTimestamp());
-        final TmfTimeSynchSignal signal2 = new TmfTimeSynchSignal(hv, fDesired2.getTimestamp());
+        final TmfSelectionRangeUpdatedSignal signal = new TmfSelectionRangeUpdatedSignal(hv, fDesired1.getTimestamp());
+        final TmfSelectionRangeUpdatedSignal signal2 = new TmfSelectionRangeUpdatedSignal(hv, fDesired2.getTimestamp());
         hv.updateTimeRange(100000);
         SWTBotUtils.waitForJobs();
-        hv.currentTimeUpdated(signal);
+        hv.selectionRangeUpdated(signal);
         hv.broadcast(signal);
         SWTBotUtils.waitForJobs();
         SWTBotUtils.delay(1000);
 
         hv.updateTimeRange(1000000000);
         SWTBotUtils.waitForJobs();
-        hv.currentTimeUpdated(signal2);
+        hv.selectionRangeUpdated(signal2);
         hv.broadcast(signal2);
         SWTBotUtils.waitForJobs();
         SWTBotUtils.delay(1000);
This page took 0.027702 seconds and 5 git commands to generate.