Author: dsvyatobatsko
Date: 2008-12-08 11:25:49 -0500 (Mon, 08 Dec 2008)
New Revision: 11643
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/showAttributesTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5254 completed
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-08
15:47:24 UTC (rev 11642)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-08
16:25:49 UTC (rev 11643)
@@ -423,7 +423,7 @@
this.showWeeksBar = showWeeksBar;
}
- public void initShowAttributes() {
+ public void initShowAttributesTest() {
showApplyButton = true;
showHeader = true;
showFooter = true;
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/showAttributesTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-08
15:47:24 UTC (rev 11642)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-08
16:25:49 UTC (rev 11643)
@@ -39,7 +39,7 @@
static final String RESET_METHOD = "#{calendarBean.reset}";
- static final String INIT_SHOW_ATTRIBUTES =
"#{calendarBean.initShowAttributes}";
+ static final String INIT_SHOW_ATTRIBUTES_TEST =
"#{calendarBean.initShowAttributesTest}";
static final String FORM_ID = "_form:";
@@ -57,6 +57,8 @@
String calendarFooterId;
+ String weekDaysBarId;
+
String ajaxSubmitId;
String serverSubmitId;
@@ -101,6 +103,20 @@
String inputDateId;
+ String showApplyButtonId;
+
+ String showHeaderId;
+
+ String showFooterId;
+
+ String showInputId;
+
+ String showWeekDaysBarId;
+
+ String showWeeksBarId;
+
+ String showPopupId;
+
void initIds(String parentId) {
calendarId = parentId + FORM_ID + "calendar";
calendarHeaderId = calendarId + "Header";
@@ -127,6 +143,14 @@
currentDateHeaderXpath =
"//td[@id='"+calendarHeaderId+"']/table/tbody/tr/td[3]/div";
popupButtonId = calendarId + "PopupButton";
inputDateId = calendarId + "InputDate";
+ showApplyButtonId = parentId + FORM_ID + "showApplyButton";
+ showHeaderId = parentId + FORM_ID + "showHeader";
+ showFooterId = parentId + FORM_ID + "showFooter";
+ showInputId = parentId + FORM_ID + "showInput";
+ showWeekDaysBarId = parentId + FORM_ID + "showWeekDaysBar";
+ showWeeksBarId = parentId + FORM_ID + "showWeeksBar";
+ showPopupId = parentId + FORM_ID + "showPopup";
+ weekDaysBarId = calendarId + "WeekDay";
}
String getStatus() {
@@ -628,15 +652,138 @@
@Test
public void testShowHeaderAttribute(Template template) {
- renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES);
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ writeStatus("Check 'showHeader' attribute");
+
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+
+ AssertPresent(calendarHeaderId, "Header is not present");
+ check(showHeaderId, false);
+ AssertNotPresent(calendarHeaderId, "Header is present");
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+
+ showPopup();
+
+ AssertNotPresent(calendarHeaderId, "Header is present");
+ check(showHeaderId, true);
+ AssertPresent(calendarHeaderId, "Header is not present");
}
+ @Test
+ public void testShowFooterAttribute(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ writeStatus("Check 'showFooter' attribute");
+
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+
+ AssertPresent(calendarFooterId, "Footer is not present");
+ check(showFooterId, false);
+ AssertNotPresent(calendarFooterId, "Footer is present");
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+
+ showPopup();
+
+ AssertNotPresent(calendarFooterId, "Footer is present");
+ check(showFooterId, true);
+ AssertPresent(calendarFooterId, "Footer is not present");
+ }
+
+ @Test
+ public void testShowWeekDaysBar(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ writeStatus("Check 'showWeekDaysBar' attribute");
+
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+
+ AssertPresent(weekDaysBarId, "Week days bar is not present");
+ check(showWeekDaysBarId, false);
+ AssertNotPresent(weekDaysBarId, "Week days bar is present");
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+
+ showPopup();
+
+ AssertNotPresent(weekDaysBarId, "Week days bar is present");
+ check(showWeekDaysBarId, true);
+ AssertPresent(weekDaysBarId, "Week days bar is not present");
+ }
+
+ @Test
+ public void testShowWeeksBar(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ String weeksBarId = calendarId + "WeekNumCell1";
+ writeStatus("Check 'showWeeksBar' attribute");
+
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+
+ AssertPresent(weeksBarId, "Weeks bar is not present");
+ check(showWeeksBarId, false);
+ AssertNotPresent(weeksBarId, "Weeks bar is present");
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+
+ showPopup();
+
+ AssertNotPresent(weeksBarId, "Weeks bar is present");
+ check(showWeeksBarId, true);
+ AssertPresent(weeksBarId, "Weeks bar is not present");
+ }
+
+ @Test
+ public void testShowInput(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ writeStatus("Check 'showInput' attribute");
+
+ writeStatus("This attribute makes sense in popup mode only");
+ check(showPopupId, true);
+
+ AssertVisible(inputDateId, "Input is not visible");
+ check(showInputId, false);
+ AssertNotVisible(inputDateId, "Input is visible");
+ }
+
+ @Test
+ public void testShowApplyButton(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ String applyButtonXpath = "//td[@id='" + calendarFooterId +
"']/table/tbody/tr/td[6]";
+ writeStatus("Check 'showApplyButton' attribute");
+
+ writeStatus("This attribute makes sense in popup mode only");
+ check(showPopupId, true);
+
+ showPopup();
+
+ Assert.assertTrue(isVisible(applyButtonXpath), "Apply button is not
visible");
+ check(showApplyButtonId, false);
+ Assert.assertFalse(isVisible(applyButtonXpath), "Apply button is
visible");
+ }
+
private void setPopup(boolean isPopup) {
- check(isPopupId, isPopup);
+ runScript("$('" + isPopupId + "').checked=" +
isPopup);
}
- private void check(String checkBoxId, boolean isChecked) {
- runScript("$('" + checkBoxId + "').checked=" +
isChecked);
+ private boolean check(String checkBoxId, boolean isChecked) {
+ boolean prevValue = Boolean.parseBoolean(runScript("$('" +
checkBoxId + "').checked"));
+ if (prevValue != isChecked) {
+ clickAjaxCommandAndWait(checkBoxId);
+ }
+ return prevValue;
}
private void setup() {