Author: ppitonak(a)redhat.com
Date: 2011-02-16 10:57:39 -0500 (Wed, 16 Feb 2011)
New Revision: 21702
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/fAjax.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelectFAjax.java
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/list.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java
Log:
added sample + test for rich:inplaceSelect+f:ajax
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/fAjax.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/fAjax.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/fAjax.xhtml 2011-02-16
15:57:39 UTC (rev 21702)
@@ -0,0 +1,124 @@
+<?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" >
+
+ <!--
+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:inplaceSelect id="inplaceSelect"
+
changedStateClass="#{richInplaceSelectBean.attributes['changedStateClass'].value}"
+
converterMessage="#{richInplaceSelectBean.attributes['converterMessage'].value}"
+
defaultLabel="#{richInplaceSelectBean.attributes['defaultLabel'].value}"
+
disabled="#{richInplaceSelectBean.attributes['disabled'].value}"
+
disabledStateClass="#{richInplaceSelectBean.attributes['disabledStateClass'].value}"
+
editEvent="#{richInplaceSelectBean.attributes['editEvent'].value}"
+
editStateClass="#{richInplaceSelectBean.attributes['editStateClass'].value}"
+
immediate="#{richInplaceSelectBean.attributes['immediate'].value}"
+
inputWidth="#{richInplaceSelectBean.attributes['inputWidth'].value}"
+
itemClass="#{richInplaceSelectBean.attributes['itemClass'].value}"
+
listClass="#{richInplaceSelectBean.attributes['listClass'].value}"
+
listHeight="#{richInplaceSelectBean.attributes['listHeight'].value}"
+
listWidth="#{richInplaceSelectBean.attributes['listWidth'].value}"
+
onblur="#{richInplaceSelectBean.attributes['onblur'].value}"
+
onchange="#{richInplaceSelectBean.attributes['onchange'].value}"
+
onclick="#{richInplaceSelectBean.attributes['onclick'].value}"
+
ondblclick="#{richInplaceSelectBean.attributes['ondblclick'].value}"
+
onfocus="#{richInplaceSelectBean.attributes['onfocus'].value}"
+
oninputclick="#{richInplaceSelectBean.attributes['oninputclick'].value}"
+
oninputdblclick="#{richInplaceSelectBean.attributes['oninputdblclick'].value}"
+
oninputkeydown="#{richInplaceSelectBean.attributes['oninputkeydown'].value}"
+
oninputkeypress="#{richInplaceSelectBean.attributes['oninputkeypress'].value}"
+
oninputkeyup="#{richInplaceSelectBean.attributes['oninputkeyup'].value}"
+
oninputmousedown="#{richInplaceSelectBean.attributes['oninputmousedown'].value}"
+
oninputmousemove="#{richInplaceSelectBean.attributes['oninputmousemove'].value}"
+
oninputmouseout="#{richInplaceSelectBean.attributes['oninputmouseout'].value}"
+
oninputmouseover="#{richInplaceSelectBean.attributes['oninputmouseover'].value}"
+
oninputmouseup="#{richInplaceSelectBean.attributes['oninputmouseup'].value}"
+
oninputselect="#{richInplaceSelectBean.attributes['oninputselect'].value}"
+
onkeydown="#{richInplaceSelectBean.attributes['onkeydown'].value}"
+
onkeypress="#{richInplaceSelectBean.attributes['onkeypress'].value}"
+
onkeyup="#{richInplaceSelectBean.attributes['onkeyup'].value}"
+
onlistclick="#{richInplaceSelectBean.attributes['onlistclick'].value}"
+
onlistdblclick="#{richInplaceSelectBean.attributes['onlistdblclick'].value}"
+
onlistkeydown="#{richInplaceSelectBean.attributes['onlistkeydown'].value}"
+
onlistkeypress="#{richInplaceSelectBean.attributes['onlistkeypress'].value}"
+
onlistkeyup="#{richInplaceSelectBean.attributes['onlistkeyup'].value}"
+
onlistmousedown="#{richInplaceSelectBean.attributes['onlistmousedown'].value}"
+
onlistmousemove="#{richInplaceSelectBean.attributes['onlistmousemove'].value}"
+
onlistmouseout="#{richInplaceSelectBean.attributes['onlistmouseout'].value}"
+
onlistmouseover="#{richInplaceSelectBean.attributes['onlistmouseover'].value}"
+
onlistmouseup="#{richInplaceSelectBean.attributes['onlistmouseup'].value}"
+
onmousedown="#{richInplaceSelectBean.attributes['onmousedown'].value}"
+
onmousemove="#{richInplaceSelectBean.attributes['onmousemove'].value}"
+
onmouseout="#{richInplaceSelectBean.attributes['onmouseout'].value}"
+
onmouseover="#{richInplaceSelectBean.attributes['onmouseover'].value}"
+
onmouseup="#{richInplaceSelectBean.attributes['onmouseup'].value}"
+
onselectitem="#{richInplaceSelectBean.attributes['onselectitem'].value}"
+
openOnEdit="#{richInplaceSelectBean.attributes['openOnEdit'].value}"
+
readyStateClass="#{richInplaceSelectBean.attributes['readyStateClass'].value}"
+
rendered="#{richInplaceSelectBean.attributes['rendered'].value}"
+
required="#{richInplaceSelectBean.attributes['required'].value}"
+
requiredMessage="#{richInplaceSelectBean.attributes['requiredMessage'].value}"
+
saveOnBlur="#{richInplaceSelectBean.attributes['saveOnBlur'].value}"
+
saveOnSelect="#{richInplaceSelectBean.attributes['saveOnSelect'].value}"
+
selectItemClass="#{richInplaceSelectBean.attributes['selectItemClass'].value}"
+
showControls="#{richInplaceSelectBean.attributes['showControls'].value}"
+
style="#{richInplaceSelectBean.attributes['style'].value}"
+
tabindex="#{richInplaceSelectBean.attributes['tabindex'].value}"
+
validatorMessage="#{richInplaceSelectBean.attributes['validatorMessage'].value}"
+
value="#{richInplaceSelectBean.attributes['value'].value}"
+
valueChangeListener="#{richInplaceSelectBean.listener}"
+ >
+
+ <f:selectItems
value="#{richInplaceSelectBean.capitalsOptions}" />
+
+ <f:ajax event="change" render="output
:phasesPanel"/>
+
+ </rich:inplaceSelect>
+
+ <br/><br/>
+
+ output: <h:outputText id="output"
value="#{richInplaceSelectBean.attributes['value'].value}"/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <metamer:attributes value="#{richInplaceSelectBean.attributes}"
id="attributes" />
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/list.xhtml 2011-02-16
15:56:50 UTC (rev 21701)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/list.xhtml 2011-02-16
15:57:39 UTC (rev 21702)
@@ -32,9 +32,13 @@
<ui:define name="links">
<metamer:testPageLink id="simple" outcome="simple"
value="Simple">
- Simple page that contains <b>rich:inplaceSelect</b> and input
boxes for all its attributes.
+ Simple page that contains <b>rich:inplaceSelect</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:inplaceSelect</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/richInplaceSelect/TestRichInplaceSelect.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java 2011-02-16
15:56:50 UTC (rev 21701)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java 2011-02-16
15:57:39 UTC (rev 21702)
@@ -100,8 +100,7 @@
assertEquals(selenium.getText(label), "Hawaii", "Label should
contain selected value.");
- String listenerText = selenium.getText(jq("div#phasesPanel
li:eq(3)"));
- assertEquals(listenerText, "* value changed: null -> Hawaii",
"Value change listener was not invoked.");
+ 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/richInplaceSelect/TestRichInplaceSelectFAjax.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelectFAjax.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelectFAjax.java 2011-02-16
15:57:39 UTC (rev 21702)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * 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.richInplaceSelect;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+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.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 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.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page faces/components/richInplaceSelect/fAjax.xhtml.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestRichInplaceSelectFAjax extends AbstractMetamerTest {
+
+ private JQueryLocator select = pjq("span[id$=inplaceSelect]");
+ private JQueryLocator label = pjq("span.rf-is-lbl");
+ private JQueryLocator input = pjq("input[id$=inplaceSelectInput]");
+ private JQueryLocator popup = pjq("span.rf-is-lst-cord");
+ private JQueryLocator edit = pjq("span.rf-is-edit");
+ private JQueryLocator options = jq("span.rf-is-opt:eq({0})"); // 00..49
+ private JQueryLocator output = pjq("span[id$=output]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richInplaceSelect/fAjax.xhtml");
+ }
+
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10538")
+ public void testClick() {
+ guardNoRequest(selenium).click(select);
+ assertFalse(selenium.belongsClass(edit, "rf-is-none"), "Edit
should not contain class rf-is-none when popup is open.");
+ assertTrue(selenium.isDisplayed(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);
+ }
+
+ selenium.click(options.format(10));
+ guardXhr(selenium).fireEvent(input, Event.BLUR);
+ waitGui.failWith("Output did not
change.").until(textEquals.locator(output).text("Hawaii"));
+
+ assertTrue(selenium.belongsClass(select, "rf-is-c-s"), "New class
should be added to inplace select.");
+ assertTrue(selenium.belongsClass(edit, "rf-is-none"), "Edit should
contain class rf-is-none when popup is closed.");
+
+ assertEquals(selenium.getText(label), "Hawaii", "Label should
contain selected value.");
+
+ phaseInfo.assertListener(PhaseId.PROCESS_VALIDATIONS, "value changed: null
-> Hawaii");
+ }
+}