Author: dsvyatobatsko
Date: 2009-02-13 11:24:31 -0500 (Fri, 13 Feb 2009)
New Revision: 12661
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataFilterSliderBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataFilterSlider/dataFilterSliderAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataFilterSlider/dataFilterSliderTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataFilterSliderTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5978
https://jira.jboss.org/jira/browse/RF-5987
https://jira.jboss.org/jira/browse/RF-5988
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataFilterSliderBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataFilterSliderBean.java 2009-02-13
15:49:36 UTC (rev 12660)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataFilterSliderBean.java 2009-02-13
16:24:31 UTC (rev 12661)
@@ -23,7 +23,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.richfaces.component.UIDataFltrSlider;
import org.richfaces.event.DataFilterSliderEvent;
public class DataFilterSliderBean {
@@ -47,12 +46,18 @@
}
}
- private UIDataFltrSlider slider;
-
private List<Planet> planets;
private String eventSnapshot = "";
+ private Integer startRange = 0;
+
+ private Integer endRange = 40;
+
+ private Integer increment = 1;
+
+ private Integer handleValue = 20;
+
public DataFilterSliderBean() {
planets = new ArrayList<Planet>();
planets.add(new Planet("Sun", 27.94));
@@ -72,14 +77,6 @@
return planets;
}
- public UIDataFltrSlider getSlider() {
- return slider;
- }
-
- public void setSlider(UIDataFltrSlider slider) {
- this.slider = slider;
- }
-
public void doSlide(DataFilterSliderEvent event) {
Integer oldSliderVal = event.getOldSliderVal();
Integer newSliderVal = event.getNewSliderVal();
@@ -90,17 +87,83 @@
return eventSnapshot;
}
- public Integer getSubmittedValue() {
- Integer retVal = null;
- if (slider != null) {
- retVal = (Integer) slider.getHandleValue();
- }
+ /**
+ * Gets value of handleValue field.
+ * @return value of handleValue field
+ */
+ public Integer getHandleValue() {
+ return handleValue;
+ }
- return retVal;
+ /**
+ * Set a new value for handleValue field.
+ * @param handleValue a new value for handleValue field
+ */
+ public void setHandleValue(Integer handleValue) {
+ this.handleValue = handleValue;
}
+ /**
+ * Gets value of startRange field.
+ * @return value of startRange field
+ */
+ public Integer getStartRange() {
+ return startRange;
+ }
+
+ /**
+ * Set a new value for startRange field.
+ * @param startRange a new value for startRange field
+ */
+ public void setStartRange(Integer startRange) {
+ this.startRange = startRange;
+ }
+
+ /**
+ * Gets value of endRange field.
+ * @return value of endRange field
+ */
+ public Integer getEndRange() {
+ return endRange;
+ }
+
+ /**
+ * Set a new value for endRange field.
+ * @param endRange a new value for endRange field
+ */
+ public void setEndRange(Integer endRange) {
+ this.endRange = endRange;
+ }
+
+ /**
+ * Gets value of increment field.
+ * @return value of increment field
+ */
+ public Integer getIncrement() {
+ return increment;
+ }
+
+ /**
+ * Set a new value for increment field.
+ * @param increment a new value for increment field
+ */
+ public void setIncrement(Integer increment) {
+ this.increment = increment;
+ }
+
+ public String action() {
+ return null;
+ }
+
+ public void initIncrementTest() {
+ reset();
+ increment = 5;
+ }
+
public String reset() {
eventSnapshot = "";
+ handleValue = 20;
+ increment = 1;
return null;
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataFilterSlider/dataFilterSliderAutoTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataFilterSlider/dataFilterSliderTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataFilterSliderTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataFilterSliderTest.java 2009-02-13
15:49:36 UTC (rev 12660)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataFilterSliderTest.java 2009-02-13
16:24:31 UTC (rev 12661)
@@ -23,6 +23,7 @@
import org.ajax4jsf.template.Template;
import org.richfaces.AutoTester;
import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
import org.testng.annotations.Test;
public class DataFilterSliderTest extends SeleniumTestBase {
@@ -43,16 +44,21 @@
private static final int PLANETS_SMALLER_1 = 6;
+ private static final int PLANETS_SMALLER_0 = 0;
+
private static final String RESET_METHOD =
"#{dataFilterSliderBean.reset}";
+ private static final String INIT_INCREMENT_TEST =
"#{dataFilterSliderBean.initIncrementTest}";
+
private static final String FORM_ID = "autoTestForm:";
@Test
public void testDataFilterSliderComponent(Template template) {
- renderPage(template);
+ renderPage(template, RESET_METHOD);
String parentId = getParentId() + FORM_ID;
String tableId = parentId + TABLE;
+ String submittedValueId = parentId + "submittedValue";
writeStatus("Check component core functionality");
@@ -63,20 +69,23 @@
writeStatus("Set 1g! Only 6 planets have to meet this condition");
clickSlider(1);
assertRowsCount(PLANETS_SMALLER_1, tableId);
-
+ AssertTextEquals(submittedValueId, "1");
+ checkDataFilterSliderEventFired(20, 1);
+
writeStatus("Set 2g! Only 9 planets have to meet this condition");
clickSlider(2);
assertRowsCount(PLANETS_SMALLER_2, tableId);
+ checkDataFilterSliderEventFired(1, 2);
writeStatus("Set 5g! Only 10 planets have to meet this condition");
clickSlider(5);
assertRowsCount(PLANETS_SMALLER_3, tableId);
-
+ checkDataFilterSliderEventFired(2, 5);
}
@Test
public void testDataFilterSliderComponentManualInput(Template template) {
- renderPage(template);
+ renderPage(template, RESET_METHOD);
String parentId = getParentId() + FORM_ID;
String tableId = parentId + TABLE;
@@ -105,6 +114,39 @@
}
@Test
+ public void testIncrementAttribute(Template template) {
+ renderPage(template, INIT_INCREMENT_TEST);
+
+ String parentId = getParentId() + FORM_ID;
+ String tableId = parentId + TABLE;
+ String inputId = parentId + DATA_FLT_SLIDER_INPUT;
+ String submittedValueId = parentId + "submittedValue";
+
+ writeStatus("Check increment attribute");
+
+ writeStatus("Increment set to 5 therefore only multiple of 5
accepted.");
+ writeStatus("Any other will be adjusted by component to the nearest value (7
to 5, 13 to 15 and so on) Check it!");
+
+ selenium.type(inputId, "7");
+ waitForAjaxCompletion();
+ AssertTextEquals(submittedValueId, "5");
+ assertRowsCount(PLANETS_SMALLER_3, tableId);
+
+ selenium.type(inputId, "13");
+ waitForAjaxCompletion();
+ AssertTextEquals(submittedValueId, "15");
+ assertRowsCount(PLANETS_SMALLER_3, tableId);
+
+ clickSlider(2);
+ AssertTextEquals(submittedValueId, "0");
+ assertRowsCount(PLANETS_SMALLER_0, tableId);
+
+ clickSlider(18);
+ AssertTextEquals(submittedValueId, "20");
+ assertRowsCount(PLANETS_SMALLER_3, tableId);
+ }
+
+ @Test
public void testRenderedAttribute(Template template) {
AutoTester tester = getAutoTester(this);
tester.renderPage(template, RESET_METHOD);
@@ -180,13 +222,19 @@
String trackId = getParentId() + FORM_ID + DATA_FLT_SLIDER_TRACK;
int w = selenium.getElementWidth(trackId).intValue();
double step = w / 40.;
- int pos = (int) (position * step + 1 + (isFF() ? step : 0));
+ int pos = (int) ((position + 1) * step);
selenium.mouseDownAt(trackId, pos + ",0");
selenium.mouseUpAt(trackId, pos + ",0");
waitForAjaxCompletion();
delay(500);
}
+ private void checkDataFilterSliderEventFired(int oldValue, int newValue) {
+ String eventSnapshotExpected = "DataFilterSliderEvent[" + oldValue +
"," + newValue + "]";
+ String eventSnapshotActual = selenium.getText(getParentId() + FORM_ID +
"eventSnapshot");
+ Assert.assertTrue((null != eventSnapshotActual) &&
eventSnapshotActual.equals(eventSnapshotExpected), eventSnapshotExpected + " is
expected!");
+ }
+
@Override
public void sendAjax() {
clickSlider(3);