Author: lfryc(a)redhat.com
Date: 2011-02-07 09:18:06 -0500 (Mon, 07 Feb 2011)
New Revision: 21507
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/GuardRequest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemClientSideHandlers.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemDOMEventHandlers.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemMode.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemSimple.java
Modified:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichPanelMenuItemBean.properties
modules/tests/metamer/trunk/application/src/main/webapp/components/richPanelMenuItem/simple.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/PanelMenu.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/PanelMenuItemAttributes.java
Log:
rich:panelMenuItem - automated (RFPL-950)
Modified:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichPanelMenuItemBean.properties
===================================================================
---
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichPanelMenuItemBean.properties 2011-02-07
14:17:40 UTC (rev 21506)
+++
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichPanelMenuItemBean.properties 2011-02-07
14:18:06 UTC (rev 21507)
@@ -11,15 +11,15 @@
attr.leftIcon.triangleDown=triangleDown
attr.leftIcon.customURL=/resources/images/loading.gif
attr.leftIcon.null=
-attr.leftIconDisabled.grid=grid
-attr.leftIconDisabled.disc=disc
-attr.leftIconDisabled.chevronUp=chevronUp
-attr.leftIconDisabled.chevronDown=chevronDown
-attr.leftIconDisabled.triangle=triangle
-attr.leftIconDisabled.triangleUp=triangleUp
-attr.leftIconDisabled.triangleDown=triangleDown
-attr.leftIconDisabled.customURL=/resources/images/loading.gif
-attr.leftIconDisabled.null=
+attr.leftDisabledIcon.grid=grid
+attr.leftDisabledIcon.disc=disc
+attr.leftDisabledIcon.chevronUp=chevronUp
+attr.leftDisabledIcon.chevronDown=chevronDown
+attr.leftDisabledIcon.triangle=triangle
+attr.leftDisabledIcon.triangleUp=triangleUp
+attr.leftDisabledIcon.triangleDown=triangleDown
+attr.leftDisabledIcon.customURL=/resources/images/loading.gif
+attr.leftDisabledIcon.null=
attr.rightIcon.grid=grid
attr.rightIcon.disc=disc
attr.rightIcon.chevronUp=chevronUp
@@ -29,12 +29,12 @@
attr.rightIcon.triangleDown=triangleDown
attr.rightIcon.customURL=/resources/images/loading.gif
attr.rightIcon.null=
-attr.rightIconDisabled.grid=grid
-attr.rightIconDisabled.disc=disc
-attr.rightIconDisabled.chevronUp=chevronUp
-attr.rightIconDisabled.chevronDown=chevronDown
-attr.rightIconDisabled.triangle=triangle
-attr.rightIconDisabled.triangleUp=triangleUp
-attr.rightIconDisabled.triangleDown=triangleDown
-attr.rightIconDisabled.customURL=/resources/images/loading.gif
-attr.rightIconDisabled.null=
\ No newline at end of file
+attr.rightDisabledIcon.grid=grid
+attr.rightDisabledIcon.disc=disc
+attr.rightDisabledIcon.chevronUp=chevronUp
+attr.rightDisabledIcon.chevronDown=chevronDown
+attr.rightDisabledIcon.triangle=triangle
+attr.rightDisabledIcon.triangleUp=triangleUp
+attr.rightDisabledIcon.triangleDown=triangleDown
+attr.rightDisabledIcon.customURL=/resources/images/loading.gif
+attr.rightDisabledIcon.null=
\ No newline at end of file
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richPanelMenuItem/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richPanelMenuItem/simple.xhtml 2011-02-07
14:17:40 UTC (rev 21506)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richPanelMenuItem/simple.xhtml 2011-02-07
14:18:06 UTC (rev 21507)
@@ -59,15 +59,16 @@
hoverClass="#{richPanelMenuItemBean.attributes['hoverClass'].value}"
leftIcon="#{richPanelMenuItemBean.attributes['leftIcon'].value}"
leftIconClass="#{richPanelMenuItemBean.attributes['leftIconClass'].value}"
-
leftIconDisabled="#{richPanelMenuItemBean.attributes['leftIconDisabled'].value}"
+
leftDisabledIcon="#{richPanelMenuItemBean.attributes['leftDisabledIcon'].value}"
rightIcon="#{richPanelMenuItemBean.attributes['rightIcon'].value}"
rightIconClass="#{richPanelMenuItemBean.attributes['rightIconClass'].value}"
-
rightIconDisabled="#{richPanelMenuItemBean.attributes['rightIconDisabled'].value}"
+
rightDisabledIcon="#{richPanelMenuItemBean.attributes['rightDisabledIcon'].value}"
immediate="#{richPanelMenuItemBean.attributes['immediate'].value}"
limitRender="#{richPanelMenuItemBean.attributes['limitRender'].value}"
mode="#{richPanelMenuItemBean.attributes['mode'].value}"
onbeforedomupdate="#{richPanelMenuItemBean.attributes['onbeforedomupdate'].value}"
onbeforeselect="#{richPanelMenuItemBean.attributes['onbeforeselect'].value}"
+
onbegin="#{richPanelMenuItemBean.attributes['onbegin'].value}"
onclick="#{richPanelMenuItemBean.attributes['onclick'].value}"
oncomplete="#{richPanelMenuItemBean.attributes['oncomplete'].value}"
ondblclick="#{richPanelMenuItemBean.attributes['ondblclick'].value}"
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/GuardRequest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/GuardRequest.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/GuardRequest.java 2011-02-07
14:18:06 UTC (rev 21507)
@@ -0,0 +1,46 @@
+/*
+ * 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.jboss.test.selenium;
+
+import org.jboss.test.selenium.guard.request.RequestTypeGuard;
+import org.jboss.test.selenium.request.RequestType;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class GuardRequest {
+
+ private RequestTypeGuard guard;
+
+ public GuardRequest(RequestType requestExpected) {
+ guard = new RequestTypeGuard(requestExpected, false);
+ }
+
+ public void waitRequest() {
+ guard.doBeforeCommand();
+ command();
+ guard.doAfterCommand();
+ }
+
+ public abstract void command();
+}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java 2011-02-07
14:17:40 UTC (rev 21506)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java 2011-02-07
14:18:06 UTC (rev 21507)
@@ -22,6 +22,7 @@
package org.richfaces.tests.metamer.ftest;
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guard;
+import static org.jboss.test.selenium.locator.Attribute.VALUE;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static
org.jboss.test.selenium.locator.reference.ReferencedLocator.referenceInferred;
import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
@@ -68,7 +69,10 @@
}
protected String getProperty(String propertyName) {
- final ElementLocator<?> locator = propertyLocator.format(propertyName,
"");
+ final ReferencedLocator<JQueryLocator> locator =
propertyLocator.format(propertyName, "");
+ if (selenium.getCount(locator) > 1) {
+ return selenium.getAttribute(propertyLocator.format(propertyName,
"[checked]").getAttribute(VALUE));
+ }
return selenium.getValue(locator);
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/PanelMenu.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/PanelMenu.java 2011-02-07
14:17:40 UTC (rev 21506)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/PanelMenu.java 2011-02-07
14:18:06 UTC (rev 21507)
@@ -1,19 +1,25 @@
package org.richfaces.tests.metamer.ftest.model;
import static org.jboss.test.selenium.locator.Attribute.CLASS;
+import static org.jboss.test.selenium.locator.Attribute.SRC;
import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import org.jboss.test.selenium.JQuerySelectors;
+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.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.locator.reference.ReferencedLocator;
+import org.jboss.test.selenium.utils.text.SimplifiedFormat;
-public class PanelMenu extends AbstractModel<JQueryLocator> {
+public class PanelMenu extends AbstractModel<JQueryLocator> implements Model {
AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- private ReferencedLocator<JQueryLocator> topItems = ref(root, ">
rf-pm-top-itm");
- private ReferencedLocator<JQueryLocator> topGroups = ref(root, ">
rf-pm-top-gr");
+ private ReferencedLocator<JQueryLocator> topItems = ref(root, ">
.rf-pm-top-itm");
+ private ReferencedLocator<JQueryLocator> topGroups = ref(root, ">
.rf-pm-top-gr");
public PanelMenu(JQueryLocator root) {
super(root);
@@ -51,14 +57,15 @@
return new Group(topGroups.getReferenced());
}
- public class Group extends AbstractModel<JQueryLocator> {
+ public class Group extends AbstractModel<JQueryLocator> implements Model {
ReferencedLocator<JQueryLocator> label = ref(root, "> table >
tbody > tr > td[class*=rf-][class*=-gr-lbl]");
ReferencedLocator<JQueryLocator> leftIcon = ref(root, "> table >
tbody > tr > td[class*=rf-][class*=-gr-ico]");
ReferencedLocator<JQueryLocator> rightIcon = ref(root,
"div[class*=rf-][class*=-gr-hdr] > table > tbody > tr >
td[class*=rf-][class*=-itm-gr-ico]");
- private ReferencedLocator<JQueryLocator> items = ref(root, ">
rf-pm-itm");
- private ReferencedLocator<JQueryLocator> groups = ref(root, ">
rf-pm-gr");
+ private ReferencedLocator<JQueryLocator> content = ref(root, ">
div[class*=rf-pm-][class*=gr-cnt]");
+ private ReferencedLocator<JQueryLocator> items = ref(content, ">
.rf-pm-itm");
+ private ReferencedLocator<JQueryLocator> groups = ref(content, ">
.rf-pm-gr");
public Group(JQueryLocator root) {
super(root);
@@ -79,6 +86,10 @@
public Item getItem(int index) {
return new Item(items.getNthOccurence(index));
}
+
+ public Item getItemContains(String string) {
+ return new Item(JQuerySelectors.append(items,
SimplifiedFormat.format(":contains('{0}')", string)));
+ }
public Iterable<Group> getAllGroups() {
return new ModelIterable<JQueryLocator,
Group>(groups.getAllOccurrences(), Group.class);
@@ -99,7 +110,7 @@
public boolean isSelected() {
return
selenium.getAttribute(this.getAttribute(CLASS)).contains("-sel");
}
-
+
public Icon getLeftIcon() {
return new Icon(leftIcon.getReferenced());
}
@@ -113,7 +124,7 @@
}
}
- public class Item extends AbstractModel<JQueryLocator> {
+ public class Item extends AbstractModel<JQueryLocator> implements Model {
ReferencedLocator<JQueryLocator> label = ref(root, "> table >
tbody > tr > td[class*=rf-][class*=-itm-lbl]");
ReferencedLocator<JQueryLocator> leftIcon = ref(root, "> table >
tbody > tr > td[class*=rf-][class*=-itm-ico]");
ReferencedLocator<JQueryLocator> rightIcon = ref(root,
@@ -131,6 +142,14 @@
return
selenium.getAttribute(this.getAttribute(CLASS)).contains("-hov");
}
+ public boolean isDisabled() {
+ return
selenium.getAttribute(this.getAttribute(CLASS)).contains("-dis");
+ }
+
+ public boolean isVisible() {
+ return selenium.isElementPresent(this) &&
selenium.isDisplayed(this);
+ }
+
public Icon getLeftIcon() {
return new Icon(leftIcon.getReferenced());
}
@@ -142,6 +161,14 @@
public Label getLabel() {
return new Label(label.getReferenced());
}
+
+ public void select() {
+ selenium.click(label);
+ }
+
+ public void hover() {
+ selenium.mouseOver(this);
+ }
}
public class Icon extends AbstractModel<JQueryLocator> {
@@ -150,6 +177,25 @@
super(root);
}
+ ReferencedLocator<JQueryLocator> img = ref(root, "> img");
+ AttributeLocator<?> imgSrc = img.getAttribute(SRC);
+
+ public boolean isTransparent() {
+ return
selenium.getAttribute(this.getAttribute(CLASS)).contains("-transparent");
+ }
+
+ public boolean containsClass(String styleClass) {
+ return selenium.belongsClass(this, styleClass);
+ }
+
+ public boolean isCustomURL() {
+ return selenium.isElementPresent(img);
+ }
+
+ public String getCustomURL() {
+ return selenium.getAttribute(imgSrc);
+ }
+
}
public class Label extends AbstractModel<JQueryLocator> {
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/PanelMenuItemAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/PanelMenuItemAttributes.java 2011-02-07
14:17:40 UTC (rev 21506)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/PanelMenuItemAttributes.java 2011-02-07
14:18:06 UTC (rev 21507)
@@ -57,15 +57,15 @@
setProperty("leftDisabledIcon", leftDisabledIcon);
}
- public void setLeftExpandedIcon(String leftExpandedIcon) {
- setProperty("leftIcon", leftExpandedIcon);
+ public void setLeftIcon(String leftIcon) {
+ setProperty("leftIcon", leftIcon);
}
-
+
public void setLeftIconClass(String leftIconClass) {
setProperty("leftIconClass", leftIconClass);
}
- public void setLimitRender(String limitRender) {
+ public void setLimitRender(Boolean limitRender) {
setProperty("limitRender", limitRender);
}
@@ -73,6 +73,10 @@
setProperty("mode", mode);
}
+ public PanelMenuMode getMode() {
+ return PanelMenuMode.valueOf(getProperty("mode"));
+ }
+
public void setRender(String render) {
setProperty("render", render);
}
@@ -84,7 +88,11 @@
public void setRightDisabledIcon(String rightDisabledIcon) {
setProperty("rightDisabledIcon", rightDisabledIcon);
}
-
+
+ public void setRightIcon(String rightIcon) {
+ setProperty("rightIcon", rightIcon);
+ }
+
public void setRightIconClass(String rightIconClass) {
setProperty("rightIconClass", rightIconClass);
}
@@ -96,8 +104,8 @@
public void setStatus(String status) {
setProperty("status", status);
}
-
- public void setStyle (String style) {
+
+ public void setStyle(String style) {
setProperty("style", style);
}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemClientSideHandlers.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemClientSideHandlers.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemClientSideHandlers.java 2011-02-07
14:18:06 UTC (rev 21507)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.richPanelMenuItem;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.richfaces.PanelMenuMode.ajax;
+import static org.richfaces.PanelMenuMode.client;
+import static org.richfaces.PanelMenuMode.server;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.GuardRequest;
+import org.jboss.test.selenium.request.RequestType;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.model.PanelMenu;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestPanelMenuItemClientSideHandlers extends AbstractMetamerTest {
+
+ PanelMenuItemAttributes attributes = new PanelMenuItemAttributes();
+ PanelMenu menu = new PanelMenu(pjq("div.rf-pm[id$=panelMenu]"));
+ PanelMenu.Item item = menu.getGroup(1).getItem(2);
+
+ @Inject
+ @Use(empty = true)
+ String event;
+ String[] ajaxEvents = new String[] { "begin", "beforedomupdate",
"beforeselect", "select", "complete" };
+ String[] clientEvents = new String[] { "beforeselect", "select"
};
+ String[] serverEvents = new String[] { "select" };
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richPanelMenuItem/simple.xhtml");
+ }
+
+ @Test
+ @Use(field = "event", value = "ajaxEvents")
+ public void testClientSideEvent() {
+ attributes.setMode(ajax);
+ super.testRequestEventsBefore(event);
+ selectItem();
+ super.testRequestEventsAfter(event);
+ }
+
+ @Test
+ public void testClientSideEventsOrderClient() {
+ attributes.setMode(client);
+ super.testRequestEventsBefore(clientEvents);
+ selectItem();
+ super.testRequestEventsAfter(clientEvents);
+ }
+
+ @Test
+ public void testClientSideEventsOrderAjax() {
+ attributes.setMode(ajax);
+ super.testRequestEventsBefore(ajaxEvents);
+ selectItem();
+ super.testRequestEventsAfter(ajaxEvents);
+ }
+
+ @Test
+ public void testClientSideEventsOrderServer() {
+ attributes.setMode(server);
+ super.testRequestEventsBefore(serverEvents);
+ selectItem();
+ super.testRequestEventsAfter(serverEvents);
+ }
+
+ private void selectItem() {
+ new GuardRequest(getRequestTypeForMode()) {
+ @Override
+ public void command() {
+ item.select();
+ }
+ }.waitRequest();
+ }
+
+ private RequestType getRequestTypeForMode() {
+ switch (attributes.getMode()) {
+ case ajax:
+ return RequestType.XHR;
+ case server:
+ return RequestType.HTTP;
+ default:
+ return RequestType.NONE;
+ }
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemDOMEventHandlers.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemDOMEventHandlers.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemDOMEventHandlers.java 2011-02-07
14:18:06 UTC (rev 21507)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.richPanelMenuItem;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.dom.Event.*;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.dom.Event;
+import org.richfaces.PanelMenuMode;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.model.PanelMenu;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestPanelMenuItemDOMEventHandlers extends AbstractMetamerTest {
+
+ PanelMenuItemAttributes attributes = new PanelMenuItemAttributes();
+ PanelMenu menu = new PanelMenu(pjq("div.rf-pm[id$=panelMenu]"));
+ PanelMenu.Item item = menu.getGroup(1).getItem(2);
+
+ @Inject
+ @Use("events")
+ Event event;
+ Event[] events = new Event[] { CLICK, DBLCLICK, MOUSEDOWN, MOUSEMOVE, MOUSEOUT,
MOUSEOVER, MOUSEUP };
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richPanelMenuItem/simple.xhtml");
+ }
+
+ @Test
+ public void testDOMEventHandler() {
+ attributes.setMode(PanelMenuMode.client);
+ super.testFireEvent(event, item);
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemMode.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemMode.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemMode.java 2011-02-07
14:18:06 UTC (rev 21507)
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.richPanelMenuItem;
+
+import static javax.faces.event.PhaseId.APPLY_REQUEST_VALUES;
+import static javax.faces.event.PhaseId.INVOKE_APPLICATION;
+import static javax.faces.event.PhaseId.PROCESS_VALIDATIONS;
+import static javax.faces.event.PhaseId.RENDER_RESPONSE;
+import static javax.faces.event.PhaseId.RESTORE_VIEW;
+import static javax.faces.event.PhaseId.UPDATE_MODEL_VALUES;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+import java.util.LinkedList;
+
+import javax.faces.event.PhaseId;
+
+import org.jboss.test.selenium.GuardRequest;
+import org.jboss.test.selenium.request.RequestType;
+import org.richfaces.PanelMenuMode;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.model.PanelMenu;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestPanelMenuItemMode extends AbstractMetamerTest {
+
+ PanelMenuItemAttributes attributes = new PanelMenuItemAttributes();
+ PanelMenu menu = new PanelMenu(pjq("div.rf-pm[id$=panelMenu]"));
+ PanelMenu.Item item = menu.getGroup(1).getItem(2);
+
+ @Inject
+ @Use(booleans = { true, false })
+ Boolean immediate;
+
+ @Inject
+ @Use(booleans = { true, false })
+ Boolean bypassUpdates;
+
+ @Inject
+ @Use(enumeration = true)
+ PanelMenuMode mode = PanelMenuMode.ajax;
+
+ @Inject
+ @Use("listeners")
+ String listener;
+ String[] listeners = new String[] { "phases", "action invoked",
"action listener invoked", "executeChecker",
+ "item changed" };
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richPanelMenuItem/simple.xhtml");
+ }
+
+ @Test
+ public void testMode() {
+ attributes.setImmediate(immediate);
+ attributes.setBypassUpdates(bypassUpdates);
+ attributes.setMode(mode);
+
+ attributes.setExecute("@this executeChecker");
+
+ new GuardRequest(getRequestTypeForMode()) {
+ @Override
+ public void command() {
+ item.select();
+ }
+ }.waitRequest();
+
+ if (mode != PanelMenuMode.client) {
+ if ("phases".equals(listener)) {
+ phaseInfo.assertPhases(getExpectedPhases());
+ } else {
+ phaseInfo.assertListener(getExecutionPhase(), listener);
+ }
+ }
+ }
+
+ private PhaseId[] getExpectedPhases() {
+ LinkedList<PhaseId> list = new LinkedList<PhaseId>();
+ list.add(RESTORE_VIEW);
+ list.add(APPLY_REQUEST_VALUES);
+ if (!immediate) {
+ list.add(PROCESS_VALIDATIONS);
+ }
+ if (!immediate && !bypassUpdates) {
+ list.add(UPDATE_MODEL_VALUES);
+ list.add(INVOKE_APPLICATION);
+ }
+ list.add(RENDER_RESPONSE);
+ return list.toArray(new PhaseId[list.size()]);
+ }
+
+ private PhaseId getExecutionPhase() {
+ PhaseId[] phases = getExpectedPhases();
+ return phases[phases.length - 2];
+ }
+
+ private RequestType getRequestTypeForMode() {
+ switch (mode) {
+ case ajax:
+ return RequestType.XHR;
+ case server:
+ return RequestType.HTTP;
+ default:
+ return RequestType.NONE;
+ }
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemSimple.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPanelMenuItem/TestPanelMenuItemSimple.java 2011-02-07
14:18:06 UTC (rev 21507)
@@ -0,0 +1,194 @@
+package org.richfaces.tests.metamer.ftest.richPanelMenuItem;
+
+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.GuardRequest;
+import org.jboss.test.selenium.request.RequestType;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.model.PanelMenu;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestPanelMenuItemSimple extends AbstractMetamerTest {
+
+ private static String SAMPLE_IMAGE = "/resources/images/loading.gif";
+ private static String CHEVRON_DOWN = "chevronDown";
+ private static String CHEVRON_DOWN_CLASS = "rf-ico-chevron-down";
+
+ PanelMenuItemAttributes attributes = new PanelMenuItemAttributes();
+ PanelMenu menu = new PanelMenu(pjq("div.rf-pm[id$=panelMenu]"));
+ PanelMenu.Item item = menu.getGroup(1).getItemContains("Item 1.2");
+ PanelMenu.Icon leftIcon = item.getLeftIcon();
+ PanelMenu.Icon rightIcon = item.getRightIcon();
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richPanelMenuItem/simple.xhtml");
+ }
+
+ @Test
+ public void testData() {
+ attributes.setData("RichFaces 4");
+ attributes.setOncomplete("data = event.data");
+
+ retrieveRequestTime.initializeValue();
+ item.select();
+ waitGui.waitForChange(retrieveRequestTime);
+
+ assertEquals(retrieveWindowData.retrieve(), "RichFaces 4");
+ }
+
+ @Test
+ public void testDisabled() {
+ assertFalse(item.isDisabled());
+
+ attributes.setDisabled(true);
+
+ assertFalse(item.isSelected());
+ assertTrue(item.isDisabled());
+
+ new GuardRequest(RequestType.NONE) {
+ public void command() {
+ item.select();
+ }
+ }.waitRequest();
+
+ assertFalse(item.isSelected());
+ assertTrue(item.isDisabled());
+ }
+
+ @Test
+ public void testDisabledClass() {
+ attributes.setDisabled(true);
+ super.testStyleClass(item, "disabledClass");
+ }
+
+ @Test
+ public void testLeftDisabledIcon() {
+ attributes.setLeftDisabledIcon(SAMPLE_IMAGE);
+
+ assertTrue(leftIcon.isTransparent());
+ assertFalse(leftIcon.isCustomURL());
+
+ attributes.setDisabled(true);
+
+ assertTrue(leftIcon.isCustomURL());
+ assertTrue(leftIcon.getCustomURL().endsWith(SAMPLE_IMAGE));
+ }
+
+ @Test
+ public void testLeftIcon() {
+ attributes.setLeftIcon(CHEVRON_DOWN);
+
+ assertTrue(leftIcon.containsClass(CHEVRON_DOWN_CLASS));
+
+ attributes.setDisabled(true);
+
+ assertTrue(leftIcon.isTransparent());
+ }
+
+ @Test
+ public void testLeftIconClass() {
+ super.testStyleClass(leftIcon, "leftIconClass");
+ }
+
+ @Test
+ public void testLimitRender() {
+ attributes.setRender("renderChecker");
+ attributes.setLimitRender(true);
+
+ retrieveRequestTime.initializeValue();
+ retrieveRenderChecker.initializeValue();
+ item.select();
+ waitAjax.waitForChange(retrieveRenderChecker);
+ assertFalse(retrieveRequestTime.isValueChanged());
+ }
+
+ @Test
+ public void testRendered() {
+ assertTrue(item.isVisible());
+
+ attributes.setRendered(false);
+
+ assertFalse(item.isVisible());
+ }
+
+ @Test
+ public void testRightDisabledIcon() {
+ attributes.setRightDisabledIcon(SAMPLE_IMAGE);
+
+ assertTrue(rightIcon.isTransparent());
+ assertFalse(rightIcon.isCustomURL());
+
+ attributes.setDisabled(true);
+
+ assertTrue(rightIcon.isCustomURL());
+ assertTrue(rightIcon.getCustomURL().endsWith(SAMPLE_IMAGE));
+ }
+
+ @Test
+ public void testRightIcon() {
+ attributes.setRightIcon(CHEVRON_DOWN);
+
+ assertTrue(rightIcon.containsClass(CHEVRON_DOWN_CLASS));
+
+ attributes.setDisabled(true);
+
+ assertTrue(rightIcon.isTransparent());
+ }
+
+ @Test
+ public void testRightIconClass() {
+ super.testStyleClass(rightIcon, "rightIconClass");
+ }
+
+ @Test
+ public void testSelectable() {
+ attributes.setSelectable(false);
+
+ new GuardRequest(RequestType.NONE) {
+ public void command() {
+ item.select();
+ }
+ }.waitRequest();
+
+ assertFalse(item.isSelected());
+
+ attributes.setSelectable(true);
+
+ new GuardRequest(RequestType.XHR) {
+ public void command() {
+ item.select();
+ }
+ }.waitRequest();
+
+ assertTrue(item.isSelected());
+ }
+
+ @Test
+ public void testStatus() {
+ attributes.setStatus("statusChecker");
+
+ retrieveStatusChecker.initializeValue();
+ item.select();
+ waitAjax.waitForChange(retrieveStatusChecker);
+ }
+
+ @Test
+ public void testStyle() {
+ super.testStyle(item, "style");
+ }
+
+ @Test
+ public void testStyleClass() {
+ super.testStyleClass(item, "styleClass");
+ }
+}