Author: dsvyatobatsko
Date: 2009-01-28 12:32:26 -0500 (Wed, 28 Jan 2009)
New Revision: 12472
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSpinnerBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5890
https://jira.jboss.org/jira/browse/RF-5891
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSpinnerBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSpinnerBean.java 2009-01-28
17:13:18 UTC (rev 12471)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSpinnerBean.java 2009-01-28
17:32:26 UTC (rev 12472)
@@ -4,6 +4,10 @@
private Integer value = 20;
+ private boolean disabled = false;
+
+ private boolean enableManualInput = true;
+
/**
* Gets value of value field.
* @return value of value field
@@ -20,8 +24,42 @@
this.value = value;
}
+ /**
+ * Gets value of disabled field.
+ * @return value of disabled field
+ */
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ /**
+ * Set a new value for disabled field.
+ * @param disabled a new value for disabled field
+ */
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+ /**
+ * Gets value of enableManualInput field.
+ * @return value of enableManualInput field
+ */
+ public boolean isEnableManualInput() {
+ return enableManualInput;
+ }
+
+ /**
+ * Set a new value for enableManualInput field.
+ * @param enableManualInput a new value for enableManualInput field
+ */
+ public void setEnableManualInput(boolean enableManualInput) {
+ this.enableManualInput = enableManualInput;
+ }
+
public void reset() {
this.value = 20;
+ this.disabled = false;
+ this.enableManualInput = true;
}
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-28
17:13:18 UTC (rev 12471)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-28
17:32:26 UTC (rev 12472)
@@ -34,6 +34,8 @@
private final static String FORM_ID = "autoTestForm:";
+ private final static String CONTROL_FORM_ID = "control:";
+
@Test
public void testCycleMode(Template template) {
renderPage(template, RESET_METHOD);
@@ -107,6 +109,59 @@
tester.testValidatorAndValidatorMessageAttributes(true);
}
+ @Test
+ public void testEnableManualInputAttribute(Template template) {
+ renderPage(template, RESET_METHOD);
+ writeStatus("Check enableManualInput = false makes input read-only");
+ String spinnerId = getParentId() + FORM_ID + "componentId";
+
+ writeStatus("Check if enableManualInput == true component's value can be
edited manually");
+ Assert.assertEquals(getSpinnerValue(), "20");
+ selenium.type("name=" + spinnerId, "30");
+ Assert.assertEquals(getSpinnerValue(), "30");
+
+ writeStatus("Via buttons as before too:");
+ clickUp();
+ Assert.assertEquals(getSpinnerValue(), "40");
+
+ writeStatus("Otherwise not, only via buttons");
+ enableManualInput(false);
+ Assert.assertEquals(getSpinnerValue(), "20");
+// selenium.type("name=" + spinnerId, "30");
+// Assert.assertEquals(getSpinnerValue(), "20");
+
+ writeStatus("Via buttons? you are welcome:");
+ clickUp();
+ Assert.assertEquals(getSpinnerValue(), "30");
+ }
+
+ @Test
+ public void testDisabledAttribute(Template template) {
+ renderPage(template, RESET_METHOD);
+ writeStatus("Check component can be disabled");
+ String spinnerId = getParentId() + FORM_ID + "componentId";
+
+ writeStatus("Check while component is not disabled its value can be edited
at liberty");
+ Assert.assertEquals(getSpinnerValue(), "20");
+ writeStatus("Via buttons:");
+ clickUp();
+ Assert.assertEquals(getSpinnerValue(), "30");
+ writeStatus("By hand");
+ selenium.type("name=" + spinnerId, "40");
+ Assert.assertEquals(getSpinnerValue(), "40");
+
+ writeStatus("Ruffle! Disable the spinner and check there is nothing can be
edited");
+ disable(true);
+
+ Assert.assertEquals(getSpinnerValue(), "20");
+ writeStatus("neither via buttons:");
+ clickUp();
+ Assert.assertEquals(getSpinnerValue(), "20");
+ writeStatus("Nor by hand");
+// selenium.type("name=" + spinnerId, "30");
+// Assert.assertEquals(getSpinnerValue(), "20");
+ }
+
private void clickUp() {
String id = getParentId() + FORM_ID + "componentIdButtons";
selenium.fireEvent("xpath=//table[@id='" + id +
"']/tbody/tr[1]/td", "mousedown");
@@ -123,6 +178,16 @@
return selenium.getValue("name=" + getParentId() + FORM_ID +
"componentId");
}
+ private void disable(boolean disabled) {
+ runScript("$('" + getParentId() + CONTROL_FORM_ID +
"disabled" + "').checked=" + disabled);
+ clickCommandAndWait(getParentId() + CONTROL_FORM_ID + "apply");
+ }
+
+ private void enableManualInput(boolean enabled) {
+ runScript("$('" + getParentId() + CONTROL_FORM_ID +
"enableManualInput" + "').checked=" + enabled);
+ clickCommandAndWait(getParentId() + CONTROL_FORM_ID + "apply");
+ }
+
@Override
public void changeValue() {
clickUp();