From richfaces-svn-commits at lists.jboss.org Thu Jan 13 09:39:08 2011 Content-Type: multipart/mixed; boundary="===============6798450640546526972==" 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: r20984 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: richColumn and 1 other directory. Date: Thu, 13 Jan 2011 09:39:08 -0500 Message-ID: <201101131439.p0DEd8Dv005782@svn01.web.mwc.hst.phx2.redhat.com> --===============6798450640546526972== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: lfryc(a)redhat.com Date: 2011-01-13 09:39:07 -0500 (Thu, 13 Jan 2011) New Revision: 20984 Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richColumn/ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richColumn/ColumnAttributes.java modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/richColumn/TestColumnSimple.java Log: rich:column - simple sample automated (RFPL-729) Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces= /tests/metamer/ftest/richColumn/ColumnAttributes.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/richColumn/ColumnAttributes.java = (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richColumn/ColumnAttributes.java 2011-01-13 14:39:07 UTC = (rev 20984) @@ -0,0 +1,51 @@ +/*************************************************************************= ****** + * 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.richColumn; + +import org.richfaces.component.SortOrder; +import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes; + +/** + * @author Lukas Fryc + * @version $Revision$ + */ +public class ColumnAttributes extends AbstractComponentAttributes { + public void setBreakRowBefore(Boolean breakRowBefore) { + setProperty("breakRowBefore", breakRowBefore); + } + + public void setColspan(Integer colspan) { + setProperty("colspan", colspan); + } + + public void setRendered(Boolean rendered) { + setProperty("rendered", rendered); + } + + public void setRowspan(Integer rowspan) { + setProperty("rowspan", rowspan); + } + + public void setSortOrder(SortOrder sortOrder) { + setProperty("sortOrder", sortOrder); + } +} Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces= /tests/metamer/ftest/richColumn/TestColumnSimple.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/richColumn/TestColumnSimple.java = (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/richColumn/TestColumnSimple.java 2011-01-13 14:39:07 UTC = (rev 20984) @@ -0,0 +1,147 @@ +/*************************************************************************= ****** + * 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.richColumn; + +import static org.jboss.test.selenium.locator.Attribute.COLSPAN; +import static org.jboss.test.selenium.locator.Attribute.ROWSPAN; +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 java.net.URL; + +import org.jboss.test.selenium.locator.JQueryLocator; +import org.richfaces.tests.metamer.ftest.AbstractMetamerTest; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * @author Lukas Fryc + * @version $Revision$ + */ +public class TestColumnSimple extends AbstractMetamerTest { + + ColumnAttributes attributes =3D new ColumnAttributes(); + + JQueryLocator table =3D pjq("table.rf-dt[id$=3DrichDataTable]"); + JQueryLocator header =3D table.getChild(jq("thead.rf-dt-thd")); + + JQueryLocator headerRow =3D header.getChild(jq("tr.rf-dt-hdr")); + JQueryLocator headerCell =3D jq("th.rf-dt-hdr-c"); + + JQueryLocator bodyRow =3D table.getChild(jq("tbody.rf-dt-b")).getChild= (jq("tr.rf-dt-r")); + JQueryLocator bodyCell =3D jq("td.rf-dt-c"); + + @Override + public URL getTestUrl() { + return buildUrl(contextPath, "faces/components/richColumn/simple.x= html"); + } + + @BeforeMethod + public void checkInitialState() { + assertEquals(headerCount(1), 1); + assertEquals(headerCount(2), 2); + assertEquals(headerCount(3), 1); + assertEquals(headerCount(4), 1); + assertEquals(bodyCount(1), 2); + + assertEquals(selenium.getAttribute(headerCell(1, 1).getAttribute(C= OLSPAN)), "2"); + assertEquals(selenium.getAttribute(headerCell(2, 2).getAttribute(R= OWSPAN)), "2"); + } + + @Test + public void testBreakRowBefore() { + attributes.setBreakRowBefore(false); + + assertEquals(headerCount(1), 3); + assertEquals(headerCount(2), 1); + assertEquals(headerCount(3), 1); + + assertEquals(selenium.getAttribute(headerCell(1, 1).getAttribute(C= OLSPAN)), "2"); + assertEquals(selenium.getAttribute(headerCell(1, 3).getAttribute(R= OWSPAN)), "2"); + } + + @Test + public void testColspan() { + attributes.setColspan(1); + + assertEquals(headerCount(1), 1); + assertEquals(headerCount(2), 2); + assertEquals(headerCount(3), 1); + assertEquals(headerCount(4), 1); + + assertEquals(selenium.getAttribute(headerCell(1, 1).getAttribute(C= OLSPAN)), "1"); + assertEquals(selenium.getAttribute(headerCell(2, 2).getAttribute(R= OWSPAN)), "2"); + } + + @Test + public void testRowspanTo1() { + attributes.setRowspan(1); + + assertEquals(headerCount(1), 1); + assertEquals(headerCount(2), 2); + assertEquals(headerCount(3), 2); + + assertEquals(selenium.getAttribute(headerCell(1, 1).getAttribute(C= OLSPAN)), "2"); + assertEquals(selenium.getAttribute(headerCell(2, 2).getAttribute(R= OWSPAN)), "1"); + } + + @Test + public void testRowspanTo3() { + attributes.setRowspan(3); + + assertEquals(headerCount(1), 1); + assertEquals(headerCount(2), 2); + assertEquals(headerCount(3), 1); + assertEquals(headerCount(4), 1); + + assertEquals(selenium.getAttribute(headerCell(1, 1).getAttribute(C= OLSPAN)), "2"); + assertEquals(selenium.getAttribute(headerCell(2, 2).getAttribute(R= OWSPAN)), "3"); + } + + @Test + public void testRendered() { + attributes.setRendered(false); + + assertEquals(headerCount(1), 1); + assertEquals(headerCount(2), 2); + assertEquals(headerCount(3), 1); + assertEquals(headerCount(4), 1); + assertEquals(bodyCount(1), 1); + + assertEquals(selenium.getAttribute(headerCell(1, 1).getAttribute(C= OLSPAN)), "2"); + assertEquals(selenium.getAttribute(headerCell(2, 2).getAttribute(R= OWSPAN)), "2"); + } + + public JQueryLocator headerCell(int iRow, int iColumn) { + return headerRow.getNthChildElement(iRow).getChild(headerCell).get= NthChildElement(iColumn); + } + + public int headerCount(int iRow) { + return selenium.getCount(headerRow.getNthChildElement(iRow).getChi= ld(headerCell)); + } + + public int bodyCount(int iRow) { + return selenium.getCount(bodyRow.getNthChildElement(iRow).getChild= (bodyCell)); + } + +} --===============6798450640546526972==--