Try to fix ControlFlowView tests on Windows

Change-Id: Ie745e6132804d6a09d206ccbd6a50c7895c8e805
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java
index 20b32ba..3c31359 100644
--- a/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java
+++ b/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java
@@ -18,8 +18,9 @@
 
 import java.util.List;
 
+import org.apache.log4j.ConsoleAppender;
 import org.apache.log4j.Logger;
-import org.apache.log4j.varia.NullAppender;
+import org.apache.log4j.SimpleLayout;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
@@ -88,7 +89,7 @@
         /* set up for swtbot */
         SWTBotPreferences.TIMEOUT = 50000; /* 50 second timeout */
         fLogger.removeAllAppenders();
-        fLogger.addAppender(new NullAppender());
+        fLogger.addAppender(new ConsoleAppender(new SimpleLayout()));
         fBot = new SWTWorkbenchBot();
 
         SWTBotUtils.closeView("welcome", fBot);
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java
index dd96180..4abad94 100644
--- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java
+++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java
@@ -14,6 +14,7 @@
 
 import static org.junit.Assert.assertTrue;
 
+import java.util.Iterator;
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNull;
@@ -35,8 +36,11 @@
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;
+import org.eclipse.ui.IWorkbenchPart;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -79,13 +83,19 @@
 
     @Test
     public void testBug() {
-        testToolBarFollowCPUForwardBackward();
-        after();
-        before();
-        testKeyboardLeftRight();
-        after();
-        before();
-        testToolBarSelectNextPreviousEvent();
+        for (int i = 0; i < 30; i++) {
+            before();
+            testToolBarFollowCPUForwardBackward();
+            after();
+            before();
+            testKeyboardLeftRight();
+            after();
+            before();
+            testToolBarSelectNextPreviousEvent();
+            after();
+            System.out.println("testBug " + i);
+        }
+
     }
 
     /**
@@ -115,54 +125,94 @@
             }
         });
 
+//        fBot.waitUntil(new ZoomCondition(timegraph));
+
         /* press ARROW_RIGHT 3 times */
         KEYBOARD.pressShortcut(Keystrokes.RIGHT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME1.getValue(), TID1_TIME2.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.RIGHT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME2.getValue(), TID1_TIME3.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.RIGHT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME3)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME3));
 
         /* press Shift-ARROW_RIGHT 3 times */
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME3.getValue(), TID1_TIME4.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.RIGHT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME4.getValue(), TID1_TIME5.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.RIGHT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME5.getValue(), TID1_TIME6.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.RIGHT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME6)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME6));
 
         /* press Shift-ARROW_LEFT 4 times */
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.LEFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME4.getValue(), TID1_TIME5.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.LEFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME3.getValue(), TID1_TIME4.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.LEFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME2.getValue(), TID1_TIME3.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.LEFT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME2)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME2));
 
         /* press ARROW_RIGHT 2 times */
         KEYBOARD.pressShortcut(Keystrokes.RIGHT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME3.getValue(), TID1_TIME4.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.RIGHT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME4)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME4));
 
         /* press Shift-ARROW_LEFT 3 times */
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.LEFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME2.getValue(), TID1_TIME3.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.LEFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME1.getValue(), TID1_TIME2.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.LEFT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME1)));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME1));
 
         /* press Shift-ARROW_RIGHT 4 times */
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME1.getValue(), TID1_TIME2.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.RIGHT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME2.getValue(), TID1_TIME3.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.RIGHT);
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME3.getValue(), TID1_TIME4.getValue()));
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.RIGHT);
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME4.getValue(), TID1_TIME5.getValue()));
         KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.RIGHT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME5)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME5));
 
         /* press ARROW_LEFT 5 times */
         KEYBOARD.pressShortcut(Keystrokes.LEFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME3.getValue(), TID1_TIME4.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.LEFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME2.getValue(), TID1_TIME3.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.LEFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME1.getValue(), TID1_TIME2.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.LEFT);
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         KEYBOARD.pressShortcut(Keystrokes.LEFT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(START_TIME));
@@ -195,54 +245,91 @@
             }
         });
 
+//        fBot.waitUntil(new ZoomCondition(timegraph));
+
         /* click "Select Next Event" 3 times */
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click();
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME1.getValue(), TID1_TIME2.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click();
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME2.getValue(), TID1_TIME3.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click();
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME3)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME3));
 
         /* shift-click "Select Next Event" 3 times */
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME3.getValue(), TID1_TIME4.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(SWT.SHIFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME4.getValue(), TID1_TIME5.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(SWT.SHIFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME5.getValue(), TID1_TIME6.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(SWT.SHIFT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME6)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME6));
 
         /* shift-click "Select Previous Event" 4 times */
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(SWT.SHIFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME4.getValue(), TID1_TIME5.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(SWT.SHIFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME3.getValue(), TID1_TIME4.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(SWT.SHIFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME2.getValue(), TID1_TIME3.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(SWT.SHIFT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME2)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME2));
 
         /* click "Select Next Event" 2 times */
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click();
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME3.getValue(), TID1_TIME4.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click();
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME4)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME4));
 
         /* shift-click "Select Previous Event" 3 times */
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(SWT.SHIFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME2.getValue(), TID1_TIME3.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(SWT.SHIFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME1.getValue(), TID1_TIME2.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(SWT.SHIFT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME1)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME1));
 
         /* shift-click "Select Next Event" 4 times */
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(SWT.SHIFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME2.getValue(), TID1_TIME3.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(SWT.SHIFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME3.getValue(), TID1_TIME4.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(SWT.SHIFT);
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME4.getValue(), TID1_TIME5.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(SWT.SHIFT);
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME5)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME5));
 
         /* click "Select Previous Event" 5 times */
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click();
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME3.getValue(), TID1_TIME4.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click();
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME2.getValue(), TID1_TIME3.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click();
+        fBot.waitUntil(new TimeEventCondition(timegraph, TID1_TIME1.getValue(), TID1_TIME2.getValue()));
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click();
+        fBot.waitUntil(new ViewDirtyCondition(), 30000000);
         fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click();
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(START_TIME));
@@ -349,4 +436,82 @@
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME)));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(START_TIME));
     }
+
+//    private static class ZoomCondition extends DefaultCondition  {
+//
+//        private TimeGraphControl timegraph;
+//
+//        public ZoomCondition(TimeGraphControl timegraph) {
+//            super();
+//            this.timegraph = timegraph;
+//        }
+//
+//        @Override
+//        public boolean test() throws Exception {
+//            Iterator<ITimeEvent> iter = timegraph.getSelectedTrace().getTimeEventsIterator();
+//            int count = 0;
+//            ITimeEvent event = null;
+//            while (iter.hasNext() && count++ < 6) {
+//                event = iter.next();
+//                System.out.println(count+":"+event.getTime());
+//            }
+//            if (count == 6 && event != null && event.getTime() == TID1_TIME5.getValue()) {
+//                return true;
+//            }
+//            return false;
+//        }
+//
+//        @Override
+//        public String getFailureMessage() {
+//            return "Time Event not found";
+//        }
+//    }
+
+    private static class TimeEventCondition extends DefaultCondition  {
+
+        private TimeGraphControl timegraph;
+        private long fEventEnd;
+        private long fEventStart;
+
+        public TimeEventCondition(TimeGraphControl timegraph, long eventStart, long eventEnd) {
+            super();
+            this.timegraph = timegraph;
+            fEventStart = eventStart;
+            fEventEnd = eventEnd;
+        }
+
+        @Override
+        public boolean test() throws Exception {
+            Iterator<ITimeEvent> iter = timegraph.getSelectedTrace().getTimeEventsIterator();
+            ITimeEvent event = null;
+            while (iter.hasNext()) {
+                event = iter.next();
+                if (event != null && event.getTime() == fEventStart && event.getTime() + event.getDuration() == fEventEnd) {
+                    System.out.println("found " + fEventStart  + "-" + fEventEnd);
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        @Override
+        public String getFailureMessage() {
+            return "Time Event not found";
+        }
+    }
+
+    private class ViewDirtyCondition extends DefaultCondition  {
+
+        @Override
+        public boolean test() throws Exception {
+            IWorkbenchPart part = fViewBot.getViewReference().getPart(false);
+            AbstractTimeGraphView view = (AbstractTimeGraphView) part;
+            return !view.isDirty();
+        }
+
+        @Override
+        public String getFailureMessage() {
+            return "View is dirty";
+        }
+    }
 }
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/KernelTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/KernelTest.java
index 082d1ef..6ed759b 100644
--- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/KernelTest.java
+++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/KernelTest.java
@@ -18,9 +18,6 @@
 
 import java.util.List;
 
-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.eclipse.finder.widgets.SWTBotView;
 import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
@@ -55,7 +52,7 @@
     protected static SWTWorkbenchBot fBot;
 
     /** The Log4j logger instance. */
-    private static final Logger fLogger = Logger.getRootLogger();
+//    private static final Logger fLogger = Logger.getRootLogger();
 
     /**
      * Before Class
@@ -67,9 +64,9 @@
         /* set up for swtbot */
         SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
         SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
-        SWTBotPreferences.PLAYBACK_DELAY = 200;
-        fLogger.removeAllAppenders();
-        fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
+//        SWTBotPreferences.PLAYBACK_DELAY = 200;
+//        fLogger.removeAllAppenders();
+//        fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
         fBot = new SWTWorkbenchBot();
 
         final List<SWTBotView> openViews = fBot.views();
@@ -92,7 +89,7 @@
     @AfterClass
     public static void afterClass() {
         SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
-        fLogger.removeAllAppenders();
+//        fLogger.removeAllAppenders();
     }
 
     private static void switchKernelPerspective() {
diff --git a/releng/org.eclipse.tracecompass.alltests/.settings/org.eclipse.jdt.core.prefs b/releng/org.eclipse.tracecompass.alltests/.settings/org.eclipse.jdt.core.prefs
index 0409c61..b37d41e 100644
--- a/releng/org.eclipse.tracecompass.alltests/.settings/org.eclipse.jdt.core.prefs
+++ b/releng/org.eclipse.tracecompass.alltests/.settings/org.eclipse.jdt.core.prefs
@@ -31,7 +31,7 @@
 org.eclipse.jdt.core.compiler.problem.deprecation=error
 org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
 org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=error
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
 org.eclipse.jdt.core.compiler.problem.emptyStatement=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
 org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=error
@@ -40,7 +40,7 @@
 org.eclipse.jdt.core.compiler.problem.fieldHiding=error
 org.eclipse.jdt.core.compiler.problem.finalParameterBound=error
 org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
 org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
 org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
 org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
@@ -108,6 +108,7 @@
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
 org.eclipse.jdt.core.compiler.problem.unusedImport=error
 org.eclipse.jdt.core.compiler.problem.unusedLabel=error
 org.eclipse.jdt.core.compiler.problem.unusedLocal=error
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CallsiteEventsInTableTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CallsiteEventsInTableTest.java
index 90bb260..e057ac2 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CallsiteEventsInTableTest.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CallsiteEventsInTableTest.java
@@ -76,6 +76,7 @@
      */
     @BeforeClass
     public static void init() {
+        SWTBotUtils.delay(30000);
         SWTBotUtils.failIfUIThread();
 
         /* set up test trace*/
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java
index 9e5dfda..c947ae6 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java
@@ -104,6 +104,12 @@
     /** The timegraph wrapper */
     private ITimeGraphWrapper fTimeGraphWrapper;
 
+    private int fDirty;
+
+    public boolean isDirty() {
+        return fDirty > 0;
+    }
+
     /** The selected trace */
     private ITmfTrace fTrace;
 
@@ -459,6 +465,7 @@
             fMonitor.setCanceled(true);
         }
     }
+    private static int fZoomThreadCount = 0;
 
     private class ZoomThread extends Thread {
         private final @NonNull List<TimeGraphEntry> fZoomEntryList;
@@ -466,9 +473,15 @@
         private final long fZoomEndTime;
         private final long fResolution;
         private final @NonNull  IProgressMonitor fMonitor;
+        private int fZoomThreadId = 0;
+        private boolean fStarted = false;
 
         public ZoomThread(@NonNull List<TimeGraphEntry> entryList, long startTime, long endTime, String name) {
             super(name + " zoom"); //$NON-NLS-1$
+            synchronized (ZoomThread.class) {
+                fZoomThreadCount++;
+                fZoomThreadId = fZoomThreadCount;
+            }
             fZoomEntryList = entryList;
             fZoomStartTime = startTime;
             fZoomEndTime = endTime;
@@ -478,20 +491,37 @@
 
         @Override
         public void run() {
-            for (TimeGraphEntry entry : fZoomEntryList) {
-                if (fMonitor.isCanceled()) {
-                    return;
+            if (!fStarted) {
+                fStarted = true;
+                synchronized (ZoomThread.class) {
+                    fDirty++;
+                    System.out.println("zoom thread start " + fZoomThreadId + "(" + fDirty + " dirty)");
                 }
-                if (entry == null) {
-                    break;
-                }
-                zoom(entry, fMonitor);
+            } else {
+                System.out.println();
             }
-            /* Refresh the arrows when zooming */
-            List<ILinkEvent> events = getLinkList(fZoomStartTime, fZoomEndTime, fResolution, fMonitor);
-            if (events != null) {
-                fTimeGraphWrapper.getTimeGraphViewer().setLinks(events);
-                redraw();
+            try {
+                for (TimeGraphEntry entry : fZoomEntryList) {
+                    if (fMonitor.isCanceled()) {
+                        return;
+                    }
+                    if (entry == null) {
+                        break;
+                    }
+                    zoom(entry, fMonitor);
+                }
+                /* Refresh the arrows when zooming */
+                List<ILinkEvent> events = getLinkList(fZoomStartTime, fZoomEndTime, fResolution, fMonitor);
+                if (events != null) {
+                    fTimeGraphWrapper.getTimeGraphViewer().setLinks(events);
+                    redraw();
+                }
+                synchronized (ZoomThread.class) {
+                    fDirty--;
+                    System.out.println("zoom thread end " + fZoomThreadId + "(" + fDirty + " dirty)");
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
             }
         }
 
@@ -516,6 +546,7 @@
         }
 
         public void cancel() {
+            System.out.println("cancel " + fZoomThreadId);
             fMonitor.setCanceled(true);
         }
     }
@@ -539,6 +570,7 @@
      */
     public AbstractTimeGraphView(String id, TimeGraphPresentationProvider pres) {
         super(id);
+        fDirty = 0;
         fPresentation = pres;
         fDisplayWidth = Display.getDefault().getBounds().width;
     }
@@ -847,6 +879,7 @@
 
     @Override
     public void createPartControl(Composite parent) {
+        fDirty = 0;
         super.createPartControl(parent);
         if (fColumns == null || fLabelProvider == null) {
             fTimeGraphWrapper = new TimeGraphViewerWrapper(parent, SWT.NONE);
@@ -1188,6 +1221,7 @@
                 }
                 if (fEntryList != fTimeGraphWrapper.getInput()) {
                     fTimeGraphWrapper.setInput(fEntryList);
+//                    fTimeGraphWrapper.getTimeGraphViewer().setLinks(null);
                 } else {
                     fTimeGraphWrapper.refresh();
                 }
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphViewer.java
index bd6fed8..62b5866 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphViewer.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphViewer.java
@@ -901,7 +901,9 @@
      * @since 1.0
      */
     public void selectNextEvent(boolean extend) {
+        System.out.println("selectNextEvent before ("+extend+") "+getSelectionBegin()+"-"+getSelectionEnd()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         fTimeGraphCtrl.selectNextEvent(extend);
+        System.out.println("selectNextEvent after  ("+extend+") "+getSelectionBegin()+"-"+getSelectionEnd()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         adjustVerticalScrollBar();
     }
 
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
index af63f1d..4c02f5f 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
@@ -1872,7 +1872,9 @@
             selectPrevEvent(extend);
         } else if (SWT.ARROW_RIGHT == e.keyCode && fDragState == DRAG_NONE) {
             boolean extend = (e.stateMask & SWT.SHIFT) != 0;
+            System.out.println("ARROW_RIGHT before ("+extend+") "+fTimeProvider.getSelectionBegin()+"-"+fTimeProvider.getSelectionEnd()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
             selectNextEvent(extend);
+            System.out.println("ARROW_RIGHT after  ("+extend+") "+fTimeProvider.getSelectionBegin()+"-"+fTimeProvider.getSelectionEnd()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         } else if (SWT.PAGE_DOWN == e.keyCode) {
             int page = countPerPage();
             idx = getSelectedIndex();