[embjopr-commits] EMBJOPR SVN: r211 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Wed Mar 11 13:26:01 EDT 2009


Author: ozizka at redhat.com
Date: 2009-03-11 13:26:01 -0400 (Wed, 11 Mar 2009)
New Revision: 211

Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
Added NavTree.waitUntilLoaded()

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java	2009-03-11 16:43:42 UTC (rev 210)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java	2009-03-11 17:26:01 UTC (rev 211)
@@ -28,6 +28,7 @@
 
 	protected JSFClientSession client;
 	protected JSFServerSession server;
+	private EmbJoprTestToolkit selfEjtt; // For closures.
 
 	public JSFClientSession getClient() { return client; }
 	public JSFServerSession getServer() { return server; }
@@ -36,6 +37,7 @@
 	public EmbJoprTestToolkit(JSFClientSession client, JSFServerSession server) {
 		this.client = client;
 		this.server = server;
+		this.selfEjtt = this;
 	}
 
 
@@ -67,10 +69,17 @@
 
 
 
+	/**
+	 * Reloads the current page.
+	 */
+	private void refreshPage() throws IOException {
+		((HtmlPage)client.getContentPage()).refresh();
+	}
 
 
 
 
+
 	/**
 	 * Inner class to encapsulate navigation tree operations.
 	 *
@@ -107,10 +116,29 @@
 		}
 
 
-		public void waitForNavTreeLoaded(){
-			sleep(1500);///
-			// TODO: Use ActiveConditionChecker
 
+
+		/**
+		 * Waits
+		 * @param msInterval  Milliseconds to wait between tries.
+		 * @param retries     Number of retries. Total time = (retries - 1) * msInterval.
+		 * @throws java.lang.Exception  Whatever exception is thrown from the isTrue() method.
+		 * @throws org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException
+		 *         when max number of retries was reached.
+		 */
+		public void waitUntilLoaded( int msInterval, int retries ) throws Exception {
+			final NavTree self = this;
+			//final EmbJoprTestToolkit ejtt = client;
+			new ActiveConditionChecker( new DescribedCondition("Nav tree contains Applications node.") {
+				int callsMade = 0;
+				public boolean isTrue() throws HtmlElementNotFoundException, IOException {
+					// Refresh the page if this is not the first call.
+					if( callsMade++ > 0 )
+						selfEjtt.refreshPage();
+					// If found, return true.
+					return null != self.findNodeByLabel("Applications");
+				}
+			}).throwOnTimeout().waitWithTimeout(1000, 3);
 		}
 
 




More information about the embjopr-commits mailing list