Author: ozizka(a)redhat.com
Date: 2009-03-17 12:52:23 -0400 (Tue, 17 Mar 2009)
New Revision: 230
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JavaScriptTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
NavTree.waitUntilReady() changed
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JavaScriptTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JavaScriptTest.java 2009-03-17
16:24:33 UTC (rev 229)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JavaScriptTest.java 2009-03-17
16:52:23 UTC (rev 230)
@@ -34,9 +34,9 @@
import org.mozilla.javascript.NativeFunction;
/**
- * Login test. Makes use of default login in EmbjoprTestCase::setUp()
+ * JavaScript tests. Primarily written to try how Rhino JavaScript impl works.
*
- * @author Stan Silvert
+ * @author Ondrej Zizka
*/
public class JavaScriptTest extends EmbjoprTestCase
{
@@ -50,7 +50,7 @@
- public void testTreeItemLoaded() throws IOException
+ public void testTreeItemLoaded() throws IOException, Exception
{
JavaScriptEngine jse =
client.getContentPage().getEnclosingWindow().getWebClient().getJavaScriptEngine();
@@ -70,26 +70,30 @@
// JS null object?
jsTreeItem = jse.execute((HtmlPage) client.getContentPage(), "null",
"testTreeItemLoaded", 0);
- log.info( jsTreeItem.getClass().getName() );
- log.info( ObjectUtils.toString(jsTreeItem) );
+ if( null == jsTreeItem ){
+ // True.
+ }
+ else {
+ log.info( jsTreeItem.getClass().getName() );
+ log.info( ObjectUtils.toString(jsTreeItem) );
+ }
-
-
-
-
+ // Own active condition waiting
new ActiveConditionChecker( new DescribedCondition("Tree.Item JS object is
initialized.") {
final EmbJoprTestToolkit selfEjtt = ejtt;
public boolean isTrue() throws Exception {
- Object obj = selfEjtt.getJavaScriptObject("Test.Item");
+ Object obj = selfEjtt.getJavaScriptObject("Tree.Item");
if( null == obj ) return false;
//if ( org.mozilla.javascript.NOT_FOUND ) return false;
if( ! (obj instanceof NativeFunction ) ) return false;
return true;
}
- });
-
+ }).throwOnTimeout().waitWithTimeout(100, 20);
+ // Using EJTT method
+ ejtt.navTree.waitUntilReady( 100, 20 );
+
}
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-17
16:24:33 UTC (rev 229)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-03-17
16:52:23 UTC (rev 230)
@@ -244,20 +244,20 @@
public boolean isReady(){
- Object obj = getJavaScriptObject("Test.Item");
+ Object obj = getJavaScriptObject("Tree.Item");
if( null == obj ) return false;
//if ( org.mozilla.javascript.NOT_FOUND ) return false;
if( ! (obj instanceof NativeFunction ) ) return false;
return true;
}
- public void waitUntilReady(){
+ public void waitUntilReady( int msInterval, int retries ) throws Exception {
final NavTree self = this;
new ActiveConditionChecker( new DescribedCondition("Tree.Item JS object is
initialized.") {
public boolean isTrue() throws Exception {
return self.isReady();
}
- });
+ }).throwOnTimeout().waitWithTimeout(msInterval, retries);
}
Show replies by date