Author: andrei_exadel
Date: 2008-12-04 09:12:13 -0500 (Thu, 04 Dec 2008)
New Revision: 11546
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarDataModel.java
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:
Sub-task RF-5151
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarDataModel.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarDataModel.java 2008-12-04
13:38:46 UTC (rev 11545)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarDataModel.java 2008-12-04
14:12:13 UTC (rev 11546)
@@ -40,13 +40,15 @@
int day;
Object data;
+ Calendar calendar;
public CalendarDataModelItemImpl(Date date) {
Map<String, String> data = new HashMap<String, String>();
Calendar c = Calendar.getInstance();
c.setTime(date);
day = c.get(Calendar.DAY_OF_MONTH);
- this.data = data;
+ this.data = data;
+ this.calendar = c;
}
public Object getData() {
@@ -58,7 +60,7 @@
}
public String getStyleClass() {
- return null;
+ return "styleClass" + this.calendar.get(Calendar.MONTH) + day;
}
public Object getToolTip() {
@@ -70,7 +72,7 @@
}
public boolean isEnabled() {
- return true;
+ return day != 13;
}
}
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-04
13:38:46 UTC (rev 11545)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-04
14:12:13 UTC (rev 11546)
@@ -42,7 +42,7 @@
public static final String DATE_PATTERN = "MM/dd/yyyy HH:mm";
- public static final Locale LOCALE = new Locale("US");
+ public static final Locale LOCALE = Locale.US;
public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("GMT+2");
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
13:38:46 UTC (rev 11545)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-04
14:12:13 UTC (rev 11546)
@@ -33,6 +33,8 @@
import org.testng.Assert;
import org.testng.annotations.Test;
+import com.thoughtworks.selenium.SeleniumException;
+
public class CalendarTest extends SeleniumTestBase {
static final String RESET_METHOD = "#{calendarBean.reset}";
@@ -41,6 +43,8 @@
static final String CONTROLS_FORM_ID = "_controls:";
static final String availableDayCellClass = "rich-calendar-cell-size
rich-calendar-cell rich-calendar-btn";
+
+ static final String disabledDayCellClass = "rich-calendar-cell-size
rich-calendar-cell rich-calendar-boundary-dates";
String calendarId;
@@ -140,7 +144,7 @@
void changeDate() {
String weekNumId = calendarId + "WeekNum2";
- selenium.click("//tr[@id='" + weekNumId +
"']/td[@class='" + availableDayCellClass + "']");
+ selenium.click("//tr[@id='" + weekNumId +
"']/td[starts-with(@class, '" + availableDayCellClass +
"')]");
}
void changeCurrentDate(boolean wait4ajax) {
@@ -162,7 +166,49 @@
selenium.click(timeSelectionXpath);
}
+ void _testModelDataAppliedToClient() {
+ String currentDate = selenium.getText(dateSelectionXpath);
+
selenium.click("//table[@id='"+calendarId+"']/tbody/tr/td[text() =
'13']");
+
+ if (!selenium.getText(dateSelectionXpath).equals(currentDate)) {
+ Assert.fail("Enabled attribute of data model was not applied for client
data. 13th day should disabled and should force date change after click.");
+ }
+
+ Calendar c = Calendar.getInstance();
+ c.setTime(new Date());
+ int currentMonth = c.get(Calendar.MONTH);
+
+ String cellDay7StyleClass =
selenium.getAttribute("//table[@id='"+calendarId+"']/tbody/tr/td[text()
= '7']/@class");
+ String cellDay7ModelClass = "styleClass"+currentMonth+"7";
+ if (cellDay7StyleClass == null || cellDay7StyleClass.indexOf(cellDay7ModelClass)
== -1) {
+ Assert.fail("Style class was not applied from data model to cell days.
Style class for 7th day should contain [" + cellDay7ModelClass + "]. But has
only + [" + cellDay7StyleClass +"]");
+ }
+
+ String cellDay5StyleClass =
selenium.getAttribute("//table[@id='"+calendarId+"']/tbody/tr/td[text()
= '5']/@class");
+ String cellDay5ModelClass = "styleClass"+currentMonth+"5";
+ if (cellDay5StyleClass == null || cellDay5StyleClass.indexOf(cellDay5ModelClass)
== -1) {
+ Assert.fail("Style class was not applied from data model to cell days.
Style class for 5th day should contain [" + cellDay5ModelClass + "]. But has
only + [" + cellDay5StyleClass +"]");
+ }
+ }
+
@Test
+ public void testDataModelAttribute(Template template) {
+ renderPage(template, RESET_METHOD);
+ initIds(getParentId());
+
+ _testModelDataAppliedToClient();
+
+ try {
+ changeCurrentDate(true);
+ }catch (SeleniumException exception) {
+ Assert.fail("Celendar in ajax mode does not request for the next portion of data
after current date has been changed");
+ }
+
+ _testModelDataAppliedToClient();
+
+ }
+
+ @Test
public void testTimeSelection(Template template) {
renderPage(template, RESET_METHOD);
initIds(getParentId());
@@ -210,7 +256,7 @@
}
- //@Test
+ @Test
public void testListenersInAjaxMode(Template template) {
renderPage(template, RESET_METHOD);
initIds(getParentId());
@@ -229,7 +275,7 @@
}
- //@Test
+ @Test
public void testListenersInClientMode(Template template) {
renderPage(template, RESET_METHOD);
initIds(getParentId());
@@ -250,9 +296,9 @@
}
- // @Test
+ //@Test
public void testCalendarComponent(Template template) {
- renderPage(template);
+ renderPage(template);
String containerId = getParentId() + "_form:";
String calendarOpenedId = containerId + "calendar";
Show replies by date