Author: ppitonak(a)redhat.com
Date: 2011-02-01 11:44:00 -0500 (Tue, 01 Feb 2011)
New Revision: 21369
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHashParam/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHashParam/TestRichHashParam.java
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richHashParam/simple.xhtml
Log:
https://issues.jboss.org/browse/RFPL-736
* added 7 tests for rich:hashParam
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richHashParam/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richHashParam/simple.xhtml 2011-02-01
16:20:31 UTC (rev 21368)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richHashParam/simple.xhtml 2011-02-01
16:44:00 UTC (rev 21369)
@@ -42,8 +42,7 @@
<rich:popupPanel id="popupPanel" resizeable="true"
header="Popup panel shown using rich:componentControl
and rich:hashParam">
<f:facet name="controls">
- <h:outputLink value="#"
-
onclick="#{rich:component('popupPanel')}.hide(); return false;">
+ <h:outputLink value="#"
onclick="#{rich:component('popupPanel')}.hide(); return false;">
X
</h:outputLink>
</f:facet>
@@ -71,7 +70,7 @@
</fieldset>
</rich:popupPanel>
- <h:commandButton value="Show popup">
+ <h:commandButton id="openPanelButton" value="Show
popup">
<rich:componentControl target="popupPanel"
operation="show">
<a4j:param noEscape="true" value="event"
/>
<rich:hashParam>
@@ -79,8 +78,8 @@
<f:param name="height" value="345px"
/>
<f:param name="minWidth" value="300px"
/>
<f:param name="minHeight" value="150px"
/>
- <a4j:param noEscape="true" name="left"
value="(jQuery(window).width()/2)-250" />
- <a4j:param noEscape="true" name="top"
value="(jQuery(window).height()/2)-150" />
+ <a4j:param noEscape="true" name="left"
value="33+44" />
+ <a4j:param noEscape="true" name="top"
value="55-33" />
</rich:hashParam>
</rich:componentControl>
</h:commandButton>
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHashParam/TestRichHashParam.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHashParam/TestRichHashParam.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHashParam/TestRichHashParam.java 2011-02-01
16:44:00 UTC (rev 21369)
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.richHashParam;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.css.CssProperty;
+import org.jboss.test.selenium.geometry.Offset;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/richHashParam/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestRichHashParam extends AbstractMetamerTest {
+
+ private JQueryLocator openButton = pjq("input[id$=openPanelButton]");
+ private JQueryLocator panel = pjq("div[id$=popupPanel]");
+ private JQueryLocator panelContainer = jq("div.rf-pp-cntr");
+ private JQueryLocator content = jq("div.rf-pp-cnt");
+ private JQueryLocator header = jq("div.rf-pp-hdr");
+ private JQueryLocator controls = jq("div.rf-pp-hdr-cntrls a");
+ private JQueryLocator scroller = jq("div.rf-pp-cnt-scrlr");
+ private JQueryLocator shadow = jq("div.rf-pp-shdw");
+ private JQueryLocator resizerW = jq("div.rf-pp-hndlr-l");
+ private JQueryLocator resizerN = jq("div.rf-pp-hndlr-t");
+ private JQueryLocator resizerE = jq("div.rf-pp-hndlr-r");
+ private JQueryLocator resizerS = jq("div.rf-pp-hndlr-b");
+ private JQueryLocator resizerNW = jq("div.rf-pp-hndlr-tl");
+ private JQueryLocator resizerNE = jq("div.rf-pp-hndlr-tr");
+ private JQueryLocator resizerSW = jq("div.rf-pp-hndlr-bl");
+ private JQueryLocator resizerSE = jq("div.rf-pp-hndlr-br");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richHashParam/simple.xhtml");
+ }
+
+ @Test
+ public void testPanelInit() {
+ assertTrue(selenium.isElementPresent(openButton), "Button for opening popup
should be on the page.");
+ assertTrue(selenium.isElementPresent(panel), "Popup panel is not present on
the page.");
+ assertFalse(selenium.isVisible(panel), "Popup panel is visible.");
+
+ selenium.click(openButton);
+ assertTrue(selenium.isVisible(panel), "Popup panel should be
visible.");
+ assertTrue(selenium.isVisible(panelContainer), "Popup panel's container
should be visible.");
+ assertTrue(selenium.isVisible(header), "Popup panel's header should be
visible.");
+ assertTrue(selenium.isVisible(controls), "Popup panel's controls should
be visible.");
+ assertTrue(selenium.isVisible(scroller), "Popup panel's scroller should
be visible.");
+ assertTrue(selenium.isVisible(shadow), "Popup panel's shadow should be
visible.");
+ assertTrue(selenium.isVisible(resizerE), "Popup panel's right resizer
should be visible.");
+ assertTrue(selenium.isVisible(resizerN), "Popup panel's top resizer
should be visible.");
+ assertTrue(selenium.isVisible(resizerS), "Popup panel's bottom resizer
should be visible.");
+ assertTrue(selenium.isVisible(resizerW), "Popup panel's left resizer
should be visible.");
+ assertTrue(selenium.isVisible(resizerNE), "Popup panel's top-right
resizer should be visible.");
+ assertTrue(selenium.isVisible(resizerNW), "Popup panel's top-left
resizer should be visible.");
+ assertTrue(selenium.isVisible(resizerSE), "Popup panel's bottom-right
resizer should be visible.");
+ assertTrue(selenium.isVisible(resizerSW), "Popup panel's bottom-left
resizer should be visible.");
+ }
+
+ @Test
+ public void testPanelMove() {
+ selenium.click(openButton);
+ int panelLeft = selenium.getElementPositionLeft(panelContainer);
+ int shadowLeft = selenium.getElementPositionLeft(shadow);
+
+ assertEquals(selenium.getStyle(header, new CssProperty("cursor")),
"move", "Cursor used when mouse is over panel's header.");
+ selenium.dragAndDrop(header, new Offset(200, -100));
+
+ assertEquals(selenium.getElementPositionLeft(panelContainer), panelLeft + 200,
"Panel's position after move to the right (200px).");
+ assertEquals(selenium.getElementPositionLeft(shadow), shadowLeft + 200,
"Shadow's position after move to the right (200px).");
+ }
+
+ @Test
+ public void testPanelResizeHorizontal() {
+ selenium.click(openButton);
+ int panelWidth = selenium.getElementWidth(panelContainer);
+ int panelHeight = selenium.getElementHeight(panelContainer);
+ int shadowWidth = selenium.getElementWidth(shadow);
+ int shadowHeight = selenium.getElementHeight(shadow);
+
+ assertEquals(selenium.getStyle(resizerW, new CssProperty("cursor")),
"w-resize", "Cursor used when mouse is over panel's left
resizer.");
+ assertEquals(selenium.getStyle(resizerE, new CssProperty("cursor")),
"e-resize", "Cursor used when mouse is over panel's right
resizer.");
+
+ selenium.dragAndDrop(resizerW, new Offset(100, 0));
+
+ assertEquals(selenium.getElementWidth(panelContainer), panelWidth - 100,
"Panel's width after resizing horizontally (-100px).");
+ assertEquals(selenium.getElementHeight(panelContainer), panelHeight,
"Panel's height after resizing horizontally.");
+ assertEquals(selenium.getElementWidth(shadow), shadowWidth - 100,
"Shadow's width after resizing horizontally (-100px).");
+ assertEquals(selenium.getElementHeight(shadow), shadowHeight, "Shadow's
height after resizing horizontally.");
+
+ selenium.dragAndDrop(resizerE, new Offset(100, 0));
+
+ assertEquals(selenium.getElementWidth(panelContainer), panelWidth,
"Panel's width after resizing horizontally (100px).");
+ assertEquals(selenium.getElementHeight(panelContainer), panelHeight,
"Panel's height after resizing horizontally.");
+ assertEquals(selenium.getElementWidth(shadow), shadowWidth, "Shadow's
width after resizing horizontally (100px).");
+ assertEquals(selenium.getElementHeight(shadow), shadowHeight, "Shadow's
height after resizing horizontally.");
+ }
+
+ @Test
+ public void testPanelHeight() {
+ selenium.click(openButton);
+ waitGui.failWith("Panel was not
opened.").until(isDisplayed.locator(panel));
+ assertEquals(selenium.getStyle(panelContainer, CssProperty.HEIGHT),
"345px", "Height of the panel");
+ }
+
+ @Test
+ public void testPanelLeft() {
+ selenium.click(openButton);
+ waitGui.failWith("Panel was not
opened.").until(isDisplayed.locator(panel));
+ assertEquals(selenium.getElementPositionLeft(panelContainer), 77, "Left
margin of the panel");
+ }
+
+ @Test
+ public void testPanelTop() {
+ selenium.click(openButton);
+ waitGui.failWith("Panel was not
opened.").until(isDisplayed.locator(panel));
+ assertEquals(selenium.getElementPositionTop(panelContainer), 22, "Top margin
of the panel");
+ }
+
+ @Test
+ public void testPanelWidth() {
+ selenium.click(openButton);
+ waitGui.failWith("Panel was not
opened.").until(isDisplayed.locator(panel));
+ assertEquals(selenium.getStyle(panelContainer, CssProperty.WIDTH),
"543px", "Width of the panel");
+ }
+}
Property changes on:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHashParam/TestRichHashParam.java
___________________________________________________________________
Name: svn:keywords
+ Revision