JBoss Rich Faces SVN: r23183 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richContextMenu.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2012-01-25 05:44:00 -0500 (Wed, 25 Jan 2012)
New Revision: 23183
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richContextMenu/TestRichContextMenu.java
Log:
RF-10197: add test for @horizontalOffset for rich:contextMenu
Update test for @verticalOffset as well
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richContextMenu/TestRichContextMenu.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richContextMenu/TestRichContextMenu.java 2012-01-24 10:53:16 UTC (rev 23182)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richContextMenu/TestRichContextMenu.java 2012-01-25 10:44:00 UTC (rev 23183)
@@ -27,20 +27,7 @@
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.richfaces.tests.metamer.ftest.attributes.AttributeList.contextMenuAttributes;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.attachTo;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.dir;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.disabled;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.hideDelay;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.lang;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.mode;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.onshow;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.popupWidth;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.rendered;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.showEvent;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.style;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.styleClass;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.title;
-import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.verticalOffset;
+import static org.richfaces.tests.metamer.ftest.richContextMenu.ContextMenuAttributes.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@@ -49,11 +36,13 @@
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.locator.Attribute;
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.EventFiredCondition;
+import org.richfaces.component.Positioning;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -163,9 +152,21 @@
}
- // @Test
+ @Test
public void testHorizontalOffset() {
-
+
+ int offset = 11;
+
+ clickOnTarget(menuElem);
+ int positionBefore = selenium.getElementPositionLeft(contextMenuContent);
+
+ contextMenuAttributes.set(horizontalOffset, offset);
+ clickOnTarget(menuElem);
+
+ int positionAfter = selenium.getElementPositionLeft(contextMenuContent);
+
+ assertEquals(positionAfter, positionBefore + offset);
+
}
// @Test
@@ -350,22 +351,17 @@
@Test
public void testVerticalOffset() {
- CssProperty cssTop = new CssProperty("top");
int offset = 11;
clickOnTarget(menuElem);
- String offsetBefore = selenium.getStyle(contextMenuContent, cssTop);
+ int positionBefore = selenium.getElementPositionTop(contextMenuContent);
contextMenuAttributes.set(verticalOffset, offset);
clickOnTarget(menuElem);
- String offsetAfter = selenium.getStyle(contextMenuContent, cssTop);
+ int positionAfter = selenium.getElementPositionTop(contextMenuContent);
- // remove suffix "px"
- int before = Integer.valueOf(offsetBefore.substring(0, offsetBefore.length()-2));
- int after = Integer.valueOf(offsetAfter.substring(0, offsetAfter.length()-2));
-
- assertEquals(after, before - offset);
+ assertEquals(positionAfter, positionBefore - offset);
}
}