From richfaces-svn-commits at lists.jboss.org Mon Nov 22 08:30:35 2010 Content-Type: multipart/mixed; boundary="===============2706729752266372314==" MIME-Version: 1.0 From: richfaces-svn-commits at lists.jboss.org To: richfaces-svn-commits at lists.jboss.org Subject: [richfaces-svn-commits] JBoss Rich Faces SVN: r20132 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: richInplaceSelect and 1 other directory. Date: Mon, 22 Nov 2010 08:30:35 -0500 Message-ID: <201011221330.oAMDUZNA009429@svn01.web.mwc.hst.phx2.redhat.com> --===============2706729752266372314== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: ppitonak(a)redhat.com Date: 2010-11-22 08:30:34 -0500 (Mon, 22 Nov 2010) New Revision: 20132 Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richInplaceSelect/ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java Log: https://jira.jboss.org/browse/RF-9037 * 54 tests for rich:inplaceSelect added Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces= /tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java = (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java 2010-11-22 1= 3:30:34 UTC (rev 20132) @@ -0,0 +1,514 @@ +/*************************************************************************= ****** + * 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.richInplaceSelect; + +import static org.jboss.test.selenium.locator.LocatorFactory.jq; +import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactor= y.guardNoRequest; +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.css.CssProperty; + +import org.jboss.test.selenium.dom.Event; +import org.jboss.test.selenium.locator.JQueryLocator; +import org.jboss.test.selenium.waiting.EventFiredCondition; +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/simple.xhtml. + * = + * @author Pavol Pitonak + * @version $Revision$ + */ +public class TestRichInplaceSelect extends AbstractMetamerTest { + + private JQueryLocator select =3D pjq("span[id$=3DinplaceSelect]"); + private JQueryLocator label =3D pjq("span.rf-is-lbl"); + private JQueryLocator input =3D pjq("input[id$=3DinplaceSelectInput]"); + private JQueryLocator popup =3D pjq("span.rf-is-lst-cord"); + private JQueryLocator edit =3D pjq("span.rf-is-edit"); + private JQueryLocator options =3D jq("span.rf-is-opt:eq({0})"); // 00.= .49 + private JQueryLocator okButton =3D jq("input.rf-is-btn[id$=3DOkbtn]"); + private JQueryLocator cancelButton =3D jq("input.rf-is-btn[id$=3DCance= lbtn]"); + + @Override + public URL getTestUrl() { + return buildUrl(contextPath, "faces/components/richInplaceSelect/s= imple.xhtml"); + } + + @Test + public void testInit() { + assertTrue(selenium.isElementPresent(select), "Inplace select is n= ot on the page."); + assertTrue(selenium.isElementPresent(label), "Default label should= be present on the page."); + assertEquals(selenium.getText(label), "Click here to edit", "Defau= lt label"); + assertTrue(selenium.isElementPresent(input), "Input should be pres= ent on the page."); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed on the page."); + } + + @Test + @IssueTracking("https://jira.jboss.org/browse/RF-9664") + public void testClick() { + guardNoRequest(selenium).click(select); + assertFalse(selenium.belongsClass(edit, "rf-is-none"), "Edit shoul= d not contain class rf-is-none when popup is open."); + assertTrue(selenium.isDisplayed(popup), "Popup should be displayed= ."); + + for (int i =3D 0; i < 50; i++) { + assertTrue(selenium.isDisplayed(options.format(i)), "Select op= tion " + i + " should be displayed."); + } + + String[] selectOptions =3D {"Alabama", "Hawaii", "Massachusetts", = "New Mexico", "South Dakota"}; + for (int i =3D 0; i < 50; i +=3D 10) { + assertEquals(selenium.getText(options.format(i)), selectOption= s[i / 10], "Select option nr. " + i); + } + + guardNoRequest(selenium).click(options.format(10)); + 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 cont= ain selected value."); + } + + @Test + public void testDefaultLabel() { + selenium.type(pjq("input[type=3Dtext][id$=3DdefaultLabelInput]"), = "new label"); + selenium.waitForPageToLoad(); + assertEquals(selenium.getText(label), "new label", "Default label = should change"); + + selenium.type(pjq("input[type=3Dtext][id$=3DdefaultLabelInput]"), = ""); + selenium.waitForPageToLoad(); + assertEquals(selenium.getText(label), "", "Default label should ch= ange"); + + assertTrue(selenium.isElementPresent(select), "Inplace select is n= ot on the page."); + assertTrue(selenium.isElementPresent(label), "Default label should= be present on the page."); + assertTrue(selenium.isElementPresent(input), "Input should be pres= ent on the page."); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed on the page."); + } + + @Test + @IssueTracking("https://jira.jboss.org/browse/RF-9844") + public void testEditEvent() { + selenium.type(pjq("input[type=3Dtext][id$=3DeditEventInput]"), "mo= useup"); + selenium.waitForPageToLoad(); + + selenium.mouseDown(select); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed."); + selenium.mouseUp(select); + assertTrue(selenium.isDisplayed(popup), "Popup should be displayed= ."); + + selenium.type(pjq("input[type=3Dtext][id$=3DeditEventInput]"), "no= nexistingevent"); + selenium.waitForPageToLoad(); + + selenium.click(select); + assertTrue(selenium.isDisplayed(popup), "Popup should be displayed= ."); + } + + @Test + public void testItemClass() { + final String value =3D "metamer-ftest-class"; + selenium.type(pjq("input[type=3Dtext][id$=3DitemClassInput]"), val= ue); + selenium.waitForPageToLoad(); + + for (int i =3D 0; i < 50; i++) { + assertTrue(selenium.belongsClass(options.format(i), value), "S= elect option " + + selenium.getText(options.format(i)) + " does not con= tain class " + value); + } + } + + @Test + @IssueTracking("https://jira.jboss.org/browse/RF-9845") + public void testListClass() { + testStyleClass(popup, "listClass"); + } + + @Test + @IssueTracking("https://jira.jboss.org/browse/RF-9647") + public void testListHeight() { + selenium.type(pjq("input[type=3Dtext][id$=3DlistHeightInput]"), "3= 00px"); + selenium.waitForPageToLoad(); + + String height =3D selenium.getStyle(jq("span.rf-is-lst-scrl"), Css= Property.HEIGHT); + assertEquals(height, "300px", "Height of list did not change"); + + selenium.type(pjq("input[type=3Dtext][id$=3DlistHeightInput]"), ""= ); + selenium.waitForPageToLoad(); + + // it cannot handle null because of a bug in Mojarra and Myfaces a= nd + // generates style=3D"height: ; " instead of default value + height =3D selenium.getStyle(jq("span.rf-is-lst-scrl"), CssPropert= y.HEIGHT); + assertEquals(height, "200px", "Height of list did not change"); + } + + @Test + @IssueTracking("https://jira.jboss.org/browse/RF-9647") + public void testListWidth() { + selenium.type(pjq("input[type=3Dtext][id$=3DlistWidthInput]"), "30= 0px"); + selenium.waitForPageToLoad(); + + String width =3D selenium.getStyle(jq("span.rf-is-lst-pos"), CssPr= operty.WIDTH); + assertEquals(width, "300px", "Width of list did not change"); + + selenium.type(pjq("input[type=3Dtext][id$=3DlistWidthInput]"), ""); + selenium.waitForPageToLoad(); + + // it cannot handle null because of a bug in Mojarra and Myfaces a= nd + // generates style=3D"width: ; " instead of default value + width =3D selenium.getStyle(jq("span.rf-is-lst-pos"), CssProperty.= WIDTH); + assertEquals(width, "200px", "Width of list did not change"); + } + + @Test + @IssueTracking("https://jira.jboss.org/browse/RF-9849") + public void testOnblur() { + testFireEvent(Event.BLUR, select); + } + + @Test + @IssueTracking("https://jira.jboss.org/browse/RF-9571") + public void testOnchange() { + selenium.type(pjq("input[type=3Dtext][id$=3DonchangeInput]"), "met= amerEvents +=3D \"change \""); + selenium.waitForPageToLoad(); + + selenium.click(select); + selenium.click(options.format(10)); + + waitGui.failWith("Attribute onchange does not work correctly").unt= il( + new EventFiredCondition(Event.CHANGE)); + } + + @Test + public void testOnclick() { + testFireEvent(Event.CLICK, select); + } + + @Test + public void testOndblclick() { + testFireEvent(Event.DBLCLICK, select); + } + + @Test + @IssueTracking("https://jira.jboss.org/browse/RF-9849") + public void testOnfocus() { + testFireEvent(Event.FOCUS, select); + } + + @Test + public void testOninputblur() { + testFireEvent(Event.BLUR, input, "inputblur"); + } + + @Test + public void testOninputclick() { + testFireEvent(Event.CLICK, input, "inputclick"); + } + + @Test + public void testOninputdblclick() { + testFireEvent(Event.DBLCLICK, input, "inputdblclick"); + } + + @Test + public void testOninputfocus() { + testFireEvent(Event.FOCUS, input, "inputfocus"); + } + + @Test + public void testOninputkeydown() { + testFireEvent(Event.KEYDOWN, input, "inputkeydown"); + } + + @Test + public void testOninputkeypress() { + testFireEvent(Event.KEYPRESS, input, "inputkeypress"); + } + + @Test + public void testOninputkeyup() { + testFireEvent(Event.KEYUP, input, "inputkeyup"); + } + + @Test + public void testOninputmousedown() { + testFireEvent(Event.MOUSEDOWN, input, "inputmousedown"); + } + + @Test + public void testOninputmousemove() { + testFireEvent(Event.MOUSEMOVE, input, "inputmousemove"); + } + + @Test + public void testOninputmouseout() { + testFireEvent(Event.MOUSEOUT, input, "inputmouseout"); + } + + @Test + public void testOninputmouseover() { + testFireEvent(Event.MOUSEOVER, input, "inputmouseover"); + } + + @Test + public void testOninputmouseup() { + testFireEvent(Event.MOUSEUP, input, "inputmouseup"); + } + + @Test + public void testOninputselect() { + testFireEvent(Event.SELECT, input, "inputselect"); + } + + @Test + public void testOnkeydown() { + testFireEvent(Event.KEYDOWN, select); + } + + @Test + public void testOnkeypress() { + testFireEvent(Event.KEYPRESS, select); + } + + @Test + public void testOnkeyup() { + testFireEvent(Event.KEYUP, select); + } + + @Test + public void testOnlistclick() { + testFireEvent(Event.CLICK, popup, "listclick"); + } + + @Test + public void testOnlistdblclick() { + testFireEvent(Event.DBLCLICK, popup, "listdblclick"); + } + + @Test + public void testOnlistkeydown() { + testFireEvent(Event.KEYDOWN, popup, "listkeydown"); + } + + @Test + public void testOnlistkeypress() { + testFireEvent(Event.KEYPRESS, popup, "listkeypress"); + } + + @Test + public void testOnlistkeyup() { + testFireEvent(Event.KEYUP, popup, "listkeyup"); + } + + @Test + public void testOnlistmousedown() { + testFireEvent(Event.MOUSEDOWN, popup, "listmousedown"); + } + + @Test + public void testOnlistmousemove() { + testFireEvent(Event.MOUSEMOVE, popup, "listmousemove"); + } + + @Test + public void testOnlistmouseout() { + testFireEvent(Event.MOUSEOUT, popup, "listmouseout"); + } + + @Test + public void testOnlistmouseover() { + testFireEvent(Event.MOUSEOVER, popup, "listmouseover"); + } + + @Test + public void testOnlistmouseup() { + testFireEvent(Event.MOUSEUP, popup, "listmouseup"); + } + + @Test + public void testOnmousedown() { + testFireEvent(Event.MOUSEDOWN, select); + } + + @Test + public void testOnmousemove() { + testFireEvent(Event.MOUSEMOVE, select); + } + + @Test + public void testOnmouseout() { + testFireEvent(Event.MOUSEOUT, select); + } + + @Test + public void testOnmouseover() { + testFireEvent(Event.MOUSEOVER, select); + } + + @Test + public void testOnmouseup() { + testFireEvent(Event.MOUSEUP, select); + } + + @Test + @IssueTracking("https://jira.jboss.org/browse/RF-9849") + public void testOnselect() { + testFireEvent(Event.SELECT, input); + } + + @Test + public void testOpenOnEdit() { + selenium.click(pjq("input[type=3Dradio][name$=3DopenOnEditInput][v= alue=3Dfalse]")); + selenium.waitForPageToLoad(); + + selenium.click(select); + assertFalse(selenium.belongsClass(edit, "rf-is-none"), "Edit shoul= d not contain class rf-is-none when popup is open."); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed."); + + selenium.click(input); + assertTrue(selenium.isDisplayed(popup), "Popup should be displayed= ."); + } + + @Test + public void testRendered() { + selenium.click(pjq("input[type=3Dradio][name$=3DrenderedInput][val= ue=3Dfalse]")); + selenium.waitForPageToLoad(); + + assertFalse(selenium.isElementPresent(select), "Panel should not b= e rendered when rendered=3Dfalse."); + } + + @Test + public void testSaveOnBlurSelectTrueTrue() { + selenium.click(pjq("input[type=3Dradio][name$=3DsaveOnBlurInput][v= alue=3Dtrue]")); + selenium.waitForPageToLoad(); + + selenium.click(select); + assertTrue(selenium.isDisplayed(popup), "Popup should be displayed= ."); + + selenium.click(options.format(10)); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed."); + assertEquals(selenium.getText(label), "Hawaii", "Label should cont= ain selected value."); + } + + @Test + public void testSaveOnBlurSelectTrueFalse() { + selenium.click(pjq("input[type=3Dradio][name$=3DsaveOnBlurInput][v= alue=3Dtrue]")); + selenium.waitForPageToLoad(); + selenium.click(pjq("input[type=3Dradio][name$=3DsaveOnSelectInput]= [value=3Dfalse]")); + selenium.waitForPageToLoad(); + + selenium.click(select); + assertTrue(selenium.isDisplayed(popup), "Popup should be displayed= ."); + + selenium.click(options.format(10)); + assertEquals(selenium.getText(label), "Click here to edit", "Label= should contain default value."); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed."); + + selenium.fireEvent(input, Event.BLUR); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed."); + assertEquals(selenium.getValue(input), "Hawaii", "Input should con= tain selected value."); + waitGui.failWith("Label should contain selected value.").until(tex= tEquals.locator(label).text("Hawaii")); + } + + @Test + public void testSaveOnBlurSelectFalseTrue() { + selenium.click(pjq("input[type=3Dradio][name$=3DsaveOnBlurInput][v= alue=3Dfalse]")); + selenium.waitForPageToLoad(); + + selenium.click(select); + assertTrue(selenium.isDisplayed(popup), "Popup should be displayed= ."); + + selenium.click(options.format(10)); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed."); + assertEquals(selenium.getText(label), "Hawaii", "Label should cont= ain selected value."); + } + + @Test + public void testSaveOnBlurSelectFalseFalse() { + selenium.click(pjq("input[type=3Dradio][name$=3DsaveOnBlurInput][v= alue=3Dfalse]")); + selenium.waitForPageToLoad(); + selenium.click(pjq("input[type=3Dradio][name$=3DsaveOnSelectInput]= [value=3Dfalse]")); + selenium.waitForPageToLoad(); + + selenium.click(select); + assertTrue(selenium.isDisplayed(popup), "Popup should be displayed= ."); + + selenium.click(options.format(10)); + assertEquals(selenium.getText(label), "Click here to edit", "Label= should contain default value."); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed."); + + selenium.fireEvent(input, Event.BLUR); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed."); + assertEquals(selenium.getText(label), "Click here to edit", "Label= should contain default value."); + } + + @Test + public void testShowControls() { + selenium.click(pjq("input[type=3Dradio][name$=3DshowControlsInput]= [value=3Dtrue]")); + selenium.waitForPageToLoad(); + + selenium.click(select); + assertTrue(selenium.isVisible(okButton), "OK button should be visi= ble."); + assertTrue(selenium.isVisible(cancelButton), "Cancel button should= be visible."); + assertTrue(selenium.isDisplayed(popup), "Popup should be displayed= ."); + } + + @Test + public void testClickOkButton() { + selenium.click(pjq("input[type=3Dradio][name$=3DshowControlsInput]= [value=3Dtrue]")); + selenium.waitForPageToLoad(); + selenium.click(pjq("input[type=3Dradio][name$=3DsaveOnSelectInput]= [value=3Dfalse]")); + selenium.waitForPageToLoad(); + + selenium.click(select); + selenium.click(options.format(10)); + assertEquals(selenium.getText(label), "Click here to edit", "Label= should contain default value."); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed."); + + selenium.mouseDown(okButton); + + if (selenium.isElementPresent(popup)) { + assertFalse(selenium.isDisplayed(popup), "Popup should not be = displayed."); + } + waitGui.failWith("Label should contain selected value.").until(tex= tEquals.locator(label).text("Hawaii")); + } + + @Test + public void testClickCancelButton() { + selenium.click(pjq("input[type=3Dradio][name$=3DshowControlsInput]= [value=3Dtrue]")); + selenium.waitForPageToLoad(); + selenium.click(pjq("input[type=3Dradio][name$=3DsaveOnSelectInput]= [value=3Dfalse]")); + selenium.waitForPageToLoad(); + + selenium.click(select); + selenium.click(options.format(10)); + assertEquals(selenium.getText(label), "Click here to edit", "Label= should contain default value."); + assertFalse(selenium.isDisplayed(popup), "Popup should not be disp= layed."); + + selenium.click(cancelButton); + if (selenium.isElementPresent(popup)) { + assertFalse(selenium.isDisplayed(popup), "Popup should not be = displayed."); + } + assertEquals(selenium.getText(label), "Click here to edit", "Label= should contain default value."); + } +} Property changes on: modules/tests/metamer/trunk/ftest-source/src/main/java= /org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.= java ___________________________________________________________________ Name: svn:keywords + Revision --===============2706729752266372314==--