Author: dsvyatobatsko
Date: 2008-12-10 04:32:00 -0500 (Wed, 10 Dec 2008)
New Revision: 11687
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/todayControlModeTest.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5250
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-09
22:14:40 UTC (rev 11686)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-10
09:32:00 UTC (rev 11687)
@@ -432,4 +432,22 @@
showWeeksBar = true;
}
+ private String todayControlMode = "select";
+
+ /**
+ * Gets value of todayControlMode field.
+ * @return value of todayControlMode field
+ */
+ public String getTodayControlMode() {
+ return todayControlMode;
+ }
+
+ /**
+ * Set a new value for todayControlMode field.
+ * @param todayControlMode a new value for todayControlMode field
+ */
+ public void setTodayControlMode(String todayControlMode) {
+ this.todayControlMode = todayControlMode;
+ }
+
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/todayControlModeTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/todayControlModeTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
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-09
22:14:40 UTC (rev 11686)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-10
09:32:00 UTC (rev 11687)
@@ -22,6 +22,7 @@
package org.richfaces.testng;
import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
@@ -45,6 +46,8 @@
static final String SHOW_ATTRIBURES_TEST_URL =
"pages/calendar/showAttributesTest.xhtml";
+ static final String TODAY_CONTROL_MODE_URL =
"pages/calendar/todayControlModeTest.xhtml";
+
static final String CONTROLS_FORM_ID = "_controls:";
static final String availableDayCellClass = "rich-calendar-cell-size
rich-calendar-cell rich-calendar-btn";
@@ -117,6 +120,10 @@
String showPopupId;
+ String todayControlModeId;
+
+ String todayControlXpath;
+
void initIds(String parentId) {
calendarId = parentId + FORM_ID + "calendar";
calendarHeaderId = calendarId + "Header";
@@ -151,6 +158,8 @@
showWeeksBarId = parentId + FORM_ID + "showWeeksBar";
showPopupId = parentId + FORM_ID + "showPopup";
weekDaysBarId = calendarId + "WeekDay";
+ todayControlModeId = parentId + FORM_ID + "todayControlMode";
+ todayControlXpath = "//td[@id='" + calendarFooterId +
"']/table/tbody/tr/td[5]";
}
String getStatus() {
@@ -774,6 +783,89 @@
Assert.assertFalse(isVisible(applyButtonXpath), "Apply button is
visible");
}
+ @Test
+ public void testTodayControlMode(Template template) {
+ renderPage(TODAY_CONTROL_MODE_URL, template, null);
+ initIds(getParentId());
+
+ String datePattern = selenium.getText(getParentId() + FORM_ID +
"datePattern");
+ Locale locale = new Locale(selenium.getText(getParentId() + FORM_ID +
"locale"));
+ Date presentTime = Calendar.getInstance(locale).getTime();
+ String month = DateUtils.month(presentTime, locale);
+ int year = DateUtils.year(presentTime);
+ String expectedCurrentMonthYearHeader = month + ", " + year;
+ String expectedTodaySelectedDate = new SimpleDateFormat(datePattern).format(new
Date());
+
+ writeStatus("Check 'todayControlMode' attribute");
+
+ //select mode
+ writeStatus("Check 'select' mode (default). Control 'Today'
should scroll calendar to current date and set selected date to today");
+ selenium.select(todayControlModeId, "select");
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+
+ selenium.click(todayControlXpath + "/div");
+ String actualSelectedDate = selenium.getValue(inputDateId);
+ String actualCurrentDate = selenium.getText(currentDateHeaderXpath);
+
+ writeStatus("Check selected date and current date set to now");
+ //TODO: time ain't set to current time ... is it true? find out!
+ Assert.assertEquals(actualSelectedDate, expectedTodaySelectedDate);
+ Assert.assertEquals(actualCurrentDate, expectedCurrentMonthYearHeader);
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+ showPopup();
+ writeStatus("Check calendar popup is shown up");
+ Assert.assertTrue(isVisible(calendarId), "Calendar popup is not
visible");
+
+ selenium.click(todayControlXpath + "/div");
+ Assert.assertEquals(actualSelectedDate, expectedTodaySelectedDate);
+ Assert.assertEquals(actualCurrentDate, expectedCurrentMonthYearHeader);
+
+ //scroll mode
+ writeStatus("Check 'scroll' mode. Control 'Today' should
just scroll calendar to current date not changing selected date");
+ selenium.select(todayControlModeId, "scroll");
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+
+ String previuosSelectedDate = selenium.getValue(inputDateId);
+ selenium.click(todayControlXpath + "/div");
+ actualSelectedDate = selenium.getValue(inputDateId);
+ actualCurrentDate = selenium.getText(currentDateHeaderXpath);
+
+ writeStatus("Check selected date is not affected, current date set to now
(month, year)");
+ Assert.assertEquals(actualSelectedDate, previuosSelectedDate);
+ Assert.assertEquals(actualCurrentDate, expectedCurrentMonthYearHeader);
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+ showPopup();
+ writeStatus("Check calendar popup is shown up");
+ Assert.assertTrue(isVisible(calendarId), "Calendar popup is not
visible");
+
+ previuosSelectedDate = selenium.getValue(inputDateId);
+ selenium.click(todayControlXpath + "/div");
+ actualSelectedDate = selenium.getValue(inputDateId);
+ actualCurrentDate = selenium.getText(currentDateHeaderXpath);
+ Assert.assertEquals(actualSelectedDate, previuosSelectedDate);
+ Assert.assertEquals(actualCurrentDate, expectedCurrentMonthYearHeader);
+
+ //hidden mode
+ writeStatus("Check 'hidden' mode. Control 'Today' has to be
hidden");
+ selenium.select(todayControlModeId, "hidden");
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+ Assert.assertFalse(isVisible(todayControlXpath), "Control 'Today'
has to be hidden");
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+ showPopup();
+ writeStatus("Check calendar popup is shown up");
+ Assert.assertTrue(isVisible(calendarId), "Calendar popup is not
visible");
+ Assert.assertFalse(isVisible(todayControlXpath), "Control 'Today'
has to be hidden");
+ }
+
private void setPopup(boolean isPopup) {
runScript("$('" + isPopupId + "').checked=" +
isPopup);
}