Author: ppitonak(a)redhat.com
Date: 2011-01-07 05:45:36 -0500 (Fri, 07 Jan 2011)
New Revision: 20914
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richFunctions/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richFunctions/TestClientFunctions.java
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/all.xhtml
Log:
https://issues.jboss.org/browse/RFPL-718
* added two tests for client functions
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/all.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/all.xhtml 2011-01-06
17:50:51 UTC (rev 20913)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/all.xhtml 2011-01-07
10:45:36 UTC (rev 20914)
@@ -50,16 +50,16 @@
<h:panelGrid columns="2">
rich:clientId('input')
- <h:outputText value="#{rich:clientId('input')}"
style="font-weight: bold;" />
+ <h:outputText id="clientIdOutput"
value="#{rich:clientId('input')}" style="font-weight: bold;"
/>
rich:element('input')
- <h:outputText value="#{rich:element('input')}"
style="font-weight: bold;" />
+ <h:outputText id="elementOutput"
value="#{rich:element('input')}" style="font-weight: bold;"
/>
rich:component('input')
- <h:outputText value="#{rich:component('input')}"
style="font-weight: bold;" />
+ <h:outputText id="componentOutput"
value="#{rich:component('input')}" style="font-weight: bold;"
/>
rich:findComponent('input').value
- <h:outputText
value="#{rich:findComponent('input').value}" style="font-weight:
bold;" />
+ <h:outputText id="findComponentOutput"
value="#{rich:findComponent('input').value}" style="font-weight:
bold;" />
</h:panelGrid>
<hr/>
@@ -67,7 +67,7 @@
<h:outputLabel value="Role name: " for="roleName"
/>
<h:inputText value="#{userBean.rolename}"
id="roleName" />
<br />
- <h:commandLink value="Apply role name" />
+ <h:commandLink id="applyLink" value="Apply role name"
/>
<hr/>
<h:panelGrid columns="2">
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richFunctions/TestClientFunctions.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richFunctions/TestClientFunctions.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richFunctions/TestClientFunctions.java 2011-01-07
10:45:36 UTC (rev 20914)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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.richFunctions;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNotSame;
+import java.net.URL;
+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/richFunctions/all.xhtml.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestClientFunctions extends AbstractMetamerTest {
+
+ private JQueryLocator clientIdOutput = pjq("span[id$=clientIdOutput]");
+ private JQueryLocator elementOutput = pjq("span[id$=elementOutput]");
+ private JQueryLocator componentOutput = pjq("span[id$=componentOutput]");
+ private JQueryLocator findComponentOutput =
pjq("span[id$=findComponentOutput]");
+ private JQueryLocator roleNameInput = pjq("input[id$=roleName]");
+ private JQueryLocator applyLink = pjq("a[id$=applyLink]");
+ private JQueryLocator userInRoleAUOutput =
pjq("span[id$=outputUserInRoleAU]");
+ private JQueryLocator userInRoleAOutput =
pjq("span[id$=outputUserInRoleA]");
+ private JQueryLocator userInRoleUOutput =
pjq("span[id$=outputUserInRoleU]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richFunctions/all.xhtml");
+ }
+
+ @Test
+ public void testFunctions() {
+ String clientId = selenium.getText(clientIdOutput);
+ assertNotNull(clientId, "Function clientId() doesn't work.");
+ assertNotSame(clientId, "", "Function clientId() doesn't
work.");
+
+ String output = selenium.getText(elementOutput);
+ assertEquals(output, "document.getElementById('" + clientId +
"')", "Function element() doesn't work.");
+
+ output = selenium.getText(componentOutput);
+ assertEquals(output, "RichFaces.$('" + clientId +
"')", "Function component() doesn't work.");
+
+ output = selenium.getText(findComponentOutput);
+ assertEquals(output, "abc", "Function findComponent() doesn't
work.");
+ }
+
+ @Test
+ public void testRoles() {
+ String outputAU = selenium.getText(userInRoleAUOutput);
+ String outputA = selenium.getText(userInRoleAOutput);
+ String outputU = selenium.getText(userInRoleUOutput);
+ assertEquals(outputAU, "false", "User is not in role
'admin' nor 'user'.");
+ assertEquals(outputA, "false", "User is not in role
'admin'.");
+ assertEquals(outputU, "false", "User is not in role
'user'.");
+
+ selenium.type(roleNameInput, "user");
+ selenium.click(applyLink);
+ selenium.waitForPageToLoad();
+ outputAU = selenium.getText(userInRoleAUOutput);
+ outputA = selenium.getText(userInRoleAOutput);
+ outputU = selenium.getText(userInRoleUOutput);
+ assertEquals(outputAU, "true", "User is in role 'admin' or
'user'.");
+ assertEquals(outputA, "false", "User is not in role
'admin'.");
+ assertEquals(outputU, "true", "User is in role
'user'.");
+
+ selenium.type(roleNameInput, "admin");
+ selenium.click(applyLink);
+ selenium.waitForPageToLoad();
+ outputAU = selenium.getText(userInRoleAUOutput);
+ outputA = selenium.getText(userInRoleAOutput);
+ outputU = selenium.getText(userInRoleUOutput);
+ assertEquals(outputAU, "true", "User is in role 'admin' or
'user'.");
+ assertEquals(outputA, "true", "User is in role
'admin'.");
+ assertEquals(outputU, "false", "User is not in role
'user'.");
+
+ selenium.type(roleNameInput, "superhero");
+ selenium.click(applyLink);
+ selenium.waitForPageToLoad();
+ outputAU = selenium.getText(userInRoleAUOutput);
+ outputA = selenium.getText(userInRoleAOutput);
+ outputU = selenium.getText(userInRoleUOutput);
+ assertEquals(outputAU, "false", "User is not in role
'admin' nor 'user'.");
+ assertEquals(outputA, "false", "User is not in role
'admin'.");
+ assertEquals(outputU, "false", "User is not in role
'user'.");
+ }
+}
Property changes on:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richFunctions/TestClientFunctions.java
___________________________________________________________________
Name: svn:keywords
+ Revision