Author: andrei_exadel
Date: 2008-04-18 11:02:01 -0400 (Fri, 18 Apr 2008)
New Revision: 7937
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ProgressBarTest.java
Log:
refactoring
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java 2008-04-18
15:00:39 UTC (rev 7936)
+++
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java 2008-04-18
15:02:01 UTC (rev 7937)
@@ -1,5 +1,6 @@
package org.ajax4jsf.test.base;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.testng.Assert;
import com.thoughtworks.selenium.DefaultSelenium;
@@ -297,6 +298,27 @@
public boolean isVisibleById(String id) {
return selenium.isVisible("id=" + id);
}
+
+ /**
+ * Invokes JS method on client.
+ * @param id - DOM id of component
+ * @param method - string method name
+ * @param parameters - parameters
+ * @return
+ */
+ public String invokeFromComponent(String id, String method, Object parameters) {
+ String _return = null;
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("$('");
+ buffer.append(id);
+ buffer.append("').component.");
+ buffer.append(method);
+ buffer.append("(");
+ buffer.append(ScriptUtils.toScript(parameters));
+ buffer.append(");");
+ _return = runScript(buffer.toString());
+ return _return;
+ }
/**
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ProgressBarTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ProgressBarTest.java 2008-04-18
15:00:39 UTC (rev 7936)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ProgressBarTest.java 2008-04-18
15:02:01 UTC (rev 7937)
@@ -91,30 +91,18 @@
value = getProgressBarValue(progressBarId);
Assert.assertTrue(value == 60);
-
-
-
-
}
private void enableProgressBar(String id, boolean enable) {
- StringBuffer script = new StringBuffer("$('");
- script.append(id).append("').component.").append(
- enable ? "enable();" : "disable();");
- runScript(script.toString());
+ invokeFromComponent(id, (enable ? "enable" : "disable"), null);
}
private void setProgressBarValue(String id, Object value) {
- StringBuffer script = new StringBuffer("$('");
- script.append(id).append("').component.").append("setValue(").append(
- value).append(");");
- runScript(script.toString());
+ invokeFromComponent(id, "setValue", value);
}
private Integer getProgressBarValue(String id) {
- StringBuffer script = new StringBuffer("$('");
- script.append(id).append("').component.").append("getValue();");
- String value = runScript(script.toString());
+ String value = invokeFromComponent(id, "getValue", null);
//runScript(script.toString());
Integer v = Integer.parseInt(value);
return v;
}
Show replies by date