Author: jpapouse
Date: 2011-08-16 07:43:57 -0400 (Tue, 16 Aug 2011)
New Revision: 22632
Added:
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/
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
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingListMoving.java
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichOrderingListBean.java
Log:
RFPL-1547: selenium tests for ordering list
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichOrderingListBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichOrderingListBean.java 2011-08-15
12:41:51 UTC (rev 22631)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichOrderingListBean.java 2011-08-16
11:43:57 UTC (rev 22632)
@@ -72,6 +72,13 @@
attributes.setAttribute("upText", "Up");
attributes.setAttribute("upTopText", "First");
+ attributes.remove("value");
+ // TODO has to be tested in another way
+ attributes.remove("converter");
+ attributes.remove("converterMessage");
+ attributes.remove("validator");
+ attributes.remove("validatorMessage");
+ attributes.remove("valueChangeListener");
// FIXME
capitals = Model.unmarshallCapitals();
}
Added:
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
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/OrderingList.java 2011-08-16
11:43:57 UTC (rev 22632)
@@ -0,0 +1,168 @@
+package org.richfaces.tests.metamer.ftest.model;
+
+import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
+import org.apache.commons.lang.Validate;
+import org.jboss.test.selenium.RequestTypeModelGuard.Model;
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+
+/**
+ * Object representing ordering list and all its elements
+ *
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class OrderingList implements Model {
+
+ private final JQueryLocator buttonBottom =
jq("button.rf-ord-down-bottom");
+ private final JQueryLocator buttonDown = jq("button.rf-ord-down");
+ private final JQueryLocator buttonTop = jq("button.rf-ord-up-top");
+ private final JQueryLocator buttonUp = jq("button.rf-ord-up");
+ 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 orderingList = pjq("div[id$=orderingList]");
+ private int numberOfItems = -1;
+ private int numberOfColumns = -1;
+ private final AjaxSelenium selenium;
+
+ public OrderingList() {
+ this(AjaxSeleniumProxy.getInstance());
+ }
+
+ public OrderingList(AjaxSelenium selenium) {
+ Validate.notNull(selenium);
+ this.selenium = selenium;
+ }
+
+ public JQueryLocator getHeader() {
+ return header;
+ }
+
+ public int getIndexOfSelectedItem() {
+ if (!isItemSelected()) {
+ throw new IllegalStateException("There is no selected item.");
+ }
+ return getNumberOfItems() - selenium.getCount(jq(itemSelected.getRawLocator() +
" ~ tr")) - 1;
+ }
+
+ public JQueryLocator getItem(int index) {
+ if (index < 0 || index >= getNumberOfItems()) {
+ throw new IndexOutOfBoundsException("The index <" + index +
"> is out of the range [0, "
+ + getNumberOfItems() + "].");
+ }
+ return jq(item.getRawLocator() + ":eq(" + index + ")");
+ }
+
+ public JQueryLocator getItemColumn(int indexItem, int indexColumn) {
+ if (indexColumn < 0 || indexColumn >= getNumberOfColumns()) {
+ throw new IndexOutOfBoundsException("The index of column <" +
indexColumn + "> is out of the range [0, " + getNumberOfColumns() +
"]");
+ }
+ return jq(getItem(indexItem).getRawLocator() + " > .rf-ord-cell:eq("
+ indexColumn + ")");
+ }
+
+ public String getItemColumnValue(int indexItem, int indexColumn) {
+ return selenium.getText(getItemColumn(indexItem, indexColumn));
+ }
+
+ public JQueryLocator getList() {
+ return list;
+ }
+
+ public JQueryLocator getLocator() {
+ return orderingList;
+ }
+
+ public int getNumberOfColumns() {
+ if (numberOfColumns == -1) {
+ numberOfColumns = selenium.getCount(jq(getItem(0).getRawLocator() + "
> .rf-ord-cell"));
+ }
+ return numberOfColumns;
+ }
+
+ public int getNumberOfItems() {
+ if (numberOfItems == -1) {
+ numberOfItems = selenium.getCount(item);
+ }
+ return numberOfItems;
+ }
+
+ public boolean isButtonBottomEnabled() {
+ return isButtonEnabled(buttonBottom);
+ }
+
+ public boolean isButtonDownEnabled() {
+ return isButtonEnabled(buttonDown);
+ }
+
+ public boolean isButtonTopEnabled() {
+ return isButtonEnabled(buttonTop);
+ }
+
+ public boolean isButtonUpEnabled() {
+ return isButtonEnabled(buttonUp);
+ }
+
+ public boolean isButtonBottomPresent() {
+ return selenium.isElementPresent(buttonBottom);
+ }
+
+ public boolean isButtonDownPresent() {
+ return selenium.isElementPresent(buttonDown);
+ }
+
+ public boolean isButtonTopPresent() {
+ return selenium.isElementPresent(buttonTop);
+ }
+
+ public boolean isButtonUpPresent() {
+ return selenium.isElementPresent(buttonUp);
+ }
+
+ public boolean isItemSelected() {
+ return selenium.isElementPresent(itemSelected);
+ }
+
+ public boolean isOrderingListPresent() {
+ return selenium.isElementPresent(orderingList);
+ }
+
+ public void moveBottom() {
+ move(buttonBottom);
+ }
+
+ public void moveDown() {
+ move(buttonDown);
+ }
+
+ public void moveTop() {
+ move(buttonTop);
+ }
+
+ public void moveUp() {
+ move(buttonUp);
+ }
+
+ public void selectItem(int index) {
+ selenium.mouseDown(getItem(index));
+ selenium.mouseUp(getItem(index));
+ selenium.click(getItem(index));
+ }
+
+ private boolean isButtonEnabled(JQueryLocator button) {
+ return !selenium.isElementPresent(jq(button.getRawLocator() +
".rf-ord-btn-dis"));
+ }
+
+ private void move(JQueryLocator button) {
+ if (!selenium.isElementPresent(itemSelected)) {
+ throw new IllegalStateException("No item is selected, so the moving
action can't be proceeded.");
+ }
+ if (!isButtonEnabled(button)) {
+ throw new IllegalStateException("The moving action can't be
proceeded because the moving button is disabled.");
+ }
+ selenium.click(button);
+ }
+
+}
Added:
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
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/AbstractOrderingListTest.java 2011-08-16
11:43:57 UTC (rev 22632)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * 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 static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.model.OrderingList;
+
+/**
+ * Abstract test case for pages faces/components/richOrderingList/
+ *
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public abstract class AbstractOrderingListTest extends AbstractMetamerTest {
+
+ private OrderingList orderingList = new OrderingList();
+
+ protected void checkButtonsBottom() {
+ assertFalse(orderingList.isButtonBottomEnabled(), "The button [bottom]
should be disabled.");
+ assertFalse(orderingList.isButtonDownEnabled(), "The button [down] should be
disabled.");
+ assertTrue(orderingList.isButtonTopEnabled(), "The button [top] should be
enabled.");
+ assertTrue(orderingList.isButtonUpEnabled(), "The button [up] should be
enabled.");
+ }
+
+ protected void checkButtonsMiddle() {
+ assertTrue(orderingList.isButtonBottomEnabled(), "The button [bottom] should
be enabled.");
+ assertTrue(orderingList.isButtonDownEnabled(), "The button [down] should be
enabled.");
+ assertTrue(orderingList.isButtonTopEnabled(), "The button [top] should be
enabled.");
+ assertTrue(orderingList.isButtonUpEnabled(), "The button [up] should be
enabled.");
+ }
+
+ protected void checkButtonsTop() {
+ assertTrue(orderingList.isButtonBottomEnabled(), "The button [bottom] should
be enabled.");
+ assertTrue(orderingList.isButtonDownEnabled(), "The button [down] should be
enabled.");
+ assertFalse(orderingList.isButtonTopEnabled(), "The button [top] should be
disabled.");
+ assertFalse(orderingList.isButtonUpEnabled(), "The button [up] should be
disabled.");
+ }
+
+ protected OrderingList getOrderingList() {
+ return orderingList;
+ }
+
+ protected void moveBottom() {
+ int beforeIndex = orderingList.getIndexOfSelectedItem();
+ String stateA = orderingList.getItemColumnValue(beforeIndex, 0);
+ String cityA = orderingList.getItemColumnValue(beforeIndex, 1);
+ String stateB = orderingList.getItemColumnValue(orderingList.getNumberOfItems() -
1, 0);
+ String cityB = orderingList.getItemColumnValue(orderingList.getNumberOfItems() -
1, 1);
+ orderingList.moveBottom();
+ int after = orderingList.getIndexOfSelectedItem();
+ assertEquals(after, orderingList.getNumberOfItems() - 1, "The index of
selected item doesn't match.");
+ checkColumnValuesMoved(beforeIndex, stateA, cityA,
orderingList.getNumberOfItems() - 1, stateB, cityB);
+ checkButtonsBottom();
+ }
+
+ protected void moveDown() {
+ int beforeIndex = orderingList.getIndexOfSelectedItem();
+ String stateA = orderingList.getItemColumnValue(beforeIndex, 0);
+ String cityA = orderingList.getItemColumnValue(beforeIndex, 1);
+ String stateB = orderingList.getItemColumnValue(beforeIndex + 1, 0);
+ String cityB = orderingList.getItemColumnValue(beforeIndex + 1, 1);
+ orderingList.moveDown();
+ int afterIndex = orderingList.getIndexOfSelectedItem();
+ assertEquals(afterIndex, beforeIndex + 1, "The index of selected item
doesn't match.");
+ checkColumnValuesSwapped(beforeIndex, stateA, cityA, afterIndex, stateB, cityB);
+ if (afterIndex < orderingList.getNumberOfItems() - 1) {
+ checkButtonsMiddle();
+ }
+ else {
+ checkButtonsBottom();
+ }
+ }
+
+ protected void moveTop() {
+ int beforeIndex = orderingList.getIndexOfSelectedItem();
+ String stateA = orderingList.getItemColumnValue(beforeIndex, 0);
+ String cityA = orderingList.getItemColumnValue(beforeIndex, 1);
+ String stateB = orderingList.getItemColumnValue(0, 0);
+ String cityB = orderingList.getItemColumnValue(0, 1);
+ orderingList.moveTop();
+ int afterIndex = orderingList.getIndexOfSelectedItem();
+ assertEquals(afterIndex, 0, "The index of selected item doesn't
match.");
+ checkColumnValuesMoved(beforeIndex, stateA, cityA, afterIndex, stateB, cityB);
+ checkButtonsTop();
+ }
+
+ protected void moveUp() {
+ int beforeIndex = orderingList.getIndexOfSelectedItem();
+ String stateA = orderingList.getItemColumnValue(beforeIndex, 0);
+ String cityA = orderingList.getItemColumnValue(beforeIndex, 1);
+ String stateB = orderingList.getItemColumnValue(beforeIndex - 1, 0);
+ String cityB = orderingList.getItemColumnValue(beforeIndex - 1, 1);
+ orderingList.moveUp();
+ int afterIndex = orderingList.getIndexOfSelectedItem();
+ assertEquals(afterIndex, beforeIndex - 1, "The index of selected item
doesn't match.");
+ checkColumnValuesSwapped(beforeIndex, stateA, cityA, afterIndex, stateB, cityB);
+ if (afterIndex > 0) {
+ checkButtonsMiddle();
+ }
+ else {
+ checkButtonsTop();
+ }
+ }
+
+ 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.");
+ assertEquals(orderingList.getItemColumnValue(indexB, 0), stateA, "The rows
weren't swapped succesfully after moving.");
+ assertEquals(orderingList.getItemColumnValue(indexB, 1), cityA, "The rows
weren't swapped succesfully after moving.");
+ }
+
+ private void checkColumnValuesMoved(int indexA, String stateA, String cityA, int
indexB, String stateB, String cityB) {
+ assertEquals(orderingList.getItemColumnValue(indexB + (int) Math.signum(indexA -
indexB), 0), stateB, "The rows weren't moved succesfully after moving.");
+ assertEquals(orderingList.getItemColumnValue(indexB + (int) Math.signum(indexA -
indexB), 1), cityB, "The rows weren't moved succesfully after moving.");
+ assertEquals(orderingList.getItemColumnValue(indexB, 0), stateA, "The rows
weren't moved succesfully after moving.");
+ assertEquals(orderingList.getItemColumnValue(indexB, 1), cityA, "The rows
weren't moved succesfully after moving.");
+ }
+
+}
Added:
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
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingList.java 2011-08-16
11:43:57 UTC (rev 22632)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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 java.net.URL;
+
+import org.jboss.test.selenium.utils.URLUtils;
+import org.richfaces.tests.metamer.ftest.model.OrderingList;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * Selenium tests for page faces/components/richOrderingList/simple.xhtml.
+ *
+ * It checks whether the moving is OK.
+ *
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class TestOrderingList extends AbstractOrderingListTest {
+
+ private OrderingList orderingList = new OrderingList();
+
+ @Override
+ public URL getTestUrl() {
+ return URLUtils.buildUrl(contextPath,
"faces/components/richOrderingList/simple.xhtml");
+ }
+
+ @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.");
+ }
+
+ @Test
+ public void testSelectFirst() {
+ orderingList.selectItem(0);
+ checkButtonsTop();
+ }
+
+ @Test
+ public void testSelectLast() {
+ orderingList.selectItem(orderingList.getNumberOfItems() - 1);
+ checkButtonsBottom();
+ }
+
+ @Test
+ public void testSelectMiddle() {
+ orderingList.selectItem(2);
+ checkButtonsMiddle();
+ }
+
+
+}
Added:
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
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingListAttributes.java 2011-08-16
11:43:57 UTC (rev 22632)
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * 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 java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+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.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+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;
+
+/**
+ * Selenium tests for page faces/components/richOrderingList/simple.xhtml.
+ *
+ * @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/simple.xhtml");
+ }
+
+ @Test
+ public void testColumnClasses() {
+ fillAttribute("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>.");
+ }
+ }
+
+ @Test
+ public void testDisabled() {
+ fillAttribute("disabled", true);
+ try {
+ getOrderingList().getIndexOfSelectedItem();
+ fail("The attribute <disabled> is set to true, but the ordering
list is still enabled.");
+ }
+ catch(IllegalStateException e) {}
+ }
+
+ @Test
+ public void testHeaderClass() {
+ fillAttribute("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
+ public void testItemClass() {
+ fillAttribute("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);
+ }
+
+ @Test
+ public void testListWidth() {
+ testSizeCssProperty(getOrderingList().getList(), "listWidth",
CssProperty.WIDTH);
+ }
+
+ @Test
+ public void testMaxListHeight() {
+ fillAttribute("listHeight", "");
+ testSizeCssProperty(getOrderingList().getList(), "maxListHeight", new
CssProperty("max-height"));
+ }
+
+ @Test
+ public void testMinListHeight() {
+ fillAttribute("listHeight", "");
+ testSizeCssProperty(getOrderingList().getList(), "minListHeight", new
CssProperty("min-height"));
+ }
+
+ @Test(enabled=false)
+ public void testOnClick() {
+ testFireEvent(Event.CLICK, pjq("div[id$=orderingList]
tr[id$=orderingList]:first"));
+ }
+
+ @Test
+ public void testRendered() {
+ fillAttribute("rendered", false);
+ assertFalse(getOrderingList().isOrderingListPresent(), "The attribute
<rendered> is set to <false>, but it has no effect.");
+ }
+
+ @Test
+ public void testSelectItemClass() {
+ fillAttribute("selectItemClass", "some-class");
+ getOrderingList().selectItem(0);
+ assertTrue(selenium.belongsClass(getOrderingList().getItem(0),
"some-class"), "The attribute <selectItemClass> is set to
<some-class>, but it has no effect.");
+ }
+
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-11311")
+ public void testShowButton() {
+ fillAttribute("showButton", false);
+ assertFalse(getOrderingList().isButtonBottomPresent(), "The attribute
<showButton> is set <false>, but the button [bottom] is present.");
+ assertFalse(getOrderingList().isButtonDownPresent(), "The attribute
<showButton> is set <false>, but the button [down] is present.");
+ assertFalse(getOrderingList().isButtonTopPresent(), "The attribute
<showButton> is set <false>, but the button [top] is present.");
+ assertFalse(getOrderingList().isButtonUpPresent(), "The attribute
<showButton> is set <false>, but the button [up] is present.");
+ }
+
+ @Test
+ public void testStyle() {
+ 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) {
+ Map<String, String> values = new HashMap<String, String>();
+ values.put("100", "100px");
+ values.put("200px", "200px");
+// values.put("200em", "200em");
+// values.put("200cm", "200cm");
+ 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.");
+ }
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingListMoving.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingListMoving.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richOrderingList/TestOrderingListMoving.java 2011-08-16
11:43:57 UTC (rev 22632)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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 java.net.URL;
+
+import org.jboss.test.selenium.utils.URLUtils;
+import org.testng.annotations.Test;
+
+/**
+ * Selenium tests for page faces/components/richOrderingList/simple.xhtml.
+ *
+ * It checks whether the moving is OK.
+ *
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class TestOrderingListMoving extends AbstractOrderingListTest {
+
+ @Override
+ public URL getTestUrl() {
+ return URLUtils.buildUrl(contextPath,
"faces/components/richOrderingList/simple.xhtml");
+ }
+
+ @Test
+ public void testMoveFirstBottom() {
+ getOrderingList().selectItem(0);
+ moveBottom();
+ }
+
+ @Test
+ public void testMoveFirstDown() {
+ getOrderingList().selectItem(0);
+ moveDown();
+ }
+
+ @Test
+ public void testMoveLastTop() {
+ getOrderingList().selectItem(getOrderingList().getNumberOfItems() - 1);
+ moveTop();
+ }
+
+ @Test
+ public void testMoveLastUp() {
+ getOrderingList().selectItem(getOrderingList().getNumberOfItems() - 1);
+ moveUp();
+ }
+
+ @Test
+ public void testMoveMiddleBottom() {
+ getOrderingList().selectItem(2);
+ moveBottom();
+ }
+
+ @Test
+ public void testMoveMiddleDown() {
+ getOrderingList().selectItem(2);
+ moveDown();
+ }
+
+ @Test
+ public void testMoveMiddleTop() {
+ getOrderingList().selectItem(2);
+ moveTop();
+ }
+
+ @Test
+ public void testMoveMiddleUp() {
+ getOrderingList().selectItem(2);
+ moveUp();
+ }
+
+}