[jbosstools-commits] JBoss Tools SVN: r43420 - in trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext: helper and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Sep 5 11:37:38 EDT 2012


Author: jjankovi
Date: 2012-09-05 11:37:38 -0400 (Wed, 05 Sep 2012)
New Revision: 43420

Added:
   trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/TreeItemContainsNode.java
Modified:
   trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/TreeContainsNode.java
   trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/TreeHelper.java
Log:
added new condition into ui.bot.ext

Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/TreeContainsNode.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/TreeContainsNode.java	2012-09-05 15:22:34 UTC (rev 43419)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/TreeContainsNode.java	2012-09-05 15:37:38 UTC (rev 43420)
@@ -25,10 +25,10 @@
 	public boolean test() throws Exception {
 		try {
 			tree.expandNode(path);
-			System.out.println("TRUE");
+//			System.out.println("TRUE");
 			return true;
 		} catch (WidgetNotFoundException e){
-			System.out.println("FALSE");
+//			System.out.println("FALSE");
 			return false;
 		}
 	}

Added: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/TreeItemContainsNode.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/TreeItemContainsNode.java	                        (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/condition/TreeItemContainsNode.java	2012-09-05 15:37:38 UTC (rev 43420)
@@ -0,0 +1,39 @@
+package org.jboss.tools.ui.bot.ext.condition;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+public class TreeItemContainsNode implements ICondition {
+
+	private SWTBotTreeItem treeItem;
+
+	private String node;
+
+	public TreeItemContainsNode(SWTBotTreeItem treeItem, String node) {
+		this.treeItem = treeItem;
+		this.node = node;
+	}
+
+	@Override
+	public void init(SWTBot bot) {
+
+	}
+
+	@Override
+	public boolean test() throws Exception {
+		try {
+			treeItem.expandNode(node);			
+			return true;
+		} catch (WidgetNotFoundException e){
+			return false;
+		}
+	}
+
+	@Override
+	public String getFailureMessage() {
+		return "Tree item " + node + " is not visible " +
+				"under tree item " + treeItem.getText();
+	}
+}

Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/TreeHelper.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/TreeHelper.java	2012-09-05 15:22:34 UTC (rev 43419)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/TreeHelper.java	2012-09-05 15:37:38 UTC (rev 43420)
@@ -5,9 +5,11 @@
 import java.util.List;
 
 import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.condition.TreeContainsNode;
+import org.jboss.tools.ui.bot.ext.condition.TreeItemContainsNode;
 
 /**
  * 
@@ -20,18 +22,18 @@
 	public static SWTBotTreeItem expandNode(final SWTBot bot, final String... nodes){
 
 		List<String> asList = new ArrayList<String>(Arrays.asList(nodes));
-		SWTBotTreeItem item = bot.tree(0).getTreeItem(asList.get(0));
+		SWTBotTree tree = bot.tree(0);
+		bot.waitUntil(new TreeContainsNode(tree,asList.get(0)), Timing.time5S());
+		SWTBotTreeItem item = tree.getTreeItem(asList.get(0));
 		asList.remove(0);
 		
 		for(String node : asList){
-			if(item == null)
-				throw new WidgetNotFoundException("Could not find node with text:" + node);
-			
 			item.expand();
 			while(item.getNode(0).getText().equals("Pending...") || 
 				  item.getNode(0).getText().equals("Loading...")) {
 				bot.sleep(Timing.time1S());
 			}
+			bot.waitUntil(new TreeItemContainsNode(item, node), Timing.time5S());
 			item = item.getNode(node);
 		}			
 		return item;



More information about the jbosstools-commits mailing list