Author: dsvyatobatsko
Date: 2009-03-26 15:23:13 -0400 (Thu, 26 Mar 2009)
New Revision: 13234
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tooltip/tooltipAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TooltipTest.java
Log:
RF-6382, RF-6383, RF-6394
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tooltip/tooltipAutoTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TooltipTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TooltipTest.java 2009-03-26
19:22:22 UTC (rev 13233)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TooltipTest.java 2009-03-26
19:23:13 UTC (rev 13234)
@@ -27,6 +27,7 @@
import org.richfaces.AutoTester;
import org.richfaces.SeleniumEvent;
import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
import org.testng.annotations.Test;
public class TooltipTest extends SeleniumTestBase {
@@ -92,19 +93,78 @@
}
@Test
- public void testCoreClientMode(Template template) {
+ public void testCoreAjaxMode(Template template) {
AutoTester autoTester = getAutoTester(this);
- autoTester.renderPage(template, INIT_CLIENT_TEST);
- //TODO: ToolTip: component is activated by defined event; its positioning and
dimensions are ok
+ autoTester.renderPage(template, RESET_METHOD);
+ writeStatus("Component retrieves data from server; 'defaultContent'
facet is handled; listeners fire");
+ String componentId = autoTester.getClientId(AutoTester.COMPONENT_ID);
+ String contentId = autoTester.getClientId(AutoTester.COMPONENT_ID +
"content");
+ String defaultContentId = autoTester.getClientId(AutoTester.COMPONENT_ID +
"defaultContent");
+
+ triggerTooltip();
+ writeStatus("Check 'defaultContent' feature");
+ //It seems event handlers registered slow down tooltip appearance a little bit
... wait 0.5 second
+ waiteForCondition("document.getElementById('" + componentId +
"').style.display != 'none'", 500);
+ AssertTextEquals(defaultContentId, "Wait...");
+ waitForAjaxCompletion();
+
+ AssertVisible(componentId);
+ AssertTextEquals(contentId, "Tooltip hit count 0");
+ assertTooltipPositioning();
+
+ writeStatus("Check tooltip content (ajax mode) is rendered on server every
time");
+ triggerTooltipAndWait();
+ AssertVisible(componentId);
+ AssertTextEquals(contentId, "Tooltip hit count 1");
+ assertTooltipPositioning();
}
@Test
- public void testCoreAjaxMode(Template template) {
+ public void testCoreClientMode(Template template) {
AutoTester autoTester = getAutoTester(this);
- autoTester.renderPage(template, RESET_METHOD);
- //TODO: ToolTip: the same for ajax mode; component retrieves data from server;
"defaultContent" facet is handled; listeners fire
+ autoTester.renderPage(template, INIT_CLIENT_TEST);
+ writeStatus("Check component is activated by defined event(onclick); its
positioning and dimensions are ok");
+
+ String componentId = autoTester.getClientId(AutoTester.COMPONENT_ID);
+ String contentId = autoTester.getClientId(AutoTester.COMPONENT_ID +
"content");
+
+ triggerTooltip();
+ AssertVisible(componentId);
+ AssertTextEquals(contentId, "Tooltip hit count 0");
+ assertTooltipPositioning();
+
+ writeStatus("Check tooltip content (client mode) is rendered on server only
once");
+
+ triggerTooltip();
+ AssertVisible(componentId);
+ assertTooltipPositioning();
+ AssertTextEquals(contentId, "Tooltip hit count 0");
}
+ private void assertTooltipPositioning() {
+ writeStatus("Check bottom-right positionning");
+ String componentId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
+ String tooltipAreaId = getAutoTester(this).getClientId("tooltipArea");
+
+ String tooltipLeft = WINDOW_JS_RESOLVER + "$('" + componentId +
"').cumulativeOffset().left";
+ String tooltipTop = WINDOW_JS_RESOLVER + "$('" + componentId +
"').cumulativeOffset().top";
+
+ // we click at 1,1 of tooltipArea
+ String eventLeft = WINDOW_JS_RESOLVER + "$('" + tooltipAreaId +
"').cumulativeOffset().left + 1";
+ String eventTop = WINDOW_JS_RESOLVER + "$('" + tooltipAreaId +
"').cumulativeOffset().top + 1";
+
+ String leftExpr = String.format("Math.abs((%1$s) - (%2$s)) <= 2",
eventLeft, tooltipLeft);
+ String topExpr = String.format("Math.abs((%1$s) - (%2$s)) <= 2",
eventTop, tooltipTop);
+
+ if ("false".equalsIgnoreCase(selenium.getEval(leftExpr))) {
+ Assert.fail(selenium.getEval(eventLeft) + " == " +
selenium.getEval(tooltipLeft));
+ }
+
+ if ("false".equalsIgnoreCase(selenium.getEval(topExpr))) {
+ Assert.fail(selenium.getEval(eventTop) + " == " +
selenium.getEval(tooltipTop));
+ }
+ }
+
@Test
public void testJSAPI(Template template) {
AutoTester autoTester = getAutoTester(this);
@@ -159,12 +219,14 @@
autoTester.checkActionListener(false);
}
- //@Test
+ @Test
public void testStylesAndClassesAndHtmlAttributes(Template template) {
- //TODO: ToolTip: style and classes, standard HTML attributes are output to
client
AutoTester autoTester = getAutoTester(this);
autoTester.renderPage(template, RESET_METHOD);
+ writeStatus("Check style and classes, standard HTML attributes are output to
client");
+
String componentId = autoTester.getClientId(AutoTester.COMPONENT_ID);
+ String tooltipAreaId = getAutoTester(this).getClientId("tooltipArea");
writeStatus("Check styles and classes are output to client");
@@ -174,6 +236,11 @@
writeStatus("Test component html events");
assertEvents(componentId, SeleniumEvent.STANDARD_HTML_EVENTS);
+
+ triggerTooltipAndWait();
+ assertEvent("onshow");
+ selenium.mouseOut(tooltipAreaId);
+ assertEvent("onhide");
}
@Override
Show replies by date