Author: lfryc(a)redhat.com
Date: 2011-01-24 10:57:53 -0500 (Mon, 24 Jan 2011)
New Revision: 21179
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TestTooltipSimple.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TooltipAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TooltipModel.java
Modified:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTooltipBean.properties
modules/tests/metamer/trunk/ftest/src/test/resources/testng-output.xml
Log:
rich:tooltip - automated Simple sample (RFPL-884)
Modified:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTooltipBean.properties
===================================================================
---
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTooltipBean.properties 2011-01-24
15:56:48 UTC (rev 21178)
+++
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTooltipBean.properties 2011-01-24
15:57:53 UTC (rev 21179)
@@ -2,6 +2,7 @@
attr.layout.block=block
attr.direction.auto=auto
attr.direction.topLeft=topLeft
+attr.direction.topRight=topRight
attr.direction.bottomLeft=bottomLeft
attr.direction.bottomRight=bottomRight
attr.direction.autoLeft=autoLeft
@@ -13,10 +14,14 @@
attr.mode.ajax=ajax
attr.jointPoint.auto=auto
attr.jointPoint.topLeft=topLeft
+attr.jointPoint.topRight=topRight
attr.jointPoint.bottomLeft=bottomLeft
attr.jointPoint.bottomRight=bottomRight
attr.jointPoint.autoLeft=autoLeft
attr.jointPoint.autoRight=autoRight
attr.jointPoint.topAuto=topAuto
attr.jointPoint.bottomAuto=bottomAuto
-attr.jointPoint.null=
\ No newline at end of file
+attr.jointPoint.null=
+attr.dir.ltr=ltr
+attr.dir.rtl=rtl
+attr.dir.null=
\ No newline at end of file
Modified: modules/tests/metamer/trunk/ftest/src/test/resources/testng-output.xml
===================================================================
--- modules/tests/metamer/trunk/ftest/src/test/resources/testng-output.xml 2011-01-24
15:56:48 UTC (rev 21178)
+++ modules/tests/metamer/trunk/ftest/src/test/resources/testng-output.xml 2011-01-24
15:57:53 UTC (rev 21179)
@@ -14,6 +14,7 @@
<package
name="org.richfaces.tests.metamer.ftest.richTogglePanelItem" />
<package name="org.richfaces.tests.metamer.ftest.richToolbar"
/>
<package
name="org.richfaces.tests.metamer.ftest.richToolbarGroup" />
+ <package name="org.richfaces.tests.metamer.ftest.richTooltip"
/>
</packages>
</test>
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TestTooltipSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TestTooltipSimple.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TestTooltipSimple.java 2011-01-24
15:57:53 UTC (rev 21179)
@@ -0,0 +1,413 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richTooltip;
+
+import static javax.faces.event.PhaseId.APPLY_REQUEST_VALUES;
+import static javax.faces.event.PhaseId.RENDER_RESPONSE;
+import static javax.faces.event.PhaseId.RESTORE_VIEW;
+import static javax.faces.event.PhaseId.UPDATE_MODEL_VALUES;
+import static org.jboss.test.selenium.dom.Event.CLICK;
+import static org.jboss.test.selenium.dom.Event.DBLCLICK;
+import static org.jboss.test.selenium.dom.Event.MOUSEDOWN;
+import static org.jboss.test.selenium.dom.Event.MOUSEMOVE;
+import static org.jboss.test.selenium.dom.Event.MOUSEOUT;
+import static org.jboss.test.selenium.dom.Event.MOUSEOVER;
+import static org.jboss.test.selenium.dom.Event.MOUSEUP;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.css.CssProperty;
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.geometry.Dimension;
+import org.jboss.test.selenium.geometry.Point;
+import org.jboss.test.selenium.javascript.JQueryScript;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.TooltipLayout;
+import org.richfaces.TooltipMode;
+import org.richfaces.component.Positioning;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.annotations.Uses;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestTooltipSimple extends AbstractMetamerTest {
+
+ private static final int EVENT_OFFSET = 10;
+ private static final int PRESET_OFFSET = 5;
+
+ TooltipAttributes attributes = new TooltipAttributes();
+ JQueryLocator panel = pjq("div[id$=panel]");
+ TooltipModel tooltip = new TooltipModel(panel.getChild(jq("* >.rf-tt")),
panel);
+
+ Point eventPosition;
+
+ @Inject
+ @Use(empty = true)
+ Positioning direction;
+
+ Integer[] offsets = new Integer[] { 0, PRESET_OFFSET, -PRESET_OFFSET };
+
+ @Inject
+ @Use(ints = 0)
+ Integer verticalOffset;
+
+ @Inject
+ @Use(ints = 0)
+ Integer horizontalOffset;
+
+ @Inject
+ @Use(empty = true)
+ Event domEvent;
+ Event[] domEvents = { CLICK, DBLCLICK, MOUSEDOWN, MOUSEMOVE, MOUSEOUT, MOUSEOVER,
MOUSEUP };
+
+ @Inject
+ @Use(empty = true)
+ Boolean followMouse = true;
+
+ @Inject
+ @Use(empty = true)
+ Integer presetDelay;
+
+ @Inject
+ @Use(empty = true)
+ TooltipLayout layout;
+
+ @Inject
+ @Use(empty = true)
+ TooltipMode mode;
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richTooltip/simple.xhtml");
+ }
+
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10282")
+ public void testLifecycle() {
+ attributes.setMode(TooltipMode.ajax);
+ tooltip.recall();
+ phaseInfo.assertPhases(RESTORE_VIEW, APPLY_REQUEST_VALUES, RENDER_RESPONSE);
+ }
+
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10285")
+ public void testData() {
+ fail("TODO needs comment ");
+ }
+
+ @Test
+ public void testDir() {
+ super.testDir(tooltip);
+ }
+
+ @Test
+ @Uses({ @Use(field = "direction", enumeration = true), @Use(field =
"verticalOffset", value = "offsets"),
+ @Use(field = "horizontalOffset", value = "offsets") })
+ public void testPositioning() {
+ attributes.setDirection(direction);
+ attributes.setHorizontalOffset(horizontalOffset);
+ attributes.setVerticalOffset(verticalOffset);
+
+ if (direction == Positioning.auto) {
+ direction = Positioning.topRight;
+ }
+
+ recallTooltipInRightBottomCornerOfPanel(0, 0);
+
+ final Point tooltipPosition = selenium.getElementPosition(tooltip);
+ final Dimension tooltipDimension = selenium.getElementDimension(tooltip);
+
+ if (getHorizontalAlignment() != null) {
+ switch (getHorizontalAlignment()) {
+ case RIGHT:
+ assertEquals(tooltipPosition.getX(), eventPosition.getX() +
horizontalOffset);
+ break;
+ case LEFT:
+ assertEquals(tooltipPosition.getX() + tooltipDimension.getWidth(),
eventPosition.getX()
+ - horizontalOffset);
+ default:
+ }
+ }
+
+ if (getVerticalAlignment() != null) {
+ switch (getVerticalAlignment()) {
+ case BOTTOM:
+ assertEquals(tooltipPosition.getY(), eventPosition.getY() +
verticalOffset);
+ break;
+ case TOP:
+ assertEquals(tooltipPosition.getY() + tooltipDimension.getHeight(),
eventPosition.getY()
+ - verticalOffset);
+ default:
+ }
+ }
+ }
+
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10283")
+ public void testDisabled() {
+ fail("TODO needs comment ");
+ }
+
+ @Test
+ public void testExecute() {
+ attributes.setExecute("@this executeChecker");
+ attributes.setMode(TooltipMode.ajax);
+
+ tooltip.recall();
+
+ phaseInfo.assertListener(UPDATE_MODEL_VALUES, "executeChecker");
+ }
+
+ @Test
+ @Use(field = "followMouse", booleans = { true, false })
+ public void testFollowMouse() {
+ attributes.setFollowMouse(followMouse);
+
+ recallTooltipInRightBottomCornerOfPanel(0, 0);
+
+ Point initialPosition = selenium.getElementPosition(tooltip);
+
+ recallTooltipInRightBottomCornerOfPanel(-5, -5);
+
+ Point nextPosition = selenium.getElementPosition(tooltip);
+
+ int expectedOffset = (followMouse) ? -5 : 0;
+
+ assertEquals(nextPosition.getX() - initialPosition.getX(), expectedOffset);
+ assertEquals(nextPosition.getY() - initialPosition.getY(), expectedOffset);
+ }
+
+ @Test
+ @Use(field = "presetDelay", ints = { 0, 1000, 5000 })
+ public void testHideDelay() {
+
+ attributes.setMode(TooltipMode.ajax);
+ attributes.setHideDelay(presetDelay);
+
+ tooltip.recall();
+ long delay = System.currentTimeMillis();
+ tooltip.hide();
+ waitGui.timeout(6000).until(isNotDisplayed.locator(tooltip));
+ delay = System.currentTimeMillis() - delay;
+
+ long deviation = Math.abs(presetDelay - delay);
+ long maxDeviation = Math.max(200, presetDelay / 2);
+
+ assertTrue(deviation < maxDeviation,
+ format("deviation '{0}' is greater than maxDeviation
'{1}'", deviation, maxDeviation));
+ }
+
+ @Test
+ public void testHideEvent() {
+ attributes.setHideEvent("mouseup");
+
+ tooltip.recall();
+ waitGui.until(isDisplayed.locator(tooltip));
+
+ selenium.mouseUpAt(panel, new Point(5, 5));
+ waitGui.until(isNotDisplayed.locator(tooltip));
+ }
+
+ @Test
+ public void testLang() {
+ super.testLang(tooltip);
+ }
+
+ @Test
+ @Use(field = "layout", enumeration = true)
+ public void testLayout() {
+ attributes.setLayout(layout);
+
+ String expectedTagName = (layout == TooltipLayout.block) ? "div" :
"span";
+
+ String actualTagName = selenium.getEval(JQueryScript.jqScript(tooltip,
"get(0).tagName"));
+ actualTagName = actualTagName.toLowerCase();
+
+ assertEquals(actualTagName, expectedTagName);
+ }
+
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10287")
+ public void testLimitRender() {
+ attributes.setLimitRender(true);
+ attributes.setRender("@this renderChecker");
+ attributes.setMode(TooltipMode.ajax);
+
+ retrieveRenderChecker.initializeValue();
+
+ tooltip.recall();
+
+ assertTrue(retrieveRenderChecker.isValueChanged());
+ }
+
+ @Test
+ @Use(field = "mode", enumeration = true)
+ public void testMode() {
+ attributes.setMode(mode);
+
+ retrieveRequestTime.initializeValue();
+
+ tooltip.recall();
+ waitAjax.until(isDisplayed.locator(tooltip));
+ assertEquals(retrieveRequestTime.isValueChanged(), mode == TooltipMode.ajax);
+
+ retrieveRequestTime.initializeValue();
+ tooltip.hide();
+ waitGui.until(isNotDisplayed.locator(tooltip));
+ assertFalse(retrieveRequestTime.isValueChanged());
+ }
+
+ @Test
+ @Use(field = "domEvent", value = "domEvents")
+ public void testDomEvents() {
+ tooltip.recall();
+ waitGui.until(isDisplayed.locator(tooltip));
+
+ testFireEvent(domEvent, tooltip);
+ }
+
+ @Test
+ public void testRendered() {
+ attributes.setRendered(false);
+
+ assertFalse(selenium.isElementPresent(tooltip));
+ }
+
+ @Test
+ @Use(field = "presetDelay", ints = { 0, 1000, 5000 })
+ public void testShowDelay() {
+
+ attributes.setMode(TooltipMode.client);
+ attributes.setShowDelay(presetDelay);
+
+ long delay = System.currentTimeMillis();
+ tooltip.recall();
+ waitGui.timeout(6000).until(isDisplayed.locator(tooltip));
+ delay = System.currentTimeMillis() - delay;
+
+ long deviation = Math.abs(presetDelay - delay);
+ long maxDeviation = Math.max(200, presetDelay / 2);
+
+ assertTrue(deviation < maxDeviation,
+ format("deviation '{0}' is greater than maxDeviation
'{1}'", deviation, maxDeviation));
+ }
+
+ @Test
+ public void testShowEvent() {
+ attributes.setShowEvent("mouseup");
+
+ selenium.mouseUpAt(panel, new Point(5, 5));
+ waitGui.until(isDisplayed.locator(tooltip));
+ }
+
+ @Test
+ public void testStatus() {
+ attributes.setStatus("statusChecker");
+ attributes.setMode(TooltipMode.ajax);
+
+ retrieveStatusChecker.initializeValue();
+ tooltip.recall();
+ assertTrue(retrieveStatusChecker.isValueChanged());
+
+ }
+
+ @Test
+ public void testStyle() {
+ super.testStyle(tooltip, "style");
+ }
+
+ @Test
+ public void testStyleClass() {
+ super.testStyleClass(tooltip, "styleClass");
+ }
+
+ @Test
+ public void testTitle() {
+ super.testTitle(tooltip);
+ }
+
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10286")
+ public void testZindex() {
+ attributes.setZindex(10);
+
+ String zindex = selenium.getStyle(tooltip, CssProperty.Z_INDEX);
+ assertEquals(zindex, "10");
+ }
+
+ private void recallTooltipInRightBottomCornerOfPanel(int offsetX, int offsetY) {
+ final Point panelPosition = selenium.getElementPosition(panel);
+ final Dimension panelDimension = selenium.getElementDimension(panel);
+
+ eventPosition = new Point(panelPosition.getX() + panelDimension.getWidth() -
EVENT_OFFSET, panelPosition.getY()
+ + panelDimension.getHeight() - EVENT_OFFSET);
+
+ tooltip.recall(panelDimension.getWidth() - EVENT_OFFSET + offsetX,
panelDimension.getHeight() - EVENT_OFFSET
+ + offsetY);
+ }
+
+ private HorizontalAlignment getHorizontalAlignment() {
+ if (direction != null) {
+ if (direction.toString().toLowerCase().contains("left")) {
+ return HorizontalAlignment.LEFT;
+ }
+ if (direction.toString().toLowerCase().contains("right")) {
+ return HorizontalAlignment.RIGHT;
+ }
+ }
+ return null;
+ }
+
+ private VerticalAlignment getVerticalAlignment() {
+ if (direction != null) {
+ if (direction.toString().contains("top")) {
+ return VerticalAlignment.TOP;
+ }
+ if (direction.toString().contains("bottom")) {
+ return VerticalAlignment.BOTTOM;
+ }
+ }
+ return null;
+ }
+
+ private enum HorizontalAlignment {
+ LEFT, RIGHT
+ }
+
+ private enum VerticalAlignment {
+ TOP, BOTTOM
+ }
+
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TooltipAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TooltipAttributes.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TooltipAttributes.java 2011-01-24
15:57:53 UTC (rev 21179)
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richTooltip;
+
+import org.richfaces.TooltipLayout;
+import org.richfaces.TooltipMode;
+import org.richfaces.component.Positioning;
+import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TooltipAttributes extends AbstractComponentAttributes {
+
+ public void setData(String data) {
+ setProperty("data", data);
+ }
+
+ public void setDir(String dir) {
+ setProperty("dir", dir);
+ }
+
+ public void setDirection(Positioning direction) {
+ setProperty("direction", direction);
+ }
+
+ public void setDisabled(Boolean disabled) {
+ setProperty("disabled", disabled);
+ }
+
+ public void setExecute(String execute) {
+ setProperty("execute", execute);
+ }
+
+ public void setFollowMouse(Boolean followMouse) {
+ setProperty("followMouse", followMouse);
+ }
+
+ public void setHideDelay(Integer hideDelay) {
+ setProperty("hideDelay", hideDelay);
+ }
+
+ public void setHideEvent(String hideEvent) {
+ setProperty("hideEvent", hideEvent);
+ }
+
+ public void setHorizontalOffset(Integer horizontalOffset) {
+ setProperty("horizontalOffset", horizontalOffset);
+ }
+
+ public void setJointPoint(Positioning positioning) {
+ setProperty("positioning", positioning);
+ }
+
+ public void setLang(String lang) {
+ setProperty("lang", lang);
+ }
+
+ public void setLayout(TooltipLayout layout) {
+ setProperty("layout", layout);
+ }
+
+ public void setLimitRender(Boolean limitRender) {
+ setProperty("limitRender", limitRender);
+ }
+
+ public void setMode(TooltipMode mode) {
+ setProperty("mode", mode);
+ }
+
+ public void setOnbeforehide(String onbeforehide) {
+ setProperty("onbeforehide", onbeforehide);
+ }
+
+ public void setOnbeforeshow(String onbeforeshow) {
+ setProperty("onbeforeshow", onbeforeshow);
+ }
+
+ public void setOnhide(String onhide) {
+ setProperty("onhide", onhide);
+ }
+
+ public void setOnshow(String onshow) {
+ setProperty("onshow", onshow);
+ }
+
+ public void setRender(String render) {
+ setProperty("render", render);
+ }
+
+ public void setRendered(Boolean rendered) {
+ setProperty("rendered", rendered);
+ }
+
+ public void setShowDelay(Integer showDelay) {
+ setProperty("showDelay", showDelay);
+ }
+
+ public void setShowEvent(String showEvent) {
+ setProperty("showEvent", showEvent);
+ }
+
+ public void setStatus(String status) {
+ setProperty("status", status);
+ }
+
+ public void setStyle(String style) {
+ setProperty("style", style);
+ }
+
+ public void setStyleClass(String styleClass) {
+ setProperty("styleClass", styleClass);
+ }
+
+ public void setTarget(String target) {
+ setProperty("target", target);
+ }
+
+ public void setTitle(String title) {
+ setProperty("title", title);
+ }
+
+ public void setVerticalOffset(Integer verticalOffset) {
+ setProperty("verticalOffset", verticalOffset);
+ }
+
+ public void setZindex(Integer zindex) {
+ setProperty("zindex", zindex);
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TooltipModel.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TooltipModel.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTooltip/TooltipModel.java 2011-01-24
15:57:53 UTC (rev 21179)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richTooltip;
+
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guard;
+
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.geometry.Point;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.request.RequestType;
+import org.richfaces.TooltipMode;
+import org.richfaces.tests.metamer.ftest.model.AbstractModel;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TooltipModel extends AbstractModel<JQueryLocator> {
+
+ private AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ private TooltipMode mode = TooltipMode.client;
+ private JQueryLocator target;
+
+ public TooltipModel(JQueryLocator root, JQueryLocator target) {
+ super(root);
+ this.target = target;
+ }
+
+ public void setMode(TooltipMode mode) {
+ this.mode = mode;
+ }
+
+ public TooltipMode getMode() {
+ return mode;
+ }
+
+ public JQueryLocator getTarget() {
+ return target;
+ }
+
+ public void recall() {
+ recall(5, 5);
+ }
+
+ public void recall(int x, int y) {
+ if (selenium.isVisible(getRoot())) {
+ guard(selenium, getRequestType()).mouseMoveAt(target, new Point(x, y));
+ } else {
+ guard(selenium, getRequestType()).mouseOverAt(target, new Point(x, y));
+ }
+ }
+
+ public void hide() {
+ hide(-1, -1);
+ }
+
+ public void hide(int x, int y) {
+ guard(selenium, getRequestType()).mouseOutAt(target, new Point(x, y));
+ }
+
+ private RequestType getRequestType() {
+ switch (mode) {
+ case ajax:
+ return RequestType.XHR;
+ default:
+ return null;
+ }
+ }
+
+}