Author: jjamrich
Date: 2011-10-06 16:38:24 -0400 (Thu, 06 Oct 2011)
New Revision: 22768
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMenuItem/MenuItemAttributes.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMenuItem/TestRichMenuItem.java
Log:
RFPL-1656: update tests for rich:menuItem
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java 2011-10-06
12:19:09 UTC (rev 22767)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java 2011-10-06
20:38:24 UTC (rev 22768)
@@ -24,6 +24,7 @@
import org.richfaces.tests.metamer.ftest.richGraphValidator.GraphValidatorAttributes;
import org.richfaces.tests.metamer.ftest.richJQuery.RichJQueryAttributes;
import org.richfaces.tests.metamer.ftest.richList.ListAttributes;
+import org.richfaces.tests.metamer.ftest.richMenuItem.MenuItemAttributes;
import org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes;
import org.richfaces.tests.metamer.ftest.richPanelMenu.PanelMenuAttributes;
import org.richfaces.tests.metamer.ftest.richPanelMenuGroup.PanelMenuGroupAttributes;
@@ -63,5 +64,6 @@
public static Attributes<PanelMenuItemAttributes> panelMenuItemAttributes = new
Attributes<PanelMenuItemAttributes>();
public static Attributes<PickListAttributes> pickListAttributes = new
Attributes<PickListAttributes>();
public static Attributes<TreeAttributes> treeAttributes = new
Attributes<TreeAttributes>(jq("span[id*=attributes]"));
+ public static Attributes<MenuItemAttributes> menuItemAttributes = new
Attributes<MenuItemAttributes>();
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java 2011-10-06
12:19:09 UTC (rev 22767)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java 2011-10-06
20:38:24 UTC (rev 22768)
@@ -18,6 +18,8 @@
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.ExtendedLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.LocatorFactory;
+import org.jboss.test.selenium.locator.option.OptionLabelLocator;
import org.jboss.test.selenium.locator.option.OptionValueLocator;
import org.jboss.test.selenium.locator.reference.LocatorReference;
import org.jboss.test.selenium.locator.reference.ReferencedLocator;
@@ -32,7 +34,7 @@
protected AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
LocatorReference<ExtendedLocator<JQueryLocator>> root =
new
LocatorReference<ExtendedLocator<JQueryLocator>>(pjq(""));
- ReferencedLocator<JQueryLocator> propertyLocator = referenceInferred(root,
":input[id*=:{0}Input]{1}");
+ ReferencedLocator<JQueryLocator> propertyLocator = referenceInferred(root,
":input[id*={0}Input]{1}");
RequestType requestType = RequestType.HTTP;
@@ -127,10 +129,10 @@
if (value == null) {
value = "";
}
+
+ String valueAsString = value.toString();
+ // System.out.println("\n ###setting following value as string: '"
+ valueAsString + "'");
- String valueAsString = value.toString();
- System.out.println("\n ###setting following value as string: '" +
valueAsString + "'");
-
if ("text".equals(inputType)) {
applyText(locator, valueAsString);
} else if ("checkbox".equals(inputType)) {
@@ -139,7 +141,7 @@
} else if ("radio".equals(inputType)) {
locator = propertyLocator.format(propertyName, "[value="
+ ("".equals(valueAsString) ? "null" : valueAsString)
+ "]");
-
+
if (!selenium.isChecked(locator)) {
applyRadio(locator);
}
@@ -177,7 +179,15 @@
protected void applySelect(ElementLocator<?> locator, String value) {
OptionValueLocator optionLocator = new OptionValueLocator(value);
- guard(selenium, requestType).select(locator, optionLocator);
+
+ LocatorFactory.jq(locator.getRawLocator());
+ JQueryLocator fullLocator =
jq(locator.getRawLocator()).getChild(jq(optionLocator.getRawLocator()));
+ if (selenium.isElementPresent(fullLocator)) {
+ guard(selenium, requestType).select(locator, optionLocator);
+ } else {
+ OptionLabelLocator optionLabelLocator = new OptionLabelLocator(value);
+ guard(selenium, requestType).select(locator, optionLabelLocator);
+ }
}
private class RepeatForElementNotFound implements CommandInterceptor {
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMenuItem/MenuItemAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMenuItem/MenuItemAttributes.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMenuItem/MenuItemAttributes.java 2011-10-06
20:38:24 UTC (rev 22768)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.richMenuItem;
+
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
+
+/**
+ * Attributes for rich:menuItem component
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ *
+ * @version $Revision$
+ */
+public enum MenuItemAttributes implements AttributeEnum {
+ bypassUpdates,
+ data,
+ dir,
+ disabled,
+ execute,
+ icon,
+ iconDisabled,
+ immediate,
+ label,
+ lang,
+ limitRender,
+ mode,
+ onbeforedomupdate,
+ onbegin,
+ onclick,
+ oncomplete,
+ ondblclick,
+ onkeydown,
+ onkeypress,
+ onkeyup,
+ onmousedown,
+ onmousemove,
+ onmouseout,
+ onmouseover,
+ onmouseup,
+ render,
+ rendered,
+ status,
+ style,
+ styleClass,
+ title
+}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMenuItem/TestRichMenuItem.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMenuItem/TestRichMenuItem.java 2011-10-06
12:19:09 UTC (rev 22767)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMenuItem/TestRichMenuItem.java 2011-10-06
20:38:24 UTC (rev 22768)
@@ -32,6 +32,8 @@
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.menuItemAttributes;
+import static org.richfaces.tests.metamer.ftest.richMenuItem.MenuItemAttributes.*;
import java.net.URL;
@@ -43,7 +45,6 @@
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
import org.testng.annotations.Test;
/**
@@ -123,9 +124,8 @@
@Test
public void testBypassUpdates() {
-
selenium.click(pjq("input[type=radio][name$=bypassUpdatesInput][value=true]"));
- selenium.waitForPageToLoad();
-
+ menuItemAttributes.set(bypassUpdates, Boolean.TRUE);
+
String reqTime = selenium.getText(time);
selenium.mouseOver(fileMenuLabel);
guardXhr(selenium).click(menuItem1);
@@ -142,11 +142,9 @@
@Test
public void testData() {
- selenium.type(pjq("input[type=text][id$=dataInput]"), "RichFaces
4");
- selenium.waitForPageToLoad();
+ menuItemAttributes.set(data, "RichFaces 4");
- selenium.type(pjq("input[type=text][id$=oncompleteInput]"), "data
= event.data");
- selenium.waitForPageToLoad();
+ menuItemAttributes.set(oncomplete, "data = event.data");
String reqTime = selenium.getText(time);
selenium.mouseOver(fileMenuLabel);
@@ -164,8 +162,7 @@
@Test
public void testDisabled() {
-
selenium.click(pjq("input[type=radio][name$=disabledInput][value=true]"));
- selenium.waitForPageToLoad();
+ menuItemAttributes.set(disabled, Boolean.TRUE);
assertTrue(selenium.belongsClass(menuItem1, "rf-ddm-itm-dis"),
"Menu item should have class \"rf-ddm-itm-dis\".");
@@ -176,8 +173,7 @@
@Test
public void testExecute() {
- selenium.type(pjq("input[type=text][id$=executeInput]"), "@this
executeChecker");
- selenium.waitForPageToLoad();
+ menuItemAttributes.set(execute, "@this executeChecker");
String reqTime = selenium.getText(time);
selenium.mouseOver(fileMenuLabel);
@@ -198,18 +194,18 @@
public void testIcon() {
AttributeLocator<?> attr = image.getAttribute(Attribute.SRC);
- selenium.select(pjq("select[id$=iconInput]"),
optionLabel("star"));
- selenium.waitForPageToLoad();
+ // selenium.select(pjq("select[id$=iconInput]"),
optionLabel("star"));
+ menuItemAttributes.set(icon, "star");
assertTrue(selenium.getAttribute(attr).contains("star.png"),
"Image's src attribute should contain
\"star.png\".");
- selenium.select(pjq("select[id$=iconInput]"),
optionLabel("nonexisting"));
- selenium.waitForPageToLoad();
+ // selenium.select(pjq("select[id$=iconInput]"),
optionLabel("nonexisting"));
+ menuItemAttributes.set(icon, "nonexisting");
assertTrue(selenium.getAttribute(attr).contains("nonexisting"),
"Image's src attribute should contain
\"nonexisting\".");
- selenium.select(pjq("select[id$=iconInput]"),
optionLabel("null"));
- selenium.waitForPageToLoad();
+ // selenium.select(pjq("select[id$=iconInput]"),
optionLabel("null"));
+ menuItemAttributes.set(icon, "null");
assertFalse(selenium.isElementPresent(image), "Icon should not be
present.");
assertTrue(selenium.isElementPresent(menuItem1.getDescendant(jq("div.rf-ddm-emptyIcon"))),
"Empty icon should be present.");
@@ -217,8 +213,7 @@
@Test
public void testIconDisabled() {
-
selenium.click(pjq("input[type=radio][name$=disabledInput][value=true]"));
- selenium.waitForPageToLoad();
+ menuItemAttributes.set(disabled, Boolean.TRUE);
AttributeLocator<?> attr = image.getAttribute(Attribute.SRC);
@@ -226,21 +221,20 @@
assertTrue(selenium.isElementPresent(menuItem1.getDescendant(jq("div.rf-ddm-emptyIcon"))),
"Empty icon should be present.");
- selenium.select(pjq("select[id$=iconDisabledInput]"),
optionLabel("star"));
- selenium.waitForPageToLoad();
+ // selenium.select(pjq("select[id$=iconDisabledInput]"),
optionLabel("star"));
+ menuItemAttributes.set(iconDisabled, "star");
assertTrue(selenium.getAttribute(attr).contains("star.png"),
"Image's src attribute should contain
\"star.png\".");
- selenium.select(pjq("select[id$=iconDisabledInput]"),
optionLabel("nonexisting"));
- selenium.waitForPageToLoad();
+ // selenium.select(pjq("select[id$=iconDisabledInput]"),
optionLabel("nonexisting"));
+ menuItemAttributes.set(iconDisabled, "nonexisting");
assertTrue(selenium.getAttribute(attr).contains("nonexisting"),
"Image's src attribute should contain
\"nonexisting\".");
}
@Test
public void testImmediate() {
-
selenium.click(pjq("input[type=radio][name$=immediateInput][value=true]"));
- selenium.waitForPageToLoad();
+ menuItemAttributes.set(immediate, Boolean.TRUE);
String reqTime = selenium.getText(time);
selenium.mouseOver(fileMenuLabel);
@@ -257,8 +251,7 @@
@Test
public void testLabel() {
- selenium.type(pjq("input[type=text][id$=labelInput]"), "new
label");
- selenium.waitForPageToLoad();
+ menuItemAttributes.set(MenuItemAttributes.label, "new label");
assertEquals(selenium.getText(label), "new label", "New label of
first menu item.");
}
@@ -270,8 +263,7 @@
@Test
public void testLimitRender() {
-
selenium.click(pjq("input[type=radio][name$=limitRenderInput][value=true]"));
- selenium.waitForPageToLoad();
+ menuItemAttributes.set(limitRender, Boolean.TRUE);
String reqTime = selenium.getText(time);
selenium.mouseOver(fileMenu);
@@ -283,6 +275,8 @@
@Test
public void testMode() {
String reqTime = selenium.getText(time);
+
+ // test for @mode=ajax
selenium.mouseOver(fileMenu);
guardXhr(selenium).click(menuItem1);
waitGui.failWith("Page was not updated").waitForChange(reqTime,
retrieveText.locator(time));
@@ -295,8 +289,8 @@
listenerOutput = selenium.getText(jq("div#phasesPanel li:eq(6)"));
assertEquals(listenerOutput, "* action invoked", "Action's
output");
- selenium.click(pjq("input[name$=modeInput][value=server]"));
- selenium.waitForPageToLoad();
+ // test for @mode=server
+ menuItemAttributes.set(mode, "server");
selenium.mouseOver(fileMenu);
guardHttp(selenium).click(menuItem1);
@@ -308,16 +302,14 @@
assertEquals(listenerOutput, "* action listener invoked", "Action
listener's output");
listenerOutput = selenium.getText(jq("div#phasesPanel li:eq(6)"));
assertEquals(listenerOutput, "* action invoked", "Action's
output");
+
}
@Test
public void testEvents() {
- selenium.type(pjq("input[type=text][id$=onbeginInput]"),
"metamerEvents += \"begin \"");
- selenium.waitForPageToLoad();
- selenium.type(pjq("input[type=text][id$=onbeforedomupdateInput]"),
"metamerEvents += \"beforedomupdate \"");
- selenium.waitForPageToLoad();
- selenium.type(pjq("input[type=text][id$=oncompleteInput]"),
"metamerEvents += \"complete \"");
- selenium.waitForPageToLoad();
+ menuItemAttributes.set(onbegin, "metamerEvents += \"begin
\"");
+ menuItemAttributes.set(onbeforedomupdate, "metamerEvents +=
\"beforedomupdate \"");
+ menuItemAttributes.set(oncomplete, "metamerEvents += \"complete
\"");
selenium.getEval(new JavaScript("window.metamerEvents =
\"\";"));
@@ -385,8 +377,7 @@
@Test
public void testRendered() {
-
selenium.click(pjq("input[type=radio][name$=renderedInput][value=false]"));
- selenium.waitForPageToLoad();
+ menuItemAttributes.set(rendered, Boolean.FALSE);
assertFalse(selenium.isElementPresent(menuItem1), "Menu item should not be
rendered when rendered=false.");
assertTrue(selenium.isDisplayed(menuItem1), "Menu item should be displayed
when item 1 is not rendered.");