[richfaces-svn-commits] JBoss Rich Faces SVN: r11850 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/calendar and 1 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Wed Dec 17 10:40:28 EST 2008
Author: dsvyatobatsko
Date: 2008-12-17 10:40:28 -0500 (Wed, 17 Dec 2008)
New Revision: 11850
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/resetTimeOnDateSelectTest.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-5347
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-17 15:05:42 UTC (rev 11849)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-17 15:40:28 UTC (rev 11850)
@@ -85,6 +85,7 @@
public CalendarTestBean() {
selectedDate = DEFAULT_DATE;
+ defaultTime = new Date();
resetSelectedDateString();
datePattern = DATE_PATTERN;
@@ -572,4 +573,40 @@
this.disabled = disabled;
}
+ private Date defaultTime;
+
+ /**
+ * Gets value of defaultTime field.
+ * @return value of defaultTime field
+ */
+ public Date getDefaultTime() {
+ return defaultTime;
+ }
+
+ /**
+ * Set a new value for defaultTime field.
+ * @param defaultTime a new value for defaultTime field
+ */
+ public void setDefaultTime(Date defaultTime) {
+ this.defaultTime = defaultTime;
+ }
+
+ private boolean resetTimeOnDateSelect;
+
+ /**
+ * Gets value of resetTimeOnDateSelect field.
+ * @return value of resetTimeOnDateSelect field
+ */
+ public boolean isResetTimeOnDateSelect() {
+ return resetTimeOnDateSelect;
+ }
+
+ /**
+ * Set a new value for resetTimeOnDateSelect field.
+ * @param resetTimeOnDateSelect a new value for resetTimeOnDateSelect field
+ */
+ public void setResetTimeOnDateSelect(boolean resetTimeOnDateSelect) {
+ this.resetTimeOnDateSelect = resetTimeOnDateSelect;
+ }
+
}
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/resetTimeOnDateSelectTest.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/resetTimeOnDateSelectTest.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-17 15:05:42 UTC (rev 11849)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-17 15:40:28 UTC (rev 11850)
@@ -67,6 +67,8 @@
static final String IMMEDIATE_TEST_URL = "pages/calendar/testImmediate.xhtml";
+ static final String RESET_TIME_ON_DATE_SELECTION_TEST_URL = "pages/calendar/resetTimeOnDateSelectTest.xhtml";
+
static final String CONTROLS_FORM_ID = "_controls:";
static final String availableDayCellClass = "rich-calendar-cell-size rich-calendar-cell rich-calendar-btn";
@@ -172,6 +174,10 @@
String isDisabledId;
+ String defaultTimeId;
+
+ String resetTimeOnDateSelectId;
+
void initIds(String parentId) {
calendarId = parentId + FORM_ID + "calendar";
calendarHeaderId = calendarId + "Header";
@@ -215,6 +221,8 @@
calendarMessageId = parentId + FORM_ID + "calendarMsg";
firstWeekDayId = parentId + FORM_ID + "firstWeekDay";
isDisabledId = parentId + FORM_ID + "isDisabled";
+ defaultTimeId = parentId + CONTROLS_FORM_ID + "defaultTime";
+ resetTimeOnDateSelectId = parentId + CONTROLS_FORM_ID + "resetTimeOnDateSelect";
}
String getStatus() {
@@ -1445,10 +1453,58 @@
Assert.assertEquals(selenium.getElementWidth(calendarId + "DayCell5").intValue(), expectedCellWidth);
}
+ @Test
+ public void testResetTimeOnDateSelect(Template template) {
+ renderPage(RESET_TIME_ON_DATE_SELECTION_TEST_URL, template, null);
+ initIds(getParentId());
+
+ String expectedDefaultTime = "05/05/2007 13:13";
+ String notEmptySelectedDate = "04/04/2006 10:00";
+
+ writeStatus("Check 'defaultTime' and 'resetTimeOnDateSelect' attributes");
+
+ writeStatus("Check time of selected date replaced by defaultTime in case of 'resetTimeOnDateSelect' attribute being true");
+ setValueById(defaultTimeId, expectedDefaultTime);
+ setValueById(selectedDateId, notEmptySelectedDate);
+ checkWithoutClick(resetTimeOnDateSelectId, true);
+ ajaxSetup();
+
+ selenium.click(todayControlXpath + "/div");
+ String actualSelectedDate = selenium.getValue(inputDateId);
+ //current date time with time replaced by default time
+ String expectedReplacedTodaySelectedDate = new SimpleDateFormat("MM/dd/yyyy").format(new Date()) + " 13:13";
+ Assert.assertEquals(actualSelectedDate, expectedReplacedTodaySelectedDate);
+
+ writeStatus("Check time of selected date replaced by defaultTime if value (selected date) is empty");
+ setValueById(selectedDateId, "");
+ checkWithoutClick(resetTimeOnDateSelectId, false);
+ ajaxSetup();
+
+ selenium.click(todayControlXpath + "/div");
+ actualSelectedDate = selenium.getValue(inputDateId);
+ expectedReplacedTodaySelectedDate = new SimpleDateFormat("MM/dd/yyyy").format(new Date()) + " 13:13";
+ Assert.assertEquals(actualSelectedDate, expectedReplacedTodaySelectedDate);
+
+ writeStatus("if value (selected date) is not empty and resetTimeOnDateSelect' attribute is not true then nothing happens");
+ setValueById(selectedDateId, notEmptySelectedDate);
+ checkWithoutClick(resetTimeOnDateSelectId, false);
+ ajaxSetup();
+
+ selenium.click(todayControlXpath + "/div");
+ actualSelectedDate = selenium.getValue(inputDateId);
+ String expectedTodaySelectedDate = new SimpleDateFormat("MM/dd/yyyy").format(new Date()) + " 10:10";
+ //side effect of https://jira.jboss.org/jira/browse/RF-5221
+ Assert.assertEquals(actualSelectedDate, expectedTodaySelectedDate);
+ }
+
private void setPopup(boolean isPopup) {
runScript("$('" + isPopupId + "').checked=" + isPopup);
}
+ private void checkWithoutClick(String id, boolean isChecked) {
+ runScript("$('" + id + "').checked=" + isChecked);
+ }
+
private boolean check(String checkBoxId, boolean isChecked) {
boolean prevValue = Boolean.parseBoolean(runScript("$('" + checkBoxId + "').checked"));
if (prevValue != isChecked) {
More information about the richfaces-svn-commits
mailing list