Author: abelevich
Date: 2010-09-01 06:59:33 -0400 (Wed, 01 Sep 2010)
New Revision: 19066
Modified:
trunk/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerBean.java
trunk/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java
trunk/ui/iteration/ui/src/test/resources/org/richfaces/renderkit/dataTableTest.xhtml
Log:
add testcase for the next/previous controls
Modified:
trunk/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerBean.java
===================================================================
---
trunk/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerBean.java 2010-09-01
10:57:22 UTC (rev 19065)
+++
trunk/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerBean.java 2010-09-01
10:59:33 UTC (rev 19066)
@@ -17,7 +17,6 @@
content.add("3 page content");
content.add("4 page content");
content.add("5 page content");
- content.add("6 page content");
}
public List<String> getContent() {
Modified:
trunk/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java
===================================================================
---
trunk/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java 2010-09-01
10:57:22 UTC (rev 19065)
+++
trunk/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java 2010-09-01
10:59:33 UTC (rev 19066)
@@ -47,7 +47,7 @@
assertEquals("span", span.getNodeName());
assertEquals("rf-ds", span.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
- // first/fastRewind buttons with arrows
+ // first/fastRewind/previous buttons with arrows
HtmlElement first = getFirstButton(page, scrollerId);
assertEquals("span", first.getNodeName());
assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
first.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
@@ -56,11 +56,15 @@
assertEquals("span", fastRewind.getNodeName());
assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
fastRewind.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+ HtmlElement previous = getPreviousButton(page, scrollerId);
+ assertEquals("span", previous.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
previous.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
// currently selected digital button
- HtmlElement dc = getDigitalButton(page, scrollerId, 1);
- assertEquals("span", dc.getNodeName());
- assertEquals("rf-ds-dtl rf-ds-cur",
dc.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
-
+ HtmlElement dc1 = getDigitalButton(page, scrollerId, 1);
+ assertEquals("span", dc1.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
dc1.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
// digital buttons
HtmlElement d2 = getDigitalButton(page, scrollerId, 2);
assertEquals("a", d2.getNodeName());
@@ -82,12 +86,12 @@
assertEquals("rf-ds-dtl",
d5.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
assertEquals("javascript:void(0);", d5.getAttribute(HTML.HREF_ATTR));
- HtmlElement d6 = getDigitalButton(page, scrollerId, 6);
- assertEquals("a", d6.getNodeName());
- assertEquals("rf-ds-dtl",
d6.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
- assertEquals("javascript:void(0);", d6.getAttribute(HTML.HREF_ATTR));
+ // next/fastForward/last buttons with arrows
+ HtmlElement next = getNextButton(page, scrollerId);
+ assertEquals("a", next.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-r",
next.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+ assertEquals("javascript:void(0);",
next.getAttribute(HTML.HREF_ATTR));
- // last/fastForward buttons with arrows
HtmlElement fastForward = getFastForwardButton(page, scrollerId);
assertEquals("a", fastForward.getNodeName());
assertEquals("rf-ds-btn rf-ds-r",
fastForward.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
@@ -134,6 +138,102 @@
}
@Test
+ public void testOutDataScrollerNextPreviousButtons() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ String firstScrollerId = "scroller1";
+
+ //dataScroller inside dataTable 'footer' facet
+ String secondScrollerId = "richTable:scroller2";
+
+ for(int i = 2; i <= 5; i++) {
+ HtmlElement next = getNextButton(page, firstScrollerId);
+
+ next.click();
+
+ HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
+ assertEquals("span", currentDigital1.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital1.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // if scroller inside dataTable has switched
+ HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
+ assertEquals("span", currentDigital2.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital2.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // check if page has switched
+ assertEquals(i + " page content", getCurrentPageContent(page, i));
+ }
+
+ checkLastPageButtons(page, firstScrollerId, secondScrollerId);
+
+ //scroll back
+ for(int i = 4; i >= 1; i--) {
+ HtmlElement previous = getPreviousButton(page, firstScrollerId);
+ previous.click();
+ HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
+
+ assertEquals("span", currentDigital1.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital1.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // if scroller inside dataTable has switched
+ HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
+ assertEquals("span", currentDigital2.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital2.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // check if page has switched
+ assertEquals(i + " page content", getCurrentPageContent(page, i));
+ }
+
+ checkFirstPageButtons(page, firstScrollerId, secondScrollerId);
+ }
+
+ @Test
+ public void testInnerDataScrollerNextPreviousButtons() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ String firstScrollerId = "scroller1";
+
+ //dataScroller inside dataTable 'footer' facet
+ String secondScrollerId = "richTable:scroller2";
+
+ for(int i = 2; i <= 5; i++) {
+ HtmlElement next = getNextButton(page, secondScrollerId);
+ next.click();
+ HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
+ assertEquals("span", currentDigital2.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital2.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // if scroller outside dataTable has switched
+ HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
+ assertEquals("span", currentDigital1.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital1.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // check if page has switched
+ assertEquals(i + " page content", getCurrentPageContent(page, i));
+ }
+
+ checkLastPageButtons(page, firstScrollerId, secondScrollerId);
+
+ //scroll back
+ for(int i = 4; i >= 1; i--) {
+ HtmlElement previous = getPreviousButton(page, secondScrollerId);
+ previous.click();
+
+ HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
+ assertEquals("span", currentDigital2.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital2.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // if scroller inside dataTable has switched
+ HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
+ assertEquals("span", currentDigital1.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital1.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // check if page has switched
+ assertEquals(i + " page content", getCurrentPageContent(page, i));
+ }
+
+ checkFirstPageButtons(page, firstScrollerId, secondScrollerId);
+ }
+
+ @Test
public void testOutDataScrollerFastButtons() throws Exception {
HtmlPage page = environment.getPage("/test.jsf");
String firstScrollerId = "scroller1";
@@ -141,7 +241,7 @@
//dataScroller inside dataTable 'footer' facet
String secondScrollerId = "richTable:scroller2";
- for(int i = 2; i <= 6; i++) {
+ for(int i = 3; i <= 5; i = i + 2) {
HtmlElement ff = getFastForwardButton(page, firstScrollerId);
ff.click();
@@ -162,7 +262,7 @@
checkLastPageButtons(page, firstScrollerId, secondScrollerId);
//scroll back
- for(int i = 5; i >= 1; i--) {
+ for(int i = 3; i >= 1; i = i - 2) {
HtmlElement fr = getFastRewindButton(page, firstScrollerId);
fr.click();
HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
@@ -190,7 +290,7 @@
//dataScroller inside dataTable 'footer' facet
String secondScrollerId = "richTable:scroller2";
- for(int i = 2; i <= 6; i++) {
+ for(int i = 3; i <= 5; i = i + 2) {
HtmlElement ff = getFastForwardButton(page, secondScrollerId);
ff.click();
HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
@@ -209,7 +309,7 @@
checkLastPageButtons(page, firstScrollerId, secondScrollerId);
//scroll back
- for(int i = 5; i >= 1; i--) {
+ for(int i = 3; i >= 1; i = i - 2) {
HtmlElement fr = getFastRewindButton(page, secondScrollerId);
fr.click();
@@ -228,7 +328,7 @@
checkFirstPageButtons(page, firstScrollerId, secondScrollerId);
}
-
+
@Test
public void testOutDataScrollerDigitalButtons() throws Exception {
HtmlPage page = environment.getPage("/test.jsf");
@@ -237,7 +337,7 @@
//dataScroller inside dataTable 'footer' facet
String secondScrollerId = "richTable:scroller2";
- for(int i = 2; i <= 6; i++) {
+ for(int i = 2; i <= 5; i++) {
HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
currentDigital1.click();
@@ -257,7 +357,7 @@
checkLastPageButtons(page, firstScrollerId, secondScrollerId);
//scroll back
- for(int i = 5; i >= 1; i--) {
+ for(int i = 4; i >= 1; i--) {
HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
currentDigital1.click();
@@ -285,7 +385,7 @@
//dataScroller inside dataTable 'footer' facet
String secondScrollerId = "richTable:scroller2";
- for(int i = 2; i <= 6; i++) {
+ for(int i = 2; i <= 5; i++) {
HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
currentDigital2.click();
@@ -305,7 +405,7 @@
checkLastPageButtons(page, firstScrollerId, secondScrollerId);
//scroll back
- for(int i = 5; i >= 1; i--) {
+ for(int i = 4; i >= 1; i--) {
HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
currentDigital2.click();
@@ -334,25 +434,35 @@
private void checkFirstPageButtons(HtmlPage page, String firstScrollerId, String
secondScrollerId) throws Exception {
HtmlElement fastForward = getFastForwardButton(page, firstScrollerId);
HtmlElement last = getLastButton(page, firstScrollerId);
+ HtmlElement next = getNextButton(page, firstScrollerId);
+ //check right buttons
assertEquals("a", fastForward.getNodeName());
assertEquals("rf-ds-btn rf-ds-r",
fastForward.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
assertEquals("a", last.getNodeName());
assertEquals("rf-ds-btn rf-ds-r",
last.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+ assertEquals("a", next.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-r",
next.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
fastForward = getFastForwardButton(page, secondScrollerId);
last = getFastForwardButton(page, secondScrollerId);
-
+ next = getNextButton(page, secondScrollerId);
+
assertEquals("a", fastForward.getNodeName());
assertEquals("rf-ds-btn rf-ds-r",
fastForward.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
assertEquals("a", last.getNodeName());
assertEquals("rf-ds-btn rf-ds-r",
last.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+ assertEquals("a", next.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-r",
next.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
//check if left buttons is disabled
HtmlElement fastRewind = getFastRewindButton(page, firstScrollerId);
HtmlElement first = getFirstButton(page, firstScrollerId);
+ HtmlElement previous = getPreviousButton(page, firstScrollerId);
assertEquals("span", fastRewind.getNodeName());
assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
fastRewind.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
@@ -360,20 +470,28 @@
assertEquals("span", first.getNodeName());
assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
first.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+ assertEquals("span", previous.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
previous.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
fastRewind = getFastRewindButton(page, secondScrollerId);
first = getFirstButton(page, secondScrollerId);
+ next = getNextButton(page, secondScrollerId);
assertEquals("span", fastRewind.getNodeName());
assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
fastRewind.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
assertEquals("span", first.getNodeName());
- assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
first.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+ assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
first.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ assertEquals("span", previous.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
previous.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
}
private void checkLastPageButtons(HtmlPage page, String firstScrollerId, String
secondScrollerId) throws Exception {
//check if right buttons is disabled
HtmlElement fastForward = getFastForwardButton(page, firstScrollerId);
HtmlElement last = getLastButton(page, firstScrollerId);
+ HtmlElement next = getNextButton(page, firstScrollerId);
assertEquals("span", fastForward.getNodeName());
assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
fastForward.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
@@ -381,8 +499,13 @@
assertEquals("span", last.getNodeName());
assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
last.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+ assertEquals("span", next.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
next.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+
fastForward = getFastForwardButton(page, secondScrollerId);
last = getFastForwardButton(page, secondScrollerId);
+ next = getNextButton(page, secondScrollerId);
assertEquals("span", fastForward.getNodeName());
assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
fastForward.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
@@ -390,9 +513,13 @@
assertEquals("span", last.getNodeName());
assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
last.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+ assertEquals("span", next.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
next.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
//check if left buttons is enabled
HtmlElement fastRewind = getFastRewindButton(page, firstScrollerId);
HtmlElement first = getFirstButton(page, firstScrollerId);
+ HtmlElement previous = getPreviousButton(page, firstScrollerId);
assertEquals("a", fastRewind.getNodeName());
assertEquals("rf-ds-btn rf-ds-l",
fastRewind.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
@@ -400,14 +527,21 @@
assertEquals("a", first.getNodeName());
assertEquals("rf-ds-btn rf-ds-l",
first.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+ assertEquals("a", previous.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-l",
previous.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
fastRewind = getFastRewindButton(page, secondScrollerId);
first = getFirstButton(page, secondScrollerId);
+ previous = getPreviousButton(page, secondScrollerId);
assertEquals("a", fastRewind.getNodeName());
assertEquals("rf-ds-btn rf-ds-l",
fastRewind.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
assertEquals("a", first.getNodeName());
assertEquals("rf-ds-btn rf-ds-l",
first.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ assertEquals("a", previous.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-l",
previous.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
}
private String getCurrentPageContent(HtmlPage page, int i) throws Exception {
@@ -417,6 +551,14 @@
return text.getNodeValue();
}
+ private HtmlElement getPreviousButton(HtmlPage page, String scrollerId) {
+ return page.getFirstByXPath("//*[@id = 'form:" + scrollerId
+"_ds_prev']");
+ }
+
+ private HtmlElement getNextButton(HtmlPage page, String scrollerId) {
+ return page.getFirstByXPath("//*[@id = 'form:" + scrollerId
+"_ds_next']");
+ }
+
private HtmlElement getFastRewindButton(HtmlPage page, String scrollerId) {
return page.getFirstByXPath("//*[@id = 'form:" + scrollerId
+"_ds_fr']");
}
Modified:
trunk/ui/iteration/ui/src/test/resources/org/richfaces/renderkit/dataTableTest.xhtml
===================================================================
---
trunk/ui/iteration/ui/src/test/resources/org/richfaces/renderkit/dataTableTest.xhtml 2010-09-01
10:57:22 UTC (rev 19065)
+++
trunk/ui/iteration/ui/src/test/resources/org/richfaces/renderkit/dataTableTest.xhtml 2010-09-01
10:59:33 UTC (rev 19066)
@@ -13,7 +13,7 @@
<h:body>
<h:form id="form">
- <it:dataScroller id="scroller1" for="richTable"
page="#{dataScrollerBean.pageNumber}"
maxPages="6"></it:dataScroller>
+ <it:dataScroller fastStep="2" id="scroller1"
for="richTable" page="#{dataScrollerBean.pageNumber}"
maxPages="5"></it:dataScroller>
<it:dataTable id="richTable" rowKeyVar="rowKey"
var="content" value="#{dataScrollerBean.content}"
rows="1">
<it:column>
<h:panelGroup id="pageContent">
@@ -21,7 +21,7 @@
</h:panelGroup>
</it:column>
<f:facet name="footer">
- <it:dataScroller id="scroller2" for="richTable"
page="#{dataScrollerBean.pageNumber}"
maxPages="6"></it:dataScroller>
+ <it:dataScroller fastStep="2" id="scroller2"
for="richTable" page="#{dataScrollerBean.pageNumber}"
maxPages="5"></it:dataScroller>
</f:facet>
</it:dataTable>
</h:form>