Author: dsvyatobatsko
Date: 2009-03-25 16:07:42 -0400 (Wed, 25 Mar 2009)
New Revision: 13201
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TooltipBean.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/layout.xhtml
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:
https://jira.jboss.org/jira/browse/RF-6381 in progress
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TooltipBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TooltipBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TooltipBean.java 2009-03-25
20:07:42 UTC (rev 13201)
@@ -0,0 +1,70 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.ajax4jsf.bean;
+
+public class TooltipBean {
+
+ private String mode = "ajax";
+
+ private int hitCount = 0;
+
+ /**
+ * Gets value of mode field.
+ * @return value of mode field
+ */
+ public String getMode() {
+ return mode;
+ }
+
+ /**
+ * Set a new value for mode field.
+ * @param mode a new value for mode field
+ */
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
+ /**
+ * Gets value of hitCount field.
+ * @return value of hitCount field
+ */
+ public int getHitCount() {
+ return hitCount++;
+ }
+
+ /**
+ * Set a new value for hitCount field.
+ * @param hitCount a new value for hitCount field
+ */
+ public void setHitCount(int hitCount) {
+ this.hitCount = hitCount;
+ }
+
+ public void initClientTest() {
+ reset();
+ mode = "client";
+ }
+
+ public void reset() {
+ hitCount = 0;
+ mode = "ajax";
+ }
+}
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TooltipBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-03-25
19:29:00 UTC (rev 13200)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-03-25
20:07:42 UTC (rev 13201)
@@ -373,6 +373,11 @@
<managed-bean-name>logBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.AjaxLogBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>tooltipBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.TooltipBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/ajaxInclude/step1.xhtml</from-view-id>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/layout.xhtml
===================================================================
(Binary files differ)
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-25
19:29:00 UTC (rev 13200)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TooltipTest.java 2009-03-25
20:07:42 UTC (rev 13201)
@@ -25,11 +25,16 @@
import org.ajax4jsf.template.Template;
import org.richfaces.AutoTester;
+import org.richfaces.SeleniumEvent;
import org.richfaces.SeleniumTestBase;
import org.testng.annotations.Test;
public class TooltipTest extends SeleniumTestBase {
+ private final static String RESET_METHOD = "#{tooltipBean.reset}";
+
+ private final static String INIT_CLIENT_TEST =
"#{tooltipBean.initClientTest}";
+
private static Map<String, String> params = new HashMap<String,
String>();
static {
@@ -41,7 +46,7 @@
@Test
public void testNestedParams(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, null);
+ tester.renderPage(template, RESET_METHOD);
writeStatus("Test component encodes nested f:param tags and their values are
present as request parameters");
tester.testRequestParameters(params);
}
@@ -49,7 +54,7 @@
@Test
public void testRenderedAttribute(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, null);
+ tester.renderPage(template, RESET_METHOD);
writeStatus("Test component with rendered = false is not present on the
page");
tester.testRendered();
}
@@ -57,7 +62,7 @@
@Test
public void testImmediate(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, null);
+ tester.renderPage(template, RESET_METHOD);
writeStatus("Test immediate attribute");
tester.testImmediate();
}
@@ -65,7 +70,7 @@
@Test
public void testImmediateWithExternalValidationFailed(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, null);
+ tester.renderPage(template, RESET_METHOD);
writeStatus("Test immediate attribute with external validation
failed");
tester.testImmediateWithExternalValidationFailed();
}
@@ -73,7 +78,7 @@
@Test
public void testAjaxSingle(Template template) {
AutoTester tester = getAutoTester(this);
- tester.renderPage(template, null);
+ tester.renderPage(template, RESET_METHOD);
writeStatus("Test ajaxSingle attribute");
tester.testAjaxSingle();
}
@@ -81,17 +86,110 @@
@Test
public void testWithExternalValidationFailure(Template template) {
AutoTester autoTester = getAutoTester(this);
- autoTester.renderPage(template, null);
+ autoTester.renderPage(template, RESET_METHOD);
writeStatus("Check that listeners are not invoked in case of external
validation failure");
autoTester.testExtrenalValidationFailure();
}
+ @Test
+ public void testCoreClientMode(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
+ }
+
+ @Test
+ public void testCoreAjaxMode(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
+ }
+
+ @Test
+ public void testJSAPI(Template template) {
+ AutoTester autoTester = getAutoTester(this);
+ autoTester.renderPage(template, RESET_METHOD);
+ writeStatus("Check JS API is present and works");
+ String componentId = autoTester.getClientId(AutoTester.COMPONENT_ID);
+ String contentId = autoTester.getClientId(AutoTester.COMPONENT_ID +
"content");
+
+ String event = "createMouseEvent('" + componentId +
"',click, 1, 1, false)";
+
+ writeStatus("Check show() function");
+ AssertNotVisible(componentId);
+ invokeFromComponent(componentId, "show", event);
+ waitForAjaxCompletion();
+ AssertVisible(componentId);
+ AssertTextEquals(contentId, "Tooltip hit count 0");
+
+ writeStatus("Check hide() function");
+ invokeFromComponent(componentId, "hide", event);
+ AssertNotVisible(componentId);
+
+ writeStatus("Check disable() function");
+ writeStatus("Check disabled tooltip cannot be shown neither by js event nor
by js api");
+ invokeFromComponent(componentId, "disable", event);
+ triggerTooltip();
+ AssertNotVisible(componentId);
+ invokeFromComponent(componentId, "show", event);
+ AssertNotVisible(componentId);
+
+ writeStatus("Check enable() function");
+ invokeFromComponent(componentId, "enable", event);
+ triggerTooltipAndWait();
+ AssertVisible(componentId);
+ AssertTextEquals(contentId, "Tooltip hit count 1");
+ invokeFromComponent(componentId, "show", event);
+ waitForAjaxCompletion();
+ AssertVisible(componentId);
+ AssertTextEquals(contentId, "Tooltip hit count 2");
+ }
+
+ @Test
+ public void testDisabledAttribute(Template template) {
+ AutoTester autoTester = getAutoTester(this);
+ autoTester.renderPage(template, RESET_METHOD);
+ writeStatus("Check disabled attribute");
+
+ autoTester.disableComponent(true);
+ writeStatus("Check tooltip is not shown up, server is not hit, listeners are
not invoked");
+ triggerTooltip();
+ String componentId = autoTester.getClientId(AutoTester.COMPONENT_ID);
+ AssertNotVisible(componentId);
+ autoTester.checkActionListener(false);
+ }
+
+ //@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);
+ String componentId = autoTester.getClientId(AutoTester.COMPONENT_ID);
+
+ writeStatus("Check styles and classes are output to client");
+
+ writeStatus("Check styleClass/style attributes");
+ assertStyleAttributeContains(componentId, "font-size: 13px",
"Style attribute was not output to client");
+ assertClassAttributeContains(componentId, "noclass", "Class
attribute was not output to client");
+
+ writeStatus("Test component html events");
+ assertEvents(componentId, SeleniumEvent.STANDARD_HTML_EVENTS);
+ }
+
@Override
public void sendAjax() {
+ triggerTooltipAndWait();
+ }
+
+ private void triggerTooltip() {
selenium.clickAt(getAutoTester(this).getClientId("tooltipArea"),
"1,1");
- waitForAjaxCompletion();
}
+ private void triggerTooltipAndWait() {
+ selenium.clickAt(getAutoTester(this).getClientId("tooltipArea"),
"1,1");
+ waitForAjaxCompletion();
+ }
+
@Override
public String getAutoTestUrl() {
return "pages/tooltip/tooltipAutoTest.xhtml";