Author: dsvyatobatsko
Date: 2009-02-26 08:23:04 -0500 (Thu, 26 Feb 2009)
New Revision: 12755
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSliderBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSlider/inputNumberSliderAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSliderTest.java
Log:
RF-5862, RF-5863
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-26
13:14:14 UTC (rev 12754)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSliderBean.java 2009-02-26
13:23:04 UTC (rev 12755)
@@ -29,6 +29,8 @@
private Integer value = 40;
+ private boolean enabledManualInput = true;
+
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."));
@@ -60,4 +62,25 @@
this.value = 40;
}
+ public void initEnableManualInputAttributeTest() {
+ reset();
+ this.enabledManualInput = false;
+ }
+
+ /**
+ * Gets value of enabledManualInput field.
+ * @return value of enabledManualInput field
+ */
+ public boolean isEnabledManualInput() {
+ return enabledManualInput;
+ }
+
+ /**
+ * Set a new value for enabledManualInput field.
+ * @param enabledManualInput a new value for enabledManualInput field
+ */
+ public void setEnabledManualInput(boolean enabledManualInput) {
+ this.enabledManualInput = enabledManualInput;
+ }
+
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSlider/inputNumberSliderAutoTest.xhtml
===================================================================
(Binary files differ)
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-26
13:14:14 UTC (rev 12754)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSliderTest.java 2009-02-26
13:23:04 UTC (rev 12755)
@@ -36,6 +36,8 @@
private final static String RESET_METHOD = "#{sliderBean.reset}";
+ private final static String ENABLE_MANUAL_INPUT_TEST =
"#{sliderBean.initEnableManualInputAttributeTest}";
+
private final static String LOOK_AND_FEEL_TEST_URL =
"pages/inputNumberSlider/styleAndClasseStandardHTMLAttributesTest.xhtml";
@Test
@@ -94,32 +96,6 @@
AssertTextEquals(output, "40");
}
- private void checkSliderVisualState(int value) {
- String id = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
- writeStatus("Checking value in input field");
- AssertValueEquals(id + "Input", Integer.toString(value));
- AssertTextEquals(id + "Tip", Integer.toString(value));
-
- writeStatus("Checking tip and tracker position");
- String actualHandle = runScript("document.getElementById('" + id +
"Handle').style.left");
- String actualTip = runScript("document.getElementById('" + id +
"Tip').style.left");
-
- Assert.assertEquals(actualHandle, actualTip);
- Assert.assertTrue(actualTip.endsWith("px"));
-
- int actual = new Integer(actualTip.replace("px",
"")).intValue();
- int expected = BAR_SCALE * value;
- Assert.assertTrue(Math.abs(actual - expected) < BAR_SCALE,
- "Handle position is not syncronized with slider value!");
- }
-
- private void clickSlider(int position) {
- String track = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID) +
"Track";
- String coords = "" + BAR_SCALE * position + ",1";
- selenium.mouseDownAt(track, coords);
- selenium.mouseUpAt(track, coords);
- }
-
@Test
public void testValueChangeEventFiredAndModelUpdatedOnSubmit(Template template) {
AutoTester tester = getAutoTester(this);
@@ -254,6 +230,74 @@
assertClassAttributeContains(tipId, "tip-class", "tipClass
attribute was not output to client");
}
+ @Test
+ public void testClickingEdgesInputBoundaryValues(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ writeStatus("Check clicking edges input boundary values");
+
+ clickSlider(0);
+ Assert.assertEquals(getSliderValue(), "0");
+
+ clickSlider(100);
+ Assert.assertEquals(getSliderValue(), "100");
+ }
+
+ @Test
+ public void testEnableManualInputAttribute(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, ENABLE_MANUAL_INPUT_TEST);
+ writeStatus("Check setting enableManualInput to false makes input
read-only");
+
+ String inputId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID) +
"Input";
+ Assert.assertFalse(selenium.isEditable(inputId), "Slider's input has to
be read only");
+ }
+
+ @Test
+ public void testAdditionalIncreasingDecreasingControls(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ writeStatus("Check clicking an arrow changes the driven value on the amount
defined with 'step' attribute");
+
+ String slider = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
+ String arrowDec = slider + "ArrowDec";
+ String arrowInc = slider + "ArrowInc";
+
+ selenium.mouseDownAt(arrowDec, "1,1");
+ selenium.mouseUpAt(arrowDec, "1,1");
+ Assert.assertEquals(getSliderValue(), "39", "Value would have
decreased by one");
+
+ selenium.mouseDownAt(arrowInc, "1,1");
+ selenium.mouseUpAt(arrowInc, "1,1");
+ Assert.assertEquals(getSliderValue(), "40", "Value would have
increased by one");
+ }
+
+ private void checkSliderVisualState(int value) {
+ String id = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
+ writeStatus("Checking value in input field");
+ AssertValueEquals(id + "Input", Integer.toString(value));
+ AssertTextEquals(id + "Tip", Integer.toString(value));
+
+ writeStatus("Checking tip and tracker position");
+ String actualHandle = runScript("document.getElementById('" + id +
"Handle').style.left");
+ String actualTip = runScript("document.getElementById('" + id +
"Tip').style.left");
+
+ Assert.assertEquals(actualHandle, actualTip);
+ Assert.assertTrue(actualTip.endsWith("px"));
+
+ int actual = new Integer(actualTip.replace("px",
"")).intValue();
+ int expected = BAR_SCALE * value;
+ Assert.assertTrue(Math.abs(actual - expected) < BAR_SCALE,
+ "Handle position is not syncronized with slider value!");
+ }
+
+ private void clickSlider(int position) {
+ String track = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID) +
"Track";
+ String coords = "" + BAR_SCALE * position + ",1";
+ selenium.mouseDownAt(track, coords);
+ selenium.mouseUpAt(track, coords);
+ }
+
private String getSliderValue() {
return selenium.getValue("name=" +
getAutoTester(this).getClientId(AutoTester.COMPONENT_ID));
}