Author: dsvyatobatsko
Date: 2009-02-23 12:48:07 -0500 (Mon, 23 Feb 2009)
New Revision: 12715
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSlider/inputNumberSliderAutoTest.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSliderBean.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSliderTest.java
Log:
RF-5855, RF-5865, RF-5866
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSliderBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSliderBean.java 2009-02-23
16:08:24 UTC (rev 12714)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSliderBean.java 2009-02-23
17:48:07 UTC (rev 12715)
@@ -17,7 +17,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+ */
package org.ajax4jsf.bean;
import javax.faces.application.FacesMessage;
@@ -26,30 +26,38 @@
import javax.faces.validator.ValidatorException;
public class InputNumberSliderBean {
- private int value;
-
- public InputNumberSliderBean() {
- value = 40;
- }
-
- public void validate(FacesContext context, UIComponent component,
- Object value) throws ValidatorException {
- if (((Integer)value).intValue() > 90) {
- throw new ValidatorException(new FacesMessage("Fake validation. Value is more
than 90."));
- }
- }
-
- public String action() {
- this.value += 10;
- return null;
- }
- public int getValue() {
- return value;
- }
+ private Integer value = 40;
- public void setValue(int value) {
- this.value = value;
- }
-
+ public void validate(FacesContext context, UIComponent component, Object value)
throws ValidatorException {
+ if (((Integer) value).intValue() > 90) {
+ throw new ValidatorException(new FacesMessage("Fake validation. Value is
more than 90."));
+ }
+ }
+
+ public String action() {
+ this.value += 10;
+ return null;
+ }
+
+ /**
+ * Gets value of value field.
+ * @return value of value field
+ */
+ public Integer getValue() {
+ return value;
+ }
+
+ /**
+ * Set a new value for value field.
+ * @param value a new value for value field
+ */
+ public void setValue(Integer value) {
+ this.value = value;
+ }
+
+ public void reset() {
+ this.value = 40;
+ }
+
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSlider/inputNumberSliderAutoTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSlider/inputNumberSliderAutoTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSliderTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSliderTest.java 2009-02-23
16:08:24 UTC (rev 12714)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSliderTest.java 2009-02-23
17:48:07 UTC (rev 12715)
@@ -21,6 +21,7 @@
package org.richfaces.testng;
import org.ajax4jsf.template.Template;
+import org.richfaces.AutoTester;
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -29,9 +30,13 @@
private static final int BAR_SCALE = 10;
+ private final static String RESET_METHOD = "#{sliderBean.reset}";
+
+ private final static String FORM_ID = "autoTestForm:";
+
@Test
public void testInputNumberSlider(Template template) {
- renderPage(template);
+ renderPage(template, RESET_METHOD);
String parentId = getParentId() + "_form:";
String slider = parentId + "slider";
@@ -45,15 +50,15 @@
String output = parentId + "output";
writeStatus("Checking initial rendering");
- Assert.assertFalse(isVisibleById(tip));
+ AssertNotVisible(tip);
checkSliderVisualState(slider, 40);
AssertTextEquals(output, "40");
writeStatus("Checking if tip is visible during click");
selenium.mouseDownAt("id=" + track, "800,1");
- Assert.assertTrue(isVisibleById(tip));
+ AssertVisible(tip);
selenium.mouseUpAt("id=" + track, "800,1");
- Assert.assertFalse(isVisibleById(tip));
+ AssertNotVisible(tip);
writeStatus("Checking if value is changed with previous click");
checkSliderVisualState(slider, 80);
@@ -104,7 +109,55 @@
"Handle position is not syncronized with slider value!");
}
+ @Test
+ public void testValueChangeEventFiredAndModelUpdatedOnSubmit(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ String submittedValueId = tester.getClientId("submittedValue");
+
+ writeStatus("Check ValueChangeListeners invoked on submit and model binding
is updated on value changed");
+ Assert.assertEquals(getSliderValue(), "40");
+ tester.testSubmit();
+ AssertTextEquals(submittedValueId, "50", "Model binding is not
updated on value changed");
+ }
+
+ @Test
+ public void testRenderedAttribute(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ writeStatus("Test component with rendered = false is not present on the
page");
+ tester.testRendered();
+ }
+
+ @Test
+ public void testImmediate(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ writeStatus("Test immediate attribute");
+ tester.testSubmitImmediate();
+ }
+
+ private String getSliderValue() {
+ return selenium.getValue("name=" + getParentId() + FORM_ID +
"componentId");
+ }
+
+ private void setSliderValue(String value) {
+ selenium.type("name=" + getParentId() + FORM_ID +
"componentId", value);
+ }
+
+ @Override
+ public void changeValue() {
+ setSliderValue("50");
+ }
+
+ @Override
public String getTestUrl() {
return "pages/inputNumberSlider/inputNumberSliderTest.xhtml";
}
+
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/inputNumberSlider/inputNumberSliderAutoTest.xhtml";
+ }
+
}
Show replies by date