Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[swtbot-dev] Wanting to fix a tree (node) bug

Hello,

I'm a Linuxtools contributor who has been working with SWTBot, and I've been experiencing an SWTBot bug I'd like to ask about before I submit any potential fixes.

The bug I'm experiencing is not being able to reliably expand tree items. On very rare cases, calling  SWTBotTree#expandNode (or SWTBotTreeItem#expandNode) has no effect, no matter how long the bot waits afterwards. The strange thing about the bug is that it can happen in tests that have been successful; even without touching the code, tests that successfully expand trees may fail to do so in a later test run / build.

I created a Bugzilla entry for this at https://bugs.eclipse.org/bugs/show_bug.cgi?id=430047.

Given how rarely this bug occurs, I haven't been able to reproduce it during local debugging, but it happens plenty of times during Linuxtools builds due to how many of its tests use tree expansions. So far, just retriggering failed builds tends to fix it temporarily, but it always happens again at some point. I'd like to find a permanent fix if possible (without having to resort to workarounds).

I cloned the SWTBot repo and made a patch that may fix this bug; it changes interactions on tree items to be synchronous rather than asynchronous. Every one of SWTBot's test classes that check tree expansion functionality still work after applying this patch, so I know at the very least that it doesn't break anything. However, since I can't reproduce the bug, I can't be sure whether or not this improved anything, which is why I'd like your opinion on the matter if possible.

The patch is attached to this email. If you'd rather have me submit it to Gerrit for review, please let me know.

Thanks,
Andrew
From 2ef811336f074efe545805e60e027ebbe66bb82c Mon Sep 17 00:00:00 2001
From: Andrew Ferrazzutti <aferrazz@xxxxxxxxxx>
Date: Thu, 13 Mar 2014 15:32:09 -0400
Subject: [PATCH] Perform synchronous operations on trees/tree nodes

https://bugs.eclipse.org/bugs/show_bug.cgi?id=430047

Signed-off-by: Andrew Ferrazzutti <aferrazz@xxxxxxxxxx>
---
 .../src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java
index 59c6b79..ed3d367 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItem.java
@@ -176,7 +176,7 @@ public class SWTBotTreeItem extends AbstractSWTBot<TreeItem> {
 		}
 
 		preExpandNotify();
-		asyncExec(new VoidResult() {
+		syncExec(new VoidResult() {
 			public void run() {
 				widget.setExpanded(true);
 			}
@@ -199,7 +199,7 @@ public class SWTBotTreeItem extends AbstractSWTBot<TreeItem> {
 		}
 
 		preCollapseNotify();
-		asyncExec(new VoidResult() {
+		syncExec(new VoidResult() {
 			public void run() {
 				widget.setExpanded(false);
 			}
@@ -428,7 +428,7 @@ public class SWTBotTreeItem extends AbstractSWTBot<TreeItem> {
 
 		final Point center = getCenter(getCellBounds());
 
-		asyncExec(new VoidResult() {
+		syncExec(new VoidResult() {
 			public void run() {
 				tree.setSelection(widget);
 			}
-- 
1.8.3.1


Back to the top