Author: jpapouse
Date: 2011-09-14 04:47:24 -0400 (Wed, 14 Sep 2011)
New Revision: 22717
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/OrderingListAttributes.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/OrderingList.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/AbstractOrderingListTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingList.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingListAttributes.java
Log:
RFPL-1547 (ordering list): added some tests, mainly for events
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/OrderingList.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/OrderingList.java 2011-09-14
06:59:17 UTC (rev 22716)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/OrderingList.java 2011-09-14
08:47:24 UTC (rev 22717)
@@ -1,3 +1,24 @@
+/*******************************************************************************
+ * 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.model;
import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
@@ -22,8 +43,10 @@
private final JQueryLocator header = pjq("thead.rf-ord-lst-header >
tr");
private final JQueryLocator item = pjq("tbody[id$=orderingListItems] >
tr.rf-ord-opt");
private final JQueryLocator itemSelected = pjq("tbody[id$=orderingListItems]
> tr.rf-ord-opt.rf-ord-sel");
- private final JQueryLocator list = pjq("div.rf-ord-lst-scrl");
+ private final JQueryLocator list = pjq("div[id$=orderingList]
div.rf-ord-lst-dcrtn");
+ private final JQueryLocator listArea = pjq("div[id$=orderingList]
td:eq(0)");
private final JQueryLocator orderingList = pjq("div[id$=orderingList]");
+ private final JQueryLocator scrollableArea = pjq("div.rf-ord-lst-scrl");
private int numberOfItems = -1;
private int numberOfColumns = -1;
private final AjaxSelenium selenium;
@@ -71,6 +94,10 @@
return list;
}
+ public JQueryLocator getListArea() {
+ return listArea;
+ }
+
public JQueryLocator getLocator() {
return orderingList;
}
@@ -89,6 +116,10 @@
return numberOfItems;
}
+ public JQueryLocator getScrollableArea() {
+ return scrollableArea;
+ }
+
public boolean isButtonBottomEnabled() {
return isButtonEnabled(buttonBottom);
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/AbstractOrderingListTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/AbstractOrderingListTest.java 2011-09-14
06:59:17 UTC (rev 22716)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/AbstractOrderingListTest.java 2011-09-14
08:47:24 UTC (rev 22717)
@@ -24,9 +24,12 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
-
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.waiting.NegationCondition;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.richfaces.tests.metamer.ftest.model.OrderingList;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import org.richfaces.tests.metamer.ftest.attributes.Attributes;
/**
* Abstract test case for pages faces/components/richOrderingList/
@@ -37,6 +40,12 @@
private OrderingList orderingList = new OrderingList();
+ private JQueryLocator requestTime = jq("span#requestTime");
+
+ private JQueryLocator submitButton = pjq("input[id$=submitButton]");
+
+ protected static final Attributes<OrderingListAttributes> ATTRIBUTES = new
Attributes<OrderingListAttributes>();
+
protected void checkButtonsBottom() {
assertFalse(orderingList.isButtonBottomEnabled(), "The button [bottom]
should be disabled.");
assertFalse(orderingList.isButtonDownEnabled(), "The button [down] should be
disabled.");
@@ -129,6 +138,12 @@
assertTrue(selenium.belongsClass(getOrderingList().getItem(index),
"rf-ord-sel"), "After selecting an item, the item should belong to the
class <rf-ord-sel>.");
}
+ protected void submit() {
+ String timeBefore = selenium.getText(requestTime);
+ selenium.click(submitButton);
+ selenium.waitForPageToLoad();
+ }
+
private void checkColumnValuesSwapped(int indexA, String stateA, String cityA, int
indexB, String stateB, String cityB) {
assertEquals(orderingList.getItemColumnValue(indexA, 0), stateB, "The rows
weren't swapped succesfully after moving.");
assertEquals(orderingList.getItemColumnValue(indexA, 1), cityB, "The rows
weren't swapped succesfully after moving.");
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/OrderingListAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/OrderingListAttributes.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/OrderingListAttributes.java 2011-09-14
08:47:24 UTC (rev 22717)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.richOrderingList;
+
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
+
+/**
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public enum OrderingListAttributes implements AttributeEnum{
+
+ columnClasses,
+ columnVar,
+ converter,
+ converterMessage,
+ disabled,
+ disabledClass,
+ downBottomText,
+ downText,
+ headerClass,
+ immediate,
+ itemClass,
+ itemLabel,
+ itemValue,
+ listHeight,
+ listWidth,
+ maxListHeight,
+ minListHeight,
+ onblur,
+ onchange,
+ onclick,
+ ondblclick,
+ onfocus,
+ onkeydown,
+ onkeypress,
+ onkeyup,
+ onlistclick,
+ onlistdblclick,
+ onlistkeydown,
+ onlistkeypress,
+ onlistkeyup,
+ onlistmousedown,
+ onlistmousemove,
+ onlistmouseout,
+ onlistmouseover,
+ onlistmouseup,
+ onmousedown,
+ onmousemove,
+ onmouseout,
+ onmouseover,
+ onmouseup,
+ rendered,
+ required,
+ requiredMessage,
+ selectItemClass,
+ style,
+ styleClass,
+ upText,
+ upTopText,
+ validator,
+ validatorMessage,
+ value,
+ valueChangeListener,
+ var
+}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingList.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingList.java 2011-09-14
06:59:17 UTC (rev 22716)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingList.java 2011-09-14
08:47:24 UTC (rev 22717)
@@ -28,6 +28,7 @@
import org.testng.annotations.Test;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
/**
* Selenium tests for page faces/components/richOrderingList/withColumn.xhtml.
@@ -37,8 +38,6 @@
* @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
*/
public class TestOrderingList extends AbstractOrderingListTest {
-
- private OrderingList orderingList = new OrderingList();
@Override
public URL getTestUrl() {
@@ -47,30 +46,39 @@
@Test
public void testInit() {
- assertTrue(orderingList.isOrderingListPresent(), "The ordering list should
be present.");
- assertFalse(orderingList.isButtonBottomEnabled(), "The button [bottom]
should be disabled.");
- assertFalse(orderingList.isButtonDownEnabled(), "The button [down] should be
disabled.");
- assertFalse(orderingList.isButtonTopEnabled(), "The button [top] should be
disabled.");
- assertFalse(orderingList.isButtonUpEnabled(), "The button [up] should be
disabled.");
+ assertTrue(getOrderingList().isOrderingListPresent(), "The ordering list
should be present.");
+ assertFalse(getOrderingList().isButtonBottomEnabled(), "The button [bottom]
should be disabled.");
+ assertFalse(getOrderingList().isButtonDownEnabled(), "The button [down]
should be disabled.");
+ assertFalse(getOrderingList().isButtonTopEnabled(), "The button [top] should
be disabled.");
+ assertFalse(getOrderingList().isButtonUpEnabled(), "The button [up] should
be disabled.");
}
@Test
public void testSelectFirst() {
- orderingList.selectItem(0);
+ getOrderingList().selectItem(0);
checkButtonsTop();
}
@Test
public void testSelectLast() {
- orderingList.selectItem(orderingList.getNumberOfItems() - 1);
+ getOrderingList().selectItem(getOrderingList().getNumberOfItems() - 1);
checkButtonsBottom();
}
@Test
public void testSelectMiddle() {
- orderingList.selectItem(2);
+ getOrderingList().selectItem(2);
checkButtonsMiddle();
}
+ @Test
+ public void testSubmit() {
+ getOrderingList().selectItem(1);
+ getOrderingList().moveTop();
+ String expectedState = getOrderingList().getItemColumnValue(0, 0);
+ submit();
+ String foundState = getOrderingList().getItemColumnValue(0, 0);
+ assertEquals(expectedState, foundState, "After submitting the ordering list
doesn't preserve the chosen order.");
+ }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingListAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingListAttributes.java 2011-09-14
06:59:17 UTC (rev 22716)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingListAttributes.java 2011-09-14
08:47:24 UTC (rev 22717)
@@ -25,16 +25,21 @@
import java.util.HashMap;
import java.util.Map;
+import javax.swing.plaf.basic.BasicInternalFrameTitlePane.RestoreAction;
+
import org.jboss.test.selenium.css.CssProperty;
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.utils.URLUtils;
+import org.jboss.test.selenium.waiting.EventFiredCondition;
import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+import org.richfaces.tests.metamer.ftest.model.OrderingList;
import org.testng.annotations.Test;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
/**
* Selenium tests for page faces/components/richOrderingList/withColumn.xhtml.
@@ -42,7 +47,7 @@
* @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
*/
public class TestOrderingListAttributes extends AbstractOrderingListTest {
-
+
@Override
public URL getTestUrl() {
return URLUtils.buildUrl(contextPath,
"faces/components/richOrderingList/withColumn.xhtml");
@@ -50,7 +55,7 @@
@Test
public void testColumnClasses() {
- fillAttribute("columnClasses", "some-class");
+ ATTRIBUTES.set(OrderingListAttributes.columnClasses, "some-class");
for (int i=0; i<getOrderingList().getNumberOfColumns(); i++) {
assertTrue(selenium.belongsClass(getOrderingList().getItemColumn(0, i),
"some-class"), "The column <" + i + "> doesn't belong
to set class <some-class>.");
}
@@ -58,7 +63,7 @@
@Test
public void testDisabled() {
- fillAttribute("disabled", true);
+ ATTRIBUTES.set(OrderingListAttributes.disabled, "true");
try {
getOrderingList().getIndexOfSelectedItem();
fail("The attribute <disabled> is set to true, but the ordering
list is still enabled.");
@@ -67,55 +72,171 @@
}
@Test
+ public void testDisabledClass() {
+ ATTRIBUTES.set(OrderingListAttributes.disabled, "true");
+ ATTRIBUTES.set(OrderingListAttributes.disabledClass,
"disabled-class");
+ assertTrue(selenium.belongsClass(getOrderingList().getLocator(),
"disabled-class"), "The disabled class is not set when the ordering list is
disabled.");
+ }
+
+ @Test
public void testHeaderClass() {
- fillAttribute("headerClass", "some-class");
+ ATTRIBUTES.set(OrderingListAttributes.headerClass, "some-class");
assertTrue(selenium.belongsClass(getOrderingList().getHeader(),
"some-class"), "The attribute <headerClass> is set to
<some-class>, but the header doesn't belong to this class.");
}
@Test
- @IssueTracking("https://issues.jboss.org/browse/RF-11317")
public void testItemClass() {
- fillAttribute("itemClass", "some-class");
+ ATTRIBUTES.set(OrderingListAttributes.itemClass, "some-class");
assertTrue(selenium.belongsClass(getOrderingList().getItem(0),
"some-class"), "The attribute <itemClass> is set to
<some-class>, but the first item doesn't belong to this class.");
}
@Test
public void testListHeight() {
- testSizeCssProperty(getOrderingList().getList(), "listHeight",
CssProperty.HEIGHT);
+ testSizeCssProperty(getOrderingList().getScrollableArea(),
OrderingListAttributes.listHeight, CssProperty.HEIGHT);
}
@Test
public void testListWidth() {
- testSizeCssProperty(getOrderingList().getList(), "listWidth",
CssProperty.WIDTH);
+ testSizeCssProperty(getOrderingList().getScrollableArea(),
OrderingListAttributes.listWidth, CssProperty.WIDTH);
}
@Test
public void testMaxListHeight() {
- fillAttribute("listHeight", "");
- testSizeCssProperty(getOrderingList().getList(), "maxListHeight", new
CssProperty("max-height"));
+ ATTRIBUTES.set(OrderingListAttributes.listHeight, "");
+ testSizeCssProperty(getOrderingList().getScrollableArea(),
OrderingListAttributes.maxListHeight, new CssProperty("max-height"));
}
@Test
public void testMinListHeight() {
- fillAttribute("listHeight", "");
- testSizeCssProperty(getOrderingList().getList(), "minListHeight", new
CssProperty("min-height"));
+ ATTRIBUTES.set(OrderingListAttributes.listHeight, "");
+ testSizeCssProperty(getOrderingList().getScrollableArea(),
OrderingListAttributes.minListHeight, new CssProperty("min-height"));
}
@Test(enabled=false)
- public void testOnClick() {
- testFireEvent(Event.CLICK, pjq("div[id$=orderingList]
tr[id$=orderingList]:first"));
+ public void testOnblur() {
+ // TODO
}
@Test
+ public void testOnchange() {
+ testFireEvent(Event.CHANGE, getOrderingList().getLocator());
+ }
+
+ @Test
+ public void testOnclick() {
+ testFireEvent(Event.CLICK, getOrderingList().getLocator());
+ }
+
+ @Test(enabled=false)
+ @IssueTracking("https://issues.jboss.org/browse/RF-11318")
+ public void testOndblclick() {
+ // TODO
+ }
+
+ @Test(enabled=false)
+ public void testOnfocus() {
+ // TODO
+ }
+
+ @Test
+ public void testOnkeydown() {
+ testFireEvent(Event.KEYDOWN, getOrderingList().getListArea());
+ }
+
+ @Test
+ public void testOnkeypress() {
+ testFireEvent(Event.KEYPRESS, getOrderingList().getListArea());
+ }
+
+ @Test
+ public void testOnkeyup() {
+ testFireEvent(Event.KEYUP, getOrderingList().getListArea());
+ }
+
+ @Test
+ public void testOnlistclick() {
+ testFireEvent(Event.CLICK, getOrderingList().getList(), "listclick");
+ }
+
+ @Test(enabled=false)
+ public void testOnlistdblclick() {
+ // TODO
+ }
+
+ @Test
+ public void testOnlistkeydown() {
+ testFireEvent(Event.KEYDOWN, getOrderingList().getList(),
"listkeydown");
+ }
+
+ @Test
+ public void testOnlistkeypress() {
+ testFireEvent(Event.KEYPRESS, getOrderingList().getList(),
"listkeypress");
+ }
+
+ @Test
+ public void testOnlistkeyup() {
+ testFireEvent(Event.KEYUP, getOrderingList().getList(), "listkeyup");
+ }
+
+ @Test
+ public void testOnlistmousedown() {
+ testFireEvent(Event.MOUSEDOWN, getOrderingList().getList(),
"listmousedown");
+ }
+
+ @Test
+ public void testOnlistmousemove() {
+ testFireEvent(Event.MOUSEMOVE, getOrderingList().getList(),
"listmousemove");
+ }
+
+ @Test
+ public void testOnlistmouseout() {
+ testFireEvent(Event.MOUSEOUT, getOrderingList().getList(),
"listmouseout");
+ }
+
+ @Test
+ public void testOnlistmouseover() {
+ testFireEvent(Event.MOUSEOVER, getOrderingList().getList(),
"listmouseover");
+ }
+
+ @Test
+ public void testOnlistmouseup() {
+ testFireEvent(Event.MOUSEUP, getOrderingList().getList(),
"listmouseup");
+ }
+
+ @Test
+ public void testOnmousedown() {
+ testFireEvent(Event.MOUSEDOWN, getOrderingList().getLocator());
+ }
+
+ @Test
+ public void testOnmousemove() {
+ testFireEvent(Event.MOUSEMOVE, getOrderingList().getLocator());
+ }
+
+ @Test
+ public void testOnmouseout() {
+ testFireEvent(Event.MOUSEOUT, getOrderingList().getLocator());
+ }
+
+ @Test
+ public void testOnmouseover() {
+ testFireEvent(Event.MOUSEOVER, getOrderingList().getLocator());
+ }
+
+ @Test
+ public void testOnmouseup() {
+ testFireEvent(Event.MOUSEUP, getOrderingList().getLocator());
+ }
+
+ @Test
public void testRendered() {
- fillAttribute("rendered", false);
+ ATTRIBUTES.set(OrderingListAttributes.rendered, false);
assertFalse(getOrderingList().isOrderingListPresent(), "The attribute
<rendered> is set to <false>, but it has no effect.");
}
@Test
- @IssueTracking("https://issues.jboss.org/browse/RF-11310")
public void testSelectItemClass() {
- fillAttribute("selectItemClass", "some-class");
+ ATTRIBUTES.set(OrderingListAttributes.selectItemClass, "some-class");
selectItem(0);
assertTrue(selenium.belongsClass(getOrderingList().getItem(0),
"some-class"), "The attribute <selectItemClass> is set to
<some-class>, but it has no effect.");
}
@@ -125,28 +246,13 @@
super.testStyle(getOrderingList().getLocator(), "style");
}
- private void fillAttribute(String name, boolean value) {
- JQueryLocator attribute = pjq("input[type=radio][name$=" + name +
"Input][value=" + Boolean.toString(value) + "]");
- selenium.click(attribute);
- selenium.waitForPageToLoad();
- }
-
- private void fillAttribute(String name, String value) {
- JQueryLocator attribute = pjq("input[name$=" + name +
"Input]");
- selenium.type(attribute, value);
- selenium.fireEvent(attribute, Event.BLUR);
- selenium.waitForPageToLoad();
- }
-
- private void testSizeCssProperty(JQueryLocator element, String attributeName,
CssProperty cssProperty) {
+ private void testSizeCssProperty(JQueryLocator element, OrderingListAttributes
attribute, CssProperty cssProperty) {
Map<String, String> values = new HashMap<String, String>();
values.put("100", "100px");
- values.put("200px", "200px");
-// values.put("200em", "200em");
-// values.put("200cm", "200cm");
+ values.put("200px", "200px");
for(String value : values.keySet()) {
- fillAttribute(attributeName, value);
- assertEquals(selenium.getStyle(getOrderingList().getList(), cssProperty),
values.get(value), "The attribute <" + attributeName +"> is set to
<" + value + ">, but it has no effect.");
+ ATTRIBUTES.set(attribute, value);
+ assertEquals(selenium.getStyle(getOrderingList().getScrollableArea(),
cssProperty), values.get(value), "The attribute <" + attribute.name()
+"> is set to <" + value + ">, but it has no effect.");
}
}
}