lttng: Stabilize CriticalPathTest
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tue, 28 Jun 2016 18:11:24 +0000 (14:11 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Wed, 29 Jun 2016 18:03:58 +0000 (14:03 -0400)
To reproduce the issue:
Inside CriticalPathView.CriticalPathContentProvider.BuildThread.run()
add a Thread.sleep(5000) just before the refresh() call.

It fails because we get all the tree items of the Critical Path view
before the algorithm and the redrawing is done. Since not all of this
process is done in a job, the waitForJobs is not sufficient. Instead,
wait for the UI to update in the state we want to "assert" on.

Bug: 496588
Change-Id: I2617b017f1d94f000600cd2f25ccce98b3cfe5be
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/76153
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java

index a70d84063df7047c3444211260b1beee5e224a9b..4e96eda888e78d643ca7e42d5388c3755ad83a01 100644 (file)
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
 import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -97,8 +98,20 @@ public class CriticalPathTest extends KernelTestBase {
         SWTBotMenu menu = item.contextMenu("Follow " + PROCESS + "/" + TID);
         assertEquals("Follow " + PROCESS + "/" + TID, menu.getText());
         menu.click();
-        SWTBotUtils.waitForJobs();
-        allItems = treeCp.getAllItems();
-        assertEquals("[" + PROCESS + "," + TID + "]", allItems[0].getNode(0).getText());
+        fBot.waitUntil(new DefaultCondition() {
+
+            private final String EXPECTED_TREE_TEXT = "[" + PROCESS + "," + TID + "]";
+
+            @Override
+            public boolean test() throws Exception {
+                SWTBotTreeItem[] items = treeCp.getAllItems();
+                return EXPECTED_TREE_TEXT.equals(items[0].getNode(0).getText());
+            }
+
+            @Override
+            public String getFailureMessage() {
+                return "Could not find " + EXPECTED_TREE_TEXT + " in Critical Path view";
+            }
+        });
     }
 }
This page took 0.027518 seconds and 5 git commands to generate.