[richfaces-svn-commits] JBoss Rich Faces SVN: r12075 - 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
Tue Dec 30 10:48:26 EST 2008


Author: alevkovsky
Date: 2008-12-30 10:48:26 -0500 (Tue, 30 Dec 2008)
New Revision: 12075

Modified:
   trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
   trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarTest.xhtml
   trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/showAttributesTest.xhtml
   trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/todayControlAndBoundaryDatesModesTest.xhtml
   trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
Fix failed calendar selenium tests

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-30 14:34:11 UTC (rev 12074)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java	2008-12-30 15:48:26 UTC (rev 12075)
@@ -237,12 +237,35 @@
         NULLModel = false;
         firstWeekDay = 0;
         disabled = false;
+        datePattern = DATE_PATTERN;
     }
+    
+    public void reset2() {
+        selectedDate = DEFAULT_DATE;
+        currentDate = getDayInMay(5);
+        defaultTime = new Date();
+        resetSelectedDateString();
 
+        datePattern = DATE_PATTERN;
+        locale = LOCALE;
+        timeZone = TIME_ZONE;
+        Calendar c = getLocale()!=null ? Calendar.getInstance(getLocale()) : Calendar.getInstance();
+        c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH) - 1, 1); 
+        preloadDateRangeStart = c.getTime(); // Set preloadBegin by the first day of the last month
+        c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH) + 3, 0);
+        preloadDateRangeEnd = c.getTime(); // Set preloadEnd by the last day of the next month
+        isPopup = true;
+    }
+
     public String resetAction() {
         reset();
         return null;
     }
+    
+    public String resetAction2() {
+        reset2();
+        return null;
+    }
 
     public String getStatus() {
         return status;

Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarTest.xhtml
===================================================================
(Binary files differ)

Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/showAttributesTest.xhtml
===================================================================
(Binary files differ)

Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/todayControlAndBoundaryDatesModesTest.xhtml
===================================================================
(Binary files differ)

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-30 14:34:11 UTC (rev 12074)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java	2008-12-30 15:48:26 UTC (rev 12075)
@@ -50,6 +50,8 @@
 public class CalendarTest extends SeleniumTestBase {
 
     static final String RESET_METHOD = "#{calendarBean.reset}";
+    
+    static final String RESET_METHOD2 = "#{calendarBean.reset2}";
 
     static final String INIT_SHOW_ATTRIBUTES_TEST = "#{calendarBean.initShowAttributesTest}";
 
@@ -113,6 +115,8 @@
     String statusId;
 
     String resetActionId;
+    
+    String resetAction2Id;
 
     String testClientModeId;
 
@@ -213,6 +217,7 @@
         serverSubmitId = parentId + FORM_ID + "serverSubmit";
         statusId = parentId + FORM_ID + "status";
         resetActionId = parentId + CONTROLS_FORM_ID + "resetAction";
+        resetAction2Id = parentId + CONTROLS_FORM_ID + "resetAction2";
         testClientModeId = parentId + CONTROLS_FORM_ID + "testClientMode";
         setupActionId = parentId + CONTROLS_FORM_ID + "setup";
         ajaxSetupActionId = parentId + CONTROLS_FORM_ID + "ajaxSetup";
@@ -905,7 +910,7 @@
 
     @Test
     public void testCalendarComponent(Template template) {
-        renderPage(template);	
+        renderPage(template, RESET_METHOD2);	
 
         String containerId = getParentId() + "_form:";
         String calendarOpenedId = containerId + "calendar";
@@ -934,23 +939,22 @@
 
     @Test
     public void testSelectDateComponent(Template template) {
-        renderPage(template);
-
+        renderPage(template, RESET_METHOD2);
+        initIds(getParentId());
         Date newSelectedDate = getDayInMay(15);
 
         String containerId = getParentId() + "_form:";
         String calendarOpenedId = containerId + "calendar";
         String calendarCollapsedId = calendarOpenedId + "Popup";
-        String calendarInputDate = calendarOpenedId + "InputDate";
         String calendarPopupButton = calendarCollapsedId + "Button";
-        String outputPanel = containerId + "outputPanel";
+        
 
         Assert.assertFalse(isVisible(calendarOpenedId), "Calendar window should NOT be visible on the component!");
         writeStatus("Mouse click on calendar popup button");
         clickById(calendarPopupButton);
         Assert.assertTrue(isVisible(calendarOpenedId), "Calendar window should be visible on the component!");
 
-        String inputDateString = getValueById(calendarInputDate);
+        String inputDateString = getValueById(selectedDateId);
         Date readDate = null;
         try {
             readDate = DATE_FORMAT.parse(inputDateString);
@@ -962,11 +966,10 @@
         // click on 15th of May
         String newSelectedDateId = calendarOpenedId + "DayCell18";
         clickById(newSelectedDateId);
+        
+        clickCommandAndWait(serverSubmitId);
 
-        writeStatus("Mouse click outside calendar");
-        clickById(outputPanel);
-
-        inputDateString = getValueById(calendarInputDate);
+        inputDateString = getValueById(selectedDateId);
         try {
             readDate = DATE_FORMAT.parse(inputDateString);
         } catch (ParseException parseException) {
@@ -1092,7 +1095,7 @@
 
     @Test
     public void testDatePatternNonPopupMode(Template template) {
-        renderPage(template, null);
+        renderPage(template, RESET_METHOD2);
         initIds(getParentId());
         String originalPattern = "MM/dd/yyyy HH:mm";
         writeStatus("Check 'datePattern' attribute in non-popup mode");
@@ -1122,7 +1125,7 @@
 
     @Test
     public void testDatePatternPopupMode(Template template) {
-        renderPage(template, null);
+        renderPage(template, RESET_METHOD2);
         initIds(getParentId());
         String originalPattern = "MM/dd/yyyy HH:mm";
         writeStatus("Check 'datePattern' attribute in popup mode");
@@ -1135,14 +1138,11 @@
         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");
+            AssertValueEquals(calendarId + "InputDate", 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);
@@ -1376,16 +1376,19 @@
 
     @Test
     public void testTodayControlMode(Template template) {
-        renderPage(TODAY_CONTROL_AND_BOUNDARY_DATES_MODES_TEST_URL, template, null);
+        renderPage(TODAY_CONTROL_AND_BOUNDARY_DATES_MODES_TEST_URL, template, RESET_METHOD2);
         initIds(getParentId());
-
-        String datePattern = selenium.getText(getParentId() + FORM_ID + "datePattern");
+        
+        String expectedPattern = "MM/dd/yyyy";
+        setValueById(getParentId() + FORM_ID + "datePattern", expectedPattern);
+        clickCommandAndWait(getParentId() + FORM_ID + "setup");
+        
         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());
+        String expectedTodaySelectedDate = new SimpleDateFormat(expectedPattern).format(new Date());
 
         writeStatus("Check 'todayControlMode' attribute");
 
@@ -1398,7 +1401,9 @@
         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);
@@ -1459,12 +1464,17 @@
 
     @Test
     public void testBoundaryDatesMode(Template template) {
-        renderPage(TODAY_CONTROL_AND_BOUNDARY_DATES_MODES_TEST_URL, template, null);
+        renderPage(TODAY_CONTROL_AND_BOUNDARY_DATES_MODES_TEST_URL, template, RESET_METHOD2);
         initIds(getParentId());
+        
         String selectedDateId = getParentId() + FORM_ID + "selectedDate";
+        String currentDateId = getParentId() + FORM_ID + "currentDate";
         String startDate = "02/21/2007 12:00";
         String firstMarCellId = calendarId + "DayCell32";
         String thirtyFirstJanCellId = calendarId + "DayCell3";
+        selenium.focus(currentDateId);
+        setValueById(currentDateId, startDate);
+        selenium.fireEvent(currentDateId, "blur");
         selenium.focus(selectedDateId);
         setValueById(selectedDateId, startDate);
         selenium.fireEvent(selectedDateId, "blur");




More information about the richfaces-svn-commits mailing list