From 2fbba798d35c546212189d546d3123b6b7b91110 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Tue, 28 Jun 2016 14:11:24 -0400 Subject: [PATCH] lttng: Stabilize CriticalPathTest 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 Reviewed-on: https://git.eclipse.org/r/76153 Reviewed-by: Matthew Khouzam Reviewed-by: Hudson CI Tested-by: Matthew Khouzam --- .../ui/swtbot/tests/CriticalPathTest.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java index a70d84063d..4e96eda888 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java @@ -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"; + } + }); } } -- 2.34.1