[jbosstools-commits] JBoss Tools SVN: r39601 - trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/common.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Mar 19 03:22:05 EDT 2012


Author: jpeterka
Date: 2012-03-19 03:22:03 -0400 (Mon, 19 Mar 2012)
New Revision: 39601

Modified:
   trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/common/Tree.java
Log:
getSubnodes routine added into Tree ui bot helper

Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/common/Tree.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/common/Tree.java	2012-03-17 17:56:54 UTC (rev 39600)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/common/Tree.java	2012-03-19 07:22:03 UTC (rev 39601)
@@ -2,6 +2,9 @@
 
 import static org.junit.Assert.fail;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.log4j.Logger;
 import org.eclipse.swtbot.swt.finder.SWTBot;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
@@ -81,10 +84,12 @@
 	
 	
 	private static void expandNode(SWTBotTreeItem item) {
-		item.expand();
 		if (!item.isExpanded()) {
-			fail("Unable to expand " + item.getText());
+			item.expand();
 		}
+		if (!item.isExpanded()) {
+			log.error("Unable to expand:" + item.getText());
+		}
 	}
 	
 	
@@ -104,12 +109,51 @@
 		
 	}
 	
+	private static boolean hasSubnodes(SWTBotTreeItem item) {
+		return (item.getNodes().size() > 0);
+	}
+	
 	private static void collapseNode(SWTBotTreeItem item) {
 		if (item.isExpanded()) {
 			item.collapse();
 		}
 		if (item.isExpanded()) {
-			fail("Unable to collapse" + item.getText());
+			log.error("Unable to collapse:" + item.getText());
 		}
 	}
+
+	public static List<String> getSubNodes(SWTBot bot, SWTBotTreeItem item) {
+		
+		List<String> ret = new ArrayList<String>();		
+		expandNode(item);
+		
+		final int limit = 5; // 5 cycles max
+		final int sleep = 1000;  // 1s		
+		int counter = 0;
+		// 1st round
+		while (counter < limit) {
+			if (!hasSubnodes(item)) {
+				log.info("no subnodes");
+				bot.sleep(sleep);
+			}
+			else {
+				ret = item.getNodes();
+				break;
+			}
+		}
+		// 2nd round
+		collapseNode(item);
+		expandNode(item);
+		while (counter < limit) {
+			if (!hasSubnodes(item)) {
+				log.info("no subnodes");
+				bot.sleep(sleep);
+			}
+			else {
+				ret = item.getNodes();
+				break;
+			}
+		}
+		return ret;
+	}
 }



More information about the jbosstools-commits mailing list