Author: dsvyatobatsko
Date: 2008-12-05 13:20:20 -0500 (Fri, 05 Dec 2008)
New Revision: 11595
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5247
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-05
18:12:58 UTC (rev 11594)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-05
18:20:20 UTC (rev 11595)
@@ -555,6 +555,72 @@
Assert.assertEquals(currentDate, month_year, "Calendar shows wrong current
date");
}
+ @Test
+ public void testDatePatternNonPopupMode(Template template) {
+ renderPage(template, null);
+ initIds(getParentId());
+ String originalPattern = "MM/dd/yyyy HH:mm";
+ writeStatus("Check 'datePattern' attribute in non-popup
mode");
+
+ String selectedDate = "03/03/2007 11:00";
+ String expectedSelectedDate = "03/2007";
+ String expectedPattern = "MM/yyyy";
+
+ setValueById(selectedDateId, selectedDate);
+ setValueById(currentDateId, "");
+ setValueById(datePatternId, expectedPattern);
+ setPopup(false);
+ setup();
+
+ try {
+ writeStatus("Check displayed date. It should be in 'MM/yyyy'
format - time part is not visible at all");
+ String date = selenium.getText(dateSelectionXpath);
+ Assert.assertEquals(date, expectedSelectedDate, "Calendar shows date in
wrong format");
+ Assert.assertFalse(isVisible(timeSelectionXpathMinusDiv), "Time part has
to be invisible");
+ } catch (AssertionError ae) {
+ Assert.fail(ae.getMessage());
+ } finally {
+ setValueById(datePatternId, originalPattern);
+ setup();
+ }
+ }
+
+ @Test
+ public void testDatePatternPopupMode(Template template) {
+ renderPage(template, null);
+ initIds(getParentId());
+ String originalPattern = "MM/dd/yyyy HH:mm";
+ writeStatus("Check 'datePattern' attribute in popup mode");
+
+ String selectedDate = "03/03/2007 11:00";
+ String expectedSelectedDate = "03/2007";
+ String expectedPattern = "MM/yyyy";
+
+ setValueById(selectedDateId, selectedDate);
+ setValueById(currentDateId, "");
+ setValueById(datePatternId, expectedPattern);
+
+ setPopup(true);
+ setup();
+ showPopup();
+
+ try {
+ writeStatus("Check calendar popup is shown up and date in the input
field is in proper format");
+ Assert.assertTrue(isVisible(calendarId), "Calendar popup is not
visible");
+ AssertValueEquals(inputDateId, expectedSelectedDate, "Calendar input
field shows wrong date");
+
+ writeStatus("Check displayed date again. It as before should be in
'MM/yyyy' format - time part is not visible at all");
+ String date = selenium.getText(dateSelectionXpath);
+ Assert.assertEquals(date, expectedSelectedDate, "Calendar shows date in
wrong format");
+ Assert.assertFalse(isVisible(timeSelectionXpathMinusDiv), "Time part has
to be invisible");
+ } catch (AssertionError ae) {
+ Assert.fail(ae.getMessage());
+ } finally {
+ setValueById(datePatternId, originalPattern);
+ setup();
+ }
+ }
+
private void setPopup(boolean isPopup) {
runScript("$('" + isPopupId + "').checked=" +
isPopup);
}