[richfaces-svn-commits] JBoss Rich Faces SVN: r11907 - trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Dec 19 07:14:55 EST 2008


Author: dsvyatobatsko
Date: 2008-12-19 07:14:55 -0500 (Fri, 19 Dec 2008)
New Revision: 11907

Modified:
   trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5346 completed

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-19 12:01:08 UTC (rev 11906)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java	2008-12-19 12:14:55 UTC (rev 11907)
@@ -1568,9 +1568,6 @@
     public void testJointPointAndDirectionAttributes(Template template) {
         renderPage(JOINTPOINT_DIRECTION_TEST_URL, template, null);
         initIds(getParentId());
-        
-        String calendarLeft = "$('" + calendarId + "').cumulativeOffset().left";
-        String calendarTop = "$('" + calendarId + "').cumulativeOffset().top";
 
         String topLeftPointLeft = "$('" + inputDateId + "').cumulativeOffset().left";
         String topLeftPointTop = "$('" + inputDateId + "').cumulativeOffset().top";
@@ -1582,46 +1579,58 @@
         String topRightPointTop =  "$('" + popupButtonId + "').cumulativeOffset().top";
 
         String bottomRightPointLeft = topRightPointLeft;
-        String bottomRightPointTop =  "($('" + popupButtonId + "').cumulativeOffset().top + $('" + popupButtonId + "').getHeight()))";
+        String bottomRightPointTop =  "($('" + popupButtonId + "').cumulativeOffset().top + $('" + popupButtonId + "').getHeight())";
 
-        //point:
-        //"top-left"
-        //"top-right"
-        //"bottom-left"
-        //"bottom-right"
-        //waiteForCondition("$('" + popupButtonId + "').getStyle('display') != 'none'", 1000);
+        testJointPoint("top-left", topLeftPointLeft, topLeftPointTop);
+        testJointPoint("top-right", topRightPointLeft, topRightPointTop);
+        testJointPoint("bottom-left", bottomLeftPointLeft, bottomLeftPointTop);
+        testJointPoint("bottom-right", bottomRightPointLeft, bottomRightPointTop);
+    }
 
-        //top-left joint point
-        selenium.select(jointPointId, "top-left");
+    private void testJointPoint(String jointPointValue, String jointPointLeft, String jointPointTop) {
+        String calendarLeft = "$('" + calendarId + "').cumulativeOffset().left";
+        String calendarTop = "$('" + calendarId + "').cumulativeOffset().top";
 
+        writeStatus("Check [" + jointPointValue + "] joint point with all directions");
+        selenium.select(jointPointId, jointPointValue);
+
         //top-left direction
         selenium.select(directionId, "top-left");
         showPopup();        
-        assertTrue(calendarLeft, "<", topLeftPointLeft);
-        assertTrue(calendarTop, "<", topLeftPointTop);
+        assertTrue(calendarLeft, "<", jointPointLeft);
+        assertTrue(calendarTop, "<", jointPointTop);
 
         //top-right direction
         selenium.select(directionId, "top-right");
         showPopup();
-        assertTrue(calendarLeft, "==", topLeftPointLeft);
-        assertTrue(calendarTop, "<", topLeftPointTop);
+        assertTrue(calendarLeft, "==", jointPointLeft);
+        assertTrue(calendarTop, "<", jointPointTop);
 
         //bottom-right direction
         selenium.select(directionId, "bottom-right");
         showPopup();
-        assertTrue(calendarLeft, "==", topLeftPointLeft);
-        assertTrue(calendarTop, "==", topLeftPointTop);
+        assertTrue(calendarLeft, "==", jointPointLeft);
+        assertTrue(calendarTop, "==", jointPointTop);
 
         //bottom-left direction
         selenium.select(directionId, "bottom-left");
         showPopup();
-        assertTrue(calendarLeft, "<", topLeftPointLeft);
-        assertTrue(calendarTop, "==", topLeftPointTop);
+        assertTrue(calendarLeft, "<", jointPointLeft);
+        assertTrue(calendarTop, "==", jointPointTop);
+
+        //waiteForCondition("$('" + popupButtonId + "').getStyle('display') != 'none'", 1000);
     }
 
     private void assertTrue(String calendarPoint, String operation, String jointPoint) {
-        Assert.assertTrue(Boolean.parseBoolean(selenium.getEval(WINDOW_JS_RESOLVER + calendarPoint + " " + operation
-                + " " + WINDOW_JS_RESOLVER + jointPoint)), runScript(calendarPoint) + operation + runScript(jointPoint));
+        calendarPoint = calendarPoint.replaceAll("\\$", WINDOW_JS_RESOLVER + "\\$");
+        jointPoint = jointPoint.replaceAll("\\$", WINDOW_JS_RESOLVER + "\\$");
+        String expression;
+        if ("==".equals(operation)) {
+            expression = "Math.abs(" + calendarPoint + " - " + jointPoint + ") < 2";
+        } else {
+            expression = calendarPoint + " " + operation + " " + jointPoint;
+        }
+        Assert.assertTrue(Boolean.parseBoolean(selenium.getEval(expression)), selenium.getEval(calendarPoint) + operation + selenium.getEval(jointPoint));
     }
 
     private void setPopup(boolean isPopup) {




More information about the richfaces-svn-commits mailing list