Author: dsvyatobatsko
Date: 2008-12-04 11:12:22 -0500 (Thu, 04 Dec 2008)
New Revision: 11553
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5155
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-04
15:50:54 UTC (rev 11552)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-04
16:12:22 UTC (rev 11553)
@@ -92,6 +92,10 @@
String currentDateHeaderXpath;
+ String popupButtonId;
+
+ String inputDateId;
+
void initIds(String parentId) {
calendarId = parentId + FORM_ID + "calendar";
calendarHeaderId = calendarId + "Header";
@@ -116,6 +120,8 @@
timeZoneId = parentId + CONTROLS_FORM_ID + "timeZone";
localeId = parentId + CONTROLS_FORM_ID + "locale";
currentDateHeaderXpath =
"//td[@id='"+calendarHeaderId+"']/table/tbody/tr/td[3]/div";
+ popupButtonId = calendarId + "PopupButton";
+ inputDateId = calendarId + "InputDate";
}
String getStatus() {
@@ -370,14 +376,53 @@
Assert.assertFalse(isVisibleById(calendarOpenedId), "Calendar window should
NOT be visible on the component!");
}
-// @Test
-// public void testValueAndCurrentDateOfCalendarInCaseOfPopupTrue(Template template)
{
-// renderPage(template);
-// //1. value != null + curr_date != null
-// //2. value != null + curr_date == null
-// //3. value == null + curr_date == null
-// }
+ @Test
+ public void testValueAndCurrentDateOfCalendarInCaseOfPopupTrue(Template template) {
+ renderPage(template);
+ initIds(getParentId());
+ String expectedSelectedDate = "03/03/2007 11:00";
+ String expectedCurrentDate = "04/04/2008 13:00";
+ setPopup(true);
+ writeStatus("Check that in popup mode currentDate attribute is ignored in
all cases");
+
+ //1. value != null + curr_date != null
+ setValueById(selectedDateId, expectedSelectedDate);
+ setValueById(currentDateId, expectedCurrentDate);
+ setup();
+
+ showPopup();
+ writeStatus("Check calendar popup is shown up");
+ Assert.assertTrue(isVisible(calendarId), "Calendar popup is not
visible");
+
+ writeStatus("Check selected date");
+ AssertValueEquals(inputDateId, expectedSelectedDate, "Calendar shows wrong
date");
+
+ writeStatus("Check current month and year. Remind! Current date has to be
ignored. Value date is used instead");
+ String currentDate = selenium.getText(currentDateHeaderXpath);
+ Assert.assertEquals(currentDate, "March, 2007", "Calendar shows
wrong current date");
+
+ //2. value == null + curr_date != null
+ setValueById(selectedDateId, "");
+ setValueById(currentDateId, expectedCurrentDate);
+ setup();
+
+ showPopup();
+ writeStatus("Check selected date is empty");
+ AssertValueEquals(inputDateId, "", "Calendar value must be
empty");
+
+ writeStatus("Check current month and year. Remind! Current date has to be
ignored as before. Value date is empty, present date is used");
+ currentDate = selenium.getText(currentDateHeaderXpath);
+
+ Locale locale = new Locale(selenium.getText(localeId));
+ Date presentTime = Calendar.getInstance(locale).getTime();
+ String month = DateUtils.month(presentTime, locale);
+ int year = DateUtils.year(presentTime);
+ String month_year = month + ", " + year;
+
+ Assert.assertEquals(currentDate, month_year, "Calendar shows wrong current
date");
+ }
+
@Test
public void testValueAndCurrentDateOfCalendarWithPopupFalse(Template template) {
renderPage(template, null);
@@ -390,7 +435,7 @@
writeStatus("Check whether the component is present and up to the mark if
value and currentDate are defined");
setValueById(selectedDateId, expectedSelectedDate);
setValueById(currentDateId, expectedCurrentDate);
- clickCommandAndWait(setupActionId);
+ setup();
writeStatus("Check calendar panel has been rendered");
Assert.assertTrue(isVisible(calendarId), "Calendar panel is not
visible");
@@ -410,7 +455,7 @@
setValueById(selectedDateId, expectedSelectedDate);
setValueById(currentDateId, "");
- clickCommandAndWait(setupActionId);
+ setup();
writeStatus("Check selected date");
date = selenium.getText(dateSelectionXpath);
@@ -426,7 +471,7 @@
writeStatus("Check whether the component is present and up to the mark if
value and currentDate are not defined");
setValueById(selectedDateId, "");
setValueById(currentDateId, "");
- clickCommandAndWait(setupActionId);
+ setup();
writeStatus("Selected date is null. Selected value panel is not
visible");
Assert.assertFalse(isVisible(dateSelectionXpath), "Footer with selected date
has to be invisible");
@@ -448,6 +493,15 @@
runScript("$('" + isPopupId + "').checked=" +
isPopup);
}
+ private void setup() {
+ clickCommandAndWait(setupActionId);
+ }
+
+ private void showPopup() {
+ writeStatus("Show popup");
+ clickById(popupButtonId);
+ }
+
public String getTestUrl() {
return "pages/calendar/calendarTest.xhtml";
}