Author: ppitonak(a)redhat.com
Date: 2011-02-16 10:58:24 -0500 (Wed, 16 Feb 2011)
New Revision: 21703
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richSelect/fAjax.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richSelect/TestRichSelectFAjax.java
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richSelect/list.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richSelect/TestRichSelect.java
Log:
added sample and test for rich:select+f:ajax
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richSelect/fAjax.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richSelect/fAjax.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richSelect/fAjax.xhtml 2011-02-16
15:58:24 UTC (rev 21703)
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:metamer="http://java.sun.com/jsf/composite/metamer"
+
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
+
+ <!--
+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.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+ <rich:select id="select"
+
converterMessage="#{richSelectBean.attributes['converterMessage'].value}"
+
defaultLabel="#{richSelectBean.attributes['defaultLabel'].value}"
+
disabled="#{richSelectBean.attributes['disabled'].value}"
+
enableManualInput="#{richSelectBean.attributes['enableManualInput'].value}"
+
immediate="#{richSelectBean.attributes['immediate'].value}"
+
itemClass="#{richSelectBean.attributes['itemClass'].value}"
+
listClass="#{richSelectBean.attributes['listClass'].value}"
+
listHeight="#{richSelectBean.attributes['listHeight'].value}"
+
listWidth="#{richSelectBean.attributes['listWidth'].value}"
+
maxListHeight="#{richSelectBean.attributes['maxListHeight'].value}"
+
minListHeight="#{richSelectBean.attributes['minListHeight'].value}"
+
onblur="#{richSelectBean.attributes['onblur'].value}"
+
onchange="#{richSelectBean.attributes['onchange'].value}"
+
onclick="#{richSelectBean.attributes['onclick'].value}"
+
ondblclick="#{richSelectBean.attributes['ondblclick'].value}"
+
onfocus="#{richSelectBean.attributes['onfocus'].value}"
+
onkeydown="#{richSelectBean.attributes['onkeydown'].value}"
+
onkeypress="#{richSelectBean.attributes['onkeypress'].value}"
+
onkeyup="#{richSelectBean.attributes['onkeyup'].value}"
+
onlistclick="#{richSelectBean.attributes['onlistclick'].value}"
+
onlistdblclick="#{richSelectBean.attributes['onlistdblclick'].value}"
+
onlistkeydown="#{richSelectBean.attributes['onlistkeydown'].value}"
+
onlistkeypress="#{richSelectBean.attributes['onlistkeypress'].value}"
+
onlistkeyup="#{richSelectBean.attributes['onlistkeyup'].value}"
+
onlistmousedown="#{richSelectBean.attributes['onlistmousedown'].value}"
+
onlistmousemove="#{richSelectBean.attributes['onlistmousemove'].value}"
+
onlistmouseout="#{richSelectBean.attributes['onlistmouseout'].value}"
+
onlistmouseover="#{richSelectBean.attributes['onlistmouseover'].value}"
+
onlistmouseup="#{richSelectBean.attributes['onlistmouseup'].value}"
+
onmousedown="#{richSelectBean.attributes['onmousedown'].value}"
+
onmousemove="#{richSelectBean.attributes['onmousemove'].value}"
+
onmouseout="#{richSelectBean.attributes['onmouseout'].value}"
+
onmouseover="#{richSelectBean.attributes['onmouseover'].value}"
+
onmouseup="#{richSelectBean.attributes['onmouseup'].value}"
+
onselectitem="#{richSelectBean.attributes['onselectitem'].value}"
+
rendered="#{richSelectBean.attributes['rendered'].value}"
+
required="#{richSelectBean.attributes['required'].value}"
+
requiredMessage="#{richSelectBean.attributes['requiredMessage'].value}"
+
selectFirst="#{richSelectBean.attributes['selectFirst'].value}"
+
selectItemClass="#{richSelectBean.attributes['selectItemClass'].value}"
+
showButton="#{richSelectBean.attributes['showButton'].value}"
+
validatorMessage="#{richSelectBean.attributes['validatorMessage'].value}"
+
value="#{richSelectBean.attributes['value'].value}"
+ valueChangeListener="#{richSelectBean.listener}"
+ >
+
+ <f:selectItems value="#{richSelectBean.capitalsOptions}"
/>
+ <f:ajax event="change" render="output
:phasesPanel"/>
+
+ </rich:select>
+
+ <br/><br/>
+
+ output: <h:outputText id="output"
value="#{richSelectBean.attributes['value'].value}"/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <metamer:attributes value="#{richSelectBean.attributes}"
id="attributes" />
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richSelect/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richSelect/list.xhtml 2011-02-16
15:57:39 UTC (rev 21702)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richSelect/list.xhtml 2011-02-16
15:58:24 UTC (rev 21703)
@@ -32,9 +32,13 @@
<ui:define name="links">
<metamer:testPageLink id="simple" outcome="simple"
value="Simple">
- Simple page that contains <b>rich:select</b> and input boxes
for all its attributes.
+ Simple page that contains <b>rich:select</b> with a4j:ajax
and input boxes for all its attributes.
</metamer:testPageLink>
+ <metamer:testPageLink id="fAjax" outcome="fAjax"
value="f:ajax">
+ Simple page that contains <b>rich:select</b> with f:ajax and
input boxes for all its attributes.
+ </metamer:testPageLink>
+
</ui:define>
</ui:composition>
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richSelect/TestRichSelect.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richSelect/TestRichSelect.java 2011-02-16
15:57:39 UTC (rev 21702)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richSelect/TestRichSelect.java 2011-02-16
15:58:24 UTC (rev 21703)
@@ -94,6 +94,7 @@
assertTrue(selenium.belongsClass(options.format(10), "rf-sel-sel"));
waitGui.failWith("Bean was not
updated").until(textEquals.locator(output).text("Hawaii"));
+ phaseInfo.assertListener(PhaseId.PROCESS_VALIDATIONS, "value changed: null
-> Hawaii");
}
@Test
@@ -120,6 +121,7 @@
// assertTrue(selenium.belongsClass(options.format(10), "rf-sel-sel"));
//
// waitGui.failWith("Bean was not
updated").until(textEquals.locator(output).text("Hawaii"));
+// phaseInfo.assertListener(PhaseId.PROCESS_VALIDATIONS, "value changed: null
-> Hawaii");
}
@Test
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richSelect/TestRichSelectFAjax.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richSelect/TestRichSelectFAjax.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richSelect/TestRichSelectFAjax.java 2011-02-16
15:58:24 UTC (rev 21703)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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.richSelect;
+
+import static
org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardNoRequest;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+import javax.faces.event.PhaseId;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page faces/components/richSelect/fAjax.xhtml.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestRichSelectFAjax extends AbstractMetamerTest {
+
+ private JQueryLocator input = pjq("input.rf-sel-inp[id$=selectInput]");
+ private JQueryLocator popup = jq("div.rf-sel-lst-cord");
+ private JQueryLocator options = jq("div.rf-sel-opt:eq({0})"); // 00..49
+ private JQueryLocator button = pjq("span.rf-sel-btn");
+ private JQueryLocator output = pjq("span[id$=output]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richSelect/fAjax.xhtml");
+ }
+
+ @Test
+ public void testSelectWithMouse() {
+ guardNoRequest(selenium).mouseDown(button);
+ selenium.mouseUp(button);
+ assertTrue(selenium.isVisible(popup), "Popup should be displayed.");
+
+ for (int i = 0; i < 50; i++) {
+ assertTrue(selenium.isDisplayed(options.format(i)), "Select option
" + i + " should be displayed.");
+ }
+
+ String[] selectOptions = {"Alabama", "Hawaii",
"Massachusetts", "New Mexico", "South Dakota"};
+ for (int i = 0; i < 50; i += 10) {
+ assertEquals(selenium.getText(options.format(i)), selectOptions[i / 10],
"Select option nr. " + i);
+ }
+
+ guardNoRequest(selenium).click(options.format(10));
+ guardXhr(selenium).fireEvent(input, Event.BLUR);
+ assertTrue(selenium.belongsClass(options.format(10), "rf-sel-sel"));
+
+ waitGui.failWith("Bean was not
updated").until(textEquals.locator(output).text("Hawaii"));
+ phaseInfo.assertListener(PhaseId.PROCESS_VALIDATIONS, "value changed: null
-> Hawaii");
+ }
+}