JBoss Rich Faces SVN: r22527 - in modules/tests/metamer/trunk/application/src/main: webapp/components/richTabPanel and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-06-06 18:02:38 -0400 (Mon, 06 Jun 2011)
New Revision: 22527
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichTabPanelBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/addTab2.xhtml
Log:
Add support for delete created tabs
Simulate issue from user forum: http://community.jboss.org/thread/167372
JIRA: https://issues.jboss.org/browse/RF-11054
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichTabPanelBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichTabPanelBean.java 2011-06-06 12:47:30 UTC (rev 22526)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichTabPanelBean.java 2011-06-06 22:02:38 UTC (rev 22527)
@@ -28,6 +28,7 @@
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
+import javax.faces.context.FacesContext;
import org.richfaces.component.UITab;
import org.richfaces.component.UITabPanel;
@@ -98,6 +99,31 @@
System.out.println(" Now is tabBeans list " + tabBeans.size() + " long");
}
+
+ public void removeTab() throws Exception {
+ // setActiveTabId("TAB1");
+
+ String tabIdToRemove = FacesContext.getCurrentInstance().getExternalContext()
+ .getRequestParameterMap().get("removeTabId");
+
+ TabBean currentTab = getTabById(tabIdToRemove);
+
+ if (currentTab != null) {
+ tabBeans.remove(currentTab);
+ } else {
+ throw new Exception("Tab Id parameter is null");
+ }
+ }
+
+ private TabBean getTabById(String tabId) {
+ System.out.println(" #tabId to remove: '" + tabId + "'");
+ for (TabBean currentTab : tabBeans) {
+ if (currentTab.getTabId().equals(tabId)) {
+ return currentTab;
+ }
+ }
+ return null;
+ }
public Attributes getAttributes() {
return attributes;
@@ -120,6 +146,7 @@
private String tabName;
private String tabHeader;
private String tabContentText;
+ private boolean closable;
public TabBean(String tabId, String tabName, String tabHeader,
String tabContentText){
@@ -127,6 +154,9 @@
this.tabName = tabName;
this.tabHeader = tabHeader;
this.tabContentText = tabContentText;
+
+ // default is closable
+ this.closable = true;
}
public String getTabId() {
@@ -160,6 +190,14 @@
public void setTabContentText(String tabContentText) {
this.tabContentText = tabContentText;
}
+
+ public boolean isClosable() {
+ return closable;
+ }
+
+ public void setClosable(boolean closable) {
+ this.closable = closable;
+ }
}
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/addTab2.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/addTab2.xhtml 2011-06-06 12:47:30 UTC (rev 22526)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richTabPanel/addTab2.xhtml 2011-06-06 22:02:38 UTC (rev 22527)
@@ -85,13 +85,26 @@
</rich:tab>
<c:forEach items="#{richTabPanelBean.tabBeans}" var="newTab">
- <rich:tab id="#{newTab.tabId}" name="#{newTab.tabName}" header="#{newTab.tabHeader}">
+ <rich:tab id="#{newTab.tabId}" name="#{newTab.tabName}">
#{newTab.tabContentText}
- </rich:tab>
+ <f:facet name="header">
+ <h:outputText value="#{newTab.tabHeader} " />
+ <h:commandLink value="[x]"
+ rendered="#{newTab.closable}"
+ onclick="removeTab('#{newTab.tabId}');" />
+ </f:facet>
+ </rich:tab>
</c:forEach>
-
+
</rich:tabPanel>
+ <a4j:jsFunction name="removeTab"
+ action="#{richTabPanelBean.removeTab}"
+ render="tabPanel"
+ oncomplete="#{rich:component('tabPanel')}.switchToItem('tab1');">
+ <a4j:param name="removeTabId"/>
+ </a4j:jsFunction>
+
<br/><br/>
<fieldset>
<legend>JavaScript API</legend>
13 years, 6 months
JBoss Rich Faces SVN: r22526 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-06-06 08:47:30 -0400 (Mon, 06 Jun 2011)
New Revision: 22526
Removed:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidators.java
Log:
Removed TestValidators class since need 2 classes for 2 similar pages
Deleted: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidators.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidators.java 2011-06-06 12:47:11 UTC (rev 22525)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidators.java 2011-06-06 12:47:30 UTC (rev 22526)
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * 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.richValidator;
-
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardNoRequest;
-import static org.jboss.test.selenium.locator.LocatorFactory.jq;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.utils.URLUtils;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Selenium test for page faces/components/richValidator/csv.xhtml
- *
- * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
- * @version $Revision$
- */
-public class TestValidators extends AbstractMetamerTest {
-
-
- private enum ID {
- /** Boolean, true */ assertTrue,
- /** Boolean false */ assertFalse,
- /** Decimal from 2.5 to 9.688 */ decimalMinMax,
- /** Decimal 3 digits and 4 fract */ digits ,
- /** Integer max 10 */ max,
- /** Integer min 2 */ min,
- /** Integer from 2 to 10 */ minMax,
- /** Text, not empty */ notEmpty,
- /** Text, not null */ notNull,
- /** Text, pattern '[a-z].*' */ pattern,
- /** custom validator */ custom,
- /** custom regExp validator */ regexp,
- /** date past */ past,
- /** date future */ future,
- /** String size from 2 to 4 */ stringSize,
- /** Selection size */ size
- }
-
- private Map<ID, String> messages = new HashMap<TestValidators.ID, String>();
-
- private JQueryLocator inputFormat = pjq("input[id$=:{0}]");
-
- private JQueryLocator setWrongBtn = pjq("input[id$=setWrongValuesButton]");
- private JQueryLocator setCorrectBtn = pjq("input[id$=setCorrectValuesButton]");
-
- private JQueryLocator hCommandBtn = pjq("input[id$=hButton]");
- private JQueryLocator a4jCommandBtn = pjq("input[id$=a4jButton]");
-
- private JQueryLocator selectionItem = inputFormat.format(ID.size)
- .getDescendant(jq("tr > td > input[id$=:size:{0}]"));
-
- private JQueryLocator msgFormat = pjq("span[id$={0}Msg] span.rf-msg-det");
-
- @BeforeClass
- private void init() {
- messages.put(ID.assertTrue, "must be true");
- messages.put(ID.assertFalse, "must be false");
- messages.put(ID.decimalMinMax, "must be less than or equal to 9.688");
- messages.put(ID.digits, "numeric value out of bounds (<3 digits>.<4 digits> expected)");
- messages.put(ID.max, "must be less than or equal to 10");
- messages.put(ID.min, "must be greater than or equal to 2");
- messages.put(ID.minMax, "must be greater than or equal to 2");
- messages.put(ID.notEmpty, "may not be empty");
- messages.put(ID.notNull, "may not be null");
- messages.put(ID.pattern, "must match \"[a-z].*\"");
- messages.put(ID.custom, "string is not \"RichFaces\"");
- messages.put(ID.regexp, "Regex pattern of '\\d{3}' not matched");
- messages.put(ID.past, "must be in the past");
- messages.put(ID.future, "must be in the future");
- messages.put(ID.stringSize, "size must be between 2 and 4");
- messages.put(ID.size, "???????"); // RF-11035
- }
-
- @Override
- public URL getTestUrl() {
- return URLUtils.buildUrl(contextPath, "faces/components/richValidator/csv.xhtml");
- }
-
- @Test
- public void testAllWrongWithAjaxSubmit() {
- selenium.click(setCorrectBtn);
- selenium.click(a4jCommandBtn);
-
- waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
- }
-
- @Test
- @IssueTracking(value = "https://issues.jboss.org/browse/RF-11035")
- public void testAllWrongWithJSFSubmit() {
- selenium.click(setCorrectBtn);
- selenium.click(hCommandBtn);
-
- waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
- }
-
- @Test
- public void testBooleanTrue() {
-
- selenium.click(setCorrectBtn);
-
- // checkBoolean to true
- selenium.check(inputFormat.format(ID.assertTrue), false);
-
- guardNoRequest(selenium).click(a4jCommandBtn);
-
- waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
- }
-
- @Test
- public void testBooleanFalse() {
-
- selenium.click(setCorrectBtn);
-
- // checkBoolean to false
- selenium.check(inputFormat.format(ID.assertFalse), true);
- selenium.click(a4jCommandBtn);
-
- waitGui.until(textEquals.locator(msgFormat.format(ID.assertFalse)).text(messages.get(ID.assertFalse)));
- }
-
-}
13 years, 6 months
JBoss Rich Faces SVN: r22525 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: richValidator and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-06-06 08:47:11 -0400 (Mon, 06 Jun 2011)
New Revision: 22525
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/AbstractValidatorsTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidators.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidatorsCSV.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidatorsJSR303.java
Log:
Add selenium tests for validators
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/AbstractValidatorsTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/AbstractValidatorsTest.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/AbstractValidatorsTest.java 2011-06-06 12:47:11 UTC (rev 22525)
@@ -0,0 +1,405 @@
+/*******************************************************************************
+ * 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.richValidator;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+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.BeforeClass;
+
+/**
+ * Abstract class with selenium test for validators
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public abstract class AbstractValidatorsTest extends AbstractMetamerTest {
+
+
+ private enum ID {
+ /** Boolean, true */ assertTrue,
+ /** Boolean false */ assertFalse,
+ /** Decimal from 2.5 to 9.688 */ decimalMinMax,
+ /** Decimal 3 digits and 4 fract */ digits ,
+ /** Integer max 10 */ max,
+ /** Integer min 2 */ min,
+ /** Integer from 2 to 10 */ minMax,
+ /** Text, not empty */ notEmpty,
+ /** Text, not null */ notNull,
+ /** Text, pattern '[a-z].*' */ pattern,
+ /** custom validator */ custom,
+ /** custom regExp validator */ regexp,
+ /** date past */ past,
+ /** date future */ future,
+ /** String size from 2 to 4 */ stringSize,
+ /** Selection size */ size
+ }
+
+ private Map<ID, String> messages = new HashMap<AbstractValidatorsTest.ID, String>();
+
+ private Map<ID, Object> wrongValue = new HashMap<AbstractValidatorsTest.ID, Object>();
+
+ private JQueryLocator inputFormat = pjq("input[id$=:{0}]");
+
+ private JQueryLocator setWrongBtn = pjq("input[id$=setWrongValuesButton]");
+ private JQueryLocator setCorrectBtn = pjq("input[id$=setCorrectValuesButton]");
+
+ private JQueryLocator hCommandBtn = pjq("input[id$=hButton]");
+ private JQueryLocator a4jCommandBtn = pjq("input[id$=a4jButton]");
+
+ private JQueryLocator selectionItem = pjq("table[id$=:size] tr > td > input[value={0}]");
+
+ private JQueryLocator msgFormat = pjq("span[id$={0}Msg] span.rf-msg-det");
+
+ @BeforeClass
+ public void init() {
+ messages.put(ID.assertTrue, "must be true");
+ messages.put(ID.assertFalse, "must be false");
+ messages.put(ID.decimalMinMax, "must be less than or equal to 9.688");
+ messages.put(ID.digits, "numeric value out of bounds (<3 digits>.<4 digits> expected)");
+ messages.put(ID.max, "must be less than or equal to 10");
+ messages.put(ID.min, "must be greater than or equal to 2");
+ messages.put(ID.minMax, "must be greater than or equal to 2");
+ messages.put(ID.notEmpty, "may not be empty");
+ messages.put(ID.notNull, "may not be null");
+ messages.put(ID.pattern, "must match \"[a-z].*\"");
+ messages.put(ID.custom, "string is not \"RichFaces\"");
+ messages.put(ID.regexp, "Regex pattern of '\\d{3}' not matched");
+ messages.put(ID.past, "must be in the past");
+ messages.put(ID.future, "must be in the future");
+ messages.put(ID.stringSize, "size must be between 2 and 4");
+ messages.put(ID.size, "???????"); // RF-11035
+
+ wrongValue.put(ID.assertTrue, Boolean.FALSE);
+ wrongValue.put(ID.assertFalse, Boolean.TRUE);
+ wrongValue.put(ID.decimalMinMax, "10.688");
+ wrongValue.put(ID.digits, "15.627123");
+ wrongValue.put(ID.max, "122");
+ wrongValue.put(ID.min, "-544");
+ wrongValue.put(ID.minMax, "-5");
+ wrongValue.put(ID.notEmpty, "");
+ wrongValue.put(ID.notNull, null);
+ wrongValue.put(ID.pattern, "@@@");
+ wrongValue.put(ID.custom, "@@@");
+ wrongValue.put(ID.regexp, "@@@");
+
+ SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy");
+ long offset = 24 * 60 * 60 * 1000; // more than 24 hours to get correct past date
+ wrongValue.put(ID.past, sdf.format(new Date(System.currentTimeMillis() + offset)));
+ wrongValue.put(ID.future, sdf.format(new Date(System.currentTimeMillis() - offset)));
+
+ wrongValue.put(ID.stringSize, "JSF 2");
+ wrongValue.put(ID.size, "F"); // RF-11035
+ }
+
+ public void verifyAllWrongWithAjaxSubmit() {
+ selenium.click(setWrongBtn);
+
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.assertFalse)).text(messages.get(ID.assertFalse)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.decimalMinMax)).text(messages.get(ID.decimalMinMax)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.digits)).text(messages.get(ID.digits)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.max)).text(messages.get(ID.max)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.min)).text(messages.get(ID.min)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.minMax)).text(messages.get(ID.minMax)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.notEmpty)).text(messages.get(ID.notEmpty)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.notNull)).text(messages.get(ID.notNull)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.pattern)).text(messages.get(ID.pattern)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.custom)).text(messages.get(ID.custom)));
+
+ if (selenium.isElementPresent(inputFormat.format(ID.regexp))) {
+ // regExp validator isn't present in JSR303 validation
+ waitGui.until(textEquals.locator(msgFormat.format(ID.regexp)).text(messages.get(ID.regexp)));
+ }
+ waitGui.until(textEquals.locator(msgFormat.format(ID.past)).text(messages.get(ID.past)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.future)).text(messages.get(ID.future)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.stringSize)).text(messages.get(ID.stringSize)));
+ // TODO JJa 2011-06-06: remove comment when fixed issue with manyCheckbox validation
+ // waitGui.until(textEquals.locator(msgFormat.format(ID.size)).text(messages.get(ID.size)));
+ }
+
+ @IssueTracking(value = "https://issues.jboss.org/browse/RF-11035")
+ public void verifyAllWrongWithJSFSubmit() {
+ selenium.click(setCorrectBtn);
+
+ selenium.click(hCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.assertFalse)).text(messages.get(ID.assertFalse)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.decimalMinMax)).text(messages.get(ID.decimalMinMax)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.digits)).text(messages.get(ID.digits)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.max)).text(messages.get(ID.max)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.min)).text(messages.get(ID.min)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.minMax)).text(messages.get(ID.minMax)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.notEmpty)).text(messages.get(ID.notEmpty)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.notNull)).text(messages.get(ID.notNull)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.pattern)).text(messages.get(ID.pattern)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.custom)).text(messages.get(ID.custom)));
+
+ if (selenium.isElementPresent(inputFormat.format(ID.regexp))) {
+ // regExp validator isn't present in JSR303 validation
+ waitGui.until(textEquals.locator(msgFormat.format(ID.regexp)).text(messages.get(ID.regexp)));
+ }
+ waitGui.until(textEquals.locator(msgFormat.format(ID.past)).text(messages.get(ID.past)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.future)).text(messages.get(ID.future)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.stringSize)).text(messages.get(ID.stringSize)));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.size)).text(messages.get(ID.size)));
+ }
+
+ /**
+ * Boolean input, verify true
+ */
+ public void verifyBooleanTrue() {
+
+ selenium.click(setCorrectBtn);
+
+ // checkBoolean to true
+ selenium.check(inputFormat.format(ID.assertTrue), (Boolean) wrongValue.get(ID.assertTrue));
+
+ // guardNoRequest(selenium).click(a4jCommandBtn);
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
+ }
+
+ /**
+ * Boolean input, verify false
+ */
+ public void verifyBooleanFalse() {
+
+ selenium.click(setCorrectBtn);
+
+ // checkBoolean to false
+ selenium.check(inputFormat.format(ID.assertFalse), (Boolean) wrongValue.get(ID.assertFalse));
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.assertFalse)).text(messages.get(ID.assertFalse)));
+ }
+
+ /**
+ * Decimal input, verify from 2.5 to 9.688
+ */
+ protected void verifyDecimalMinMax() {
+
+ selenium.click(setCorrectBtn);
+
+ // Decimal input
+ selenium.type(inputFormat.format(ID.decimalMinMax), wrongValue.get(ID.decimalMinMax).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.decimalMinMax)).text(messages.get(ID.decimalMinMax)));
+ }
+
+ /**
+ * Decimal input, verify digits
+ */
+ protected void verifyDecimalDigits() {
+
+ selenium.click(setCorrectBtn);
+
+ // decimal input digits
+ selenium.type(inputFormat.format(ID.digits), wrongValue.get(ID.digits).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.decimalMinMax)).text(messages.get(ID.decimalMinMax)));
+ }
+
+ /**
+ * Integer input, verify max
+ */
+ protected void verifyMax() {
+
+ selenium.click(setCorrectBtn);
+
+ // integer input max
+ selenium.type(inputFormat.format(ID.max), wrongValue.get(ID.max).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.max)).text(messages.get(ID.max)));
+ }
+
+ /**
+ * Integer input, verify min
+ */
+ protected void verifyMin() {
+
+ selenium.click(setCorrectBtn);
+
+ // integer input min
+ selenium.type(inputFormat.format(ID.min), wrongValue.get(ID.min).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.min)).text(messages.get(ID.min)));
+ }
+
+ /**
+ * Integer input, verify min max
+ */
+ protected void verifyMinMax() {
+
+ selenium.click(setCorrectBtn);
+
+ // integer input min and max
+ selenium.type(inputFormat.format(ID.minMax), wrongValue.get(ID.minMax).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.minMax)).text(messages.get(ID.minMax)));
+ }
+
+ /**
+ * Integer input, verify not empty
+ */
+ protected void verifyNotEmpty() {
+
+ selenium.click(setCorrectBtn);
+
+ // string input not empty
+ selenium.type(inputFormat.format(ID.notEmpty), wrongValue.get(ID.notEmpty).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.notEmpty)).text(messages.get(ID.notEmpty)));
+ }
+
+ /**
+ * Integer input, verify not null
+ */
+ protected void verifyNotNull() {
+
+ selenium.click(setCorrectBtn);
+
+ // string input not null
+ selenium.type(inputFormat.format(ID.notNull), "");
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.notNull)).text(messages.get(ID.notNull)));
+ }
+
+ /**
+ * Integer input, verify string pattern
+ */
+ protected void verifyPattern() {
+
+ selenium.click(setCorrectBtn);
+
+ // string input custom pattern
+ selenium.type(inputFormat.format(ID.pattern), wrongValue.get(ID.pattern).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.pattern)).text(messages.get(ID.pattern)));
+ }
+
+ /**
+ * Integer input, verify custom string
+ */
+ protected void verifyCustom() {
+
+ selenium.click(setCorrectBtn);
+
+ // string input custom string
+ selenium.type(inputFormat.format(ID.custom), wrongValue.get(ID.custom).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.custom)).text(messages.get(ID.custom)));
+ }
+
+ /**
+ * Integer input, verify regExp
+ */
+ protected void verifyRegExp() {
+
+ selenium.click(setCorrectBtn);
+
+ // string input regExp pattern
+ selenium.type(inputFormat.format(ID.regexp), wrongValue.get(ID.regexp).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.regexp)).text(messages.get(ID.regexp)));
+ }
+
+ /**
+ * Integer input, verify date in past
+ */
+ protected void verifyDatePast() {
+
+ selenium.click(setCorrectBtn);
+
+ // date input past
+ selenium.type(inputFormat.format(ID.past), wrongValue.get(ID.past).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.past)).text(messages.get(ID.past)));
+ }
+
+ /**
+ * Integer input, verify date in future
+ */
+ protected void verifyDateFuture() {
+
+ selenium.click(setCorrectBtn);
+
+ // date input future
+ selenium.type(inputFormat.format(ID.future), wrongValue.get(ID.future).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.future)).text(messages.get(ID.future)));
+ }
+
+ /**
+ * Integer input, verify string size
+ */
+ protected void verifyStringSize() {
+
+ selenium.click(setCorrectBtn);
+
+ // string input string size
+ selenium.type(inputFormat.format(ID.stringSize), wrongValue.get(ID.stringSize).toString());
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.stringSize)).text(messages.get(ID.stringSize)));
+ }
+
+ /**
+ * Integer input, verify selection size
+ */
+ @IssueTracking(value = "https://issues.jboss.org/browse/RF-11035")
+ protected void verifySelectionSize() {
+
+ selenium.click(setCorrectBtn);
+ selenium.click(setWrongBtn);
+
+ // many checkBox input selection size
+ // selenium.type(inputFormat.format(ID.size), wrongValue.get(ID.size).toString());
+ selenium.check(selectionItem.format(wrongValue.get(ID.size)), true);
+
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.size)).text(messages.get(ID.size)));
+ }
+
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidators.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidators.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidators.java 2011-06-06 12:47:11 UTC (rev 22525)
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * 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.richValidator;
+
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardNoRequest;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.utils.URLUtils;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Selenium test for page faces/components/richValidator/csv.xhtml
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public class TestValidators extends AbstractMetamerTest {
+
+
+ private enum ID {
+ /** Boolean, true */ assertTrue,
+ /** Boolean false */ assertFalse,
+ /** Decimal from 2.5 to 9.688 */ decimalMinMax,
+ /** Decimal 3 digits and 4 fract */ digits ,
+ /** Integer max 10 */ max,
+ /** Integer min 2 */ min,
+ /** Integer from 2 to 10 */ minMax,
+ /** Text, not empty */ notEmpty,
+ /** Text, not null */ notNull,
+ /** Text, pattern '[a-z].*' */ pattern,
+ /** custom validator */ custom,
+ /** custom regExp validator */ regexp,
+ /** date past */ past,
+ /** date future */ future,
+ /** String size from 2 to 4 */ stringSize,
+ /** Selection size */ size
+ }
+
+ private Map<ID, String> messages = new HashMap<TestValidators.ID, String>();
+
+ private JQueryLocator inputFormat = pjq("input[id$=:{0}]");
+
+ private JQueryLocator setWrongBtn = pjq("input[id$=setWrongValuesButton]");
+ private JQueryLocator setCorrectBtn = pjq("input[id$=setCorrectValuesButton]");
+
+ private JQueryLocator hCommandBtn = pjq("input[id$=hButton]");
+ private JQueryLocator a4jCommandBtn = pjq("input[id$=a4jButton]");
+
+ private JQueryLocator selectionItem = inputFormat.format(ID.size)
+ .getDescendant(jq("tr > td > input[id$=:size:{0}]"));
+
+ private JQueryLocator msgFormat = pjq("span[id$={0}Msg] span.rf-msg-det");
+
+ @BeforeClass
+ private void init() {
+ messages.put(ID.assertTrue, "must be true");
+ messages.put(ID.assertFalse, "must be false");
+ messages.put(ID.decimalMinMax, "must be less than or equal to 9.688");
+ messages.put(ID.digits, "numeric value out of bounds (<3 digits>.<4 digits> expected)");
+ messages.put(ID.max, "must be less than or equal to 10");
+ messages.put(ID.min, "must be greater than or equal to 2");
+ messages.put(ID.minMax, "must be greater than or equal to 2");
+ messages.put(ID.notEmpty, "may not be empty");
+ messages.put(ID.notNull, "may not be null");
+ messages.put(ID.pattern, "must match \"[a-z].*\"");
+ messages.put(ID.custom, "string is not \"RichFaces\"");
+ messages.put(ID.regexp, "Regex pattern of '\\d{3}' not matched");
+ messages.put(ID.past, "must be in the past");
+ messages.put(ID.future, "must be in the future");
+ messages.put(ID.stringSize, "size must be between 2 and 4");
+ messages.put(ID.size, "???????"); // RF-11035
+ }
+
+ @Override
+ public URL getTestUrl() {
+ return URLUtils.buildUrl(contextPath, "faces/components/richValidator/csv.xhtml");
+ }
+
+ @Test
+ public void testAllWrongWithAjaxSubmit() {
+ selenium.click(setCorrectBtn);
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
+ }
+
+ @Test
+ @IssueTracking(value = "https://issues.jboss.org/browse/RF-11035")
+ public void testAllWrongWithJSFSubmit() {
+ selenium.click(setCorrectBtn);
+ selenium.click(hCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
+ }
+
+ @Test
+ public void testBooleanTrue() {
+
+ selenium.click(setCorrectBtn);
+
+ // checkBoolean to true
+ selenium.check(inputFormat.format(ID.assertTrue), false);
+
+ guardNoRequest(selenium).click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.assertTrue)).text(messages.get(ID.assertTrue)));
+ }
+
+ @Test
+ public void testBooleanFalse() {
+
+ selenium.click(setCorrectBtn);
+
+ // checkBoolean to false
+ selenium.check(inputFormat.format(ID.assertFalse), true);
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.assertFalse)).text(messages.get(ID.assertFalse)));
+ }
+
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidatorsCSV.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidatorsCSV.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidatorsCSV.java 2011-06-06 12:47:11 UTC (rev 22525)
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * 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.richValidator;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.utils.URLUtils;
+import org.testng.annotations.Test;
+
+/**
+ * Selenium tests for page faces/components/richValidator/csv.xhtml
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public class TestValidatorsCSV extends AbstractValidatorsTest {
+
+ @Override
+ public URL getTestUrl() {
+ return URLUtils.buildUrl(contextPath, "faces/components/richValidator/csv.xhtml");
+ }
+
+ @Test
+ public void testAllWrong() {
+ verifyAllWrongWithAjaxSubmit();
+ }
+
+ @Test
+ public void testAllWrongJSF() {
+ verifyAllWrongWithJSFSubmit();
+ }
+
+ @Test
+ public void testBooleanTrue() {
+ verifyBooleanTrue();
+ }
+
+ @Test
+ public void testBooleanFalse() {
+ verifyBooleanFalse();
+ }
+
+ @Test
+ public void testDecimalMinMax() {
+ verifyDecimalMinMax();
+ }
+
+ @Test
+ public void testIntegerMax() {
+ verifyMax();
+ }
+
+ @Test
+ public void testIntegerMin() {
+ verifyMin();
+ }
+
+ @Test
+ public void testIntegerMinMax() {
+ verifyMinMax();
+ }
+
+ @Test
+ public void testTextNotEmpty() {
+ verifyNotEmpty();
+ }
+
+ @Test
+ public void testTextNotNull() {
+ verifyNotNull();
+ }
+
+ @Test
+ public void testTextPattern() {
+ verifyPattern();
+ }
+
+ @Test
+ public void testTextCustomPattern() {
+ verifyCustom();
+ }
+
+ @Test
+ public void testTextRegExp() {
+ verifyRegExp();
+ }
+
+ @Test
+ public void testDatePast() {
+ verifyDatePast();
+ }
+
+ @Test
+ public void testDateFuture() {
+ verifyDateFuture();
+ }
+
+ @Test
+ public void testStringSize() {
+ verifyStringSize();
+ }
+
+ @Test
+ public void testSelectionSize() {
+ verifySelectionSize();
+ }
+
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidatorsJSR303.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidatorsJSR303.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richValidator/TestValidatorsJSR303.java 2011-06-06 12:47:11 UTC (rev 22525)
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * 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.richValidator;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.utils.URLUtils;
+import org.testng.annotations.Test;
+
+/**
+ * Selenium tests for page faces/components/richValidator/jsr303.xhtml
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public class TestValidatorsJSR303 extends AbstractValidatorsTest {
+
+ @Override
+ public URL getTestUrl() {
+ return URLUtils.buildUrl(contextPath, "faces/components/richValidator/jsr303.xhtml");
+ }
+
+ @Test
+ public void testAllWrong() {
+ verifyAllWrongWithAjaxSubmit();
+ }
+
+ @Test
+ public void testAllWrongJSF() {
+ verifyAllWrongWithJSFSubmit();
+ }
+
+ @Test
+ public void testBooleanTrue() {
+ verifyBooleanTrue();
+ }
+
+ @Test
+ public void testBooleanFalse() {
+ verifyBooleanFalse();
+ }
+
+ @Test
+ public void testDecimalMinMax() {
+ verifyDecimalMinMax();
+ }
+
+ @Test
+ public void testIntegerMax() {
+ verifyMax();
+ }
+
+ @Test
+ public void testIntegerMin() {
+ verifyMin();
+ }
+
+ @Test
+ public void testIntegerMinMax() {
+ verifyMinMax();
+ }
+
+ @Test
+ public void testTextNotEmpty() {
+ verifyNotEmpty();
+ }
+
+ @Test
+ public void testTextNotNull() {
+ verifyNotNull();
+ }
+
+ @Test
+ public void testTextPattern() {
+ verifyPattern();
+ }
+
+ @Test
+ public void testTextCustomPattern() {
+ verifyCustom();
+ }
+
+ @Test
+ public void testDatePast() {
+ verifyDatePast();
+ }
+
+ @Test
+ public void testDateFuture() {
+ verifyDateFuture();
+ }
+
+ @Test
+ public void testStringSize() {
+ verifyStringSize();
+ }
+
+ @Test
+ public void testSelectionSize() {
+ verifySelectionSize();
+ }
+
+}
13 years, 6 months
JBoss Rich Faces SVN: r22524 - modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-06-06 08:46:48 -0400 (Mon, 06 Jun 2011)
New Revision: 22524
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csv.xhtml
Log:
Fix set correct value for regExp input
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csv.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csv.xhtml 2011-06-06 12:46:33 UTC (rev 22523)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csv.xhtml 2011-06-06 12:46:48 UTC (rev 22524)
@@ -62,6 +62,7 @@
$('input[id$=notEmpty]').val('RichFaces 4');
$('input[id$=notNull]').val('RichFaces 4');
$('input[id$=pattern]').val('richFaces 4');
+ $('input[id$=regexp]').val('100');
$('input[id$=custom]').val('RichFaces');
$('input[id$=past]').val(inPast.format("d mmm yyyy"));
$('input[id$=future]').val(inFuture.format("d mmm yyyy"));
@@ -89,6 +90,7 @@
$('input[id$=notEmpty]').val('');
$('input[id$=notNull]').val('');
$('input[id$=pattern]').val('@@@');
+ $('input[id$=regexp]').val('@@@');
$('input[id$=custom]').val('@@@');
$('input[id$=past]').val(inFuture.format("d mmm yyyy"));
$('input[id$=future]').val(inPast.format("d mmm yyyy"));
13 years, 6 months
JBoss Rich Faces SVN: r22523 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-06-06 08:46:33 -0400 (Mon, 06 Jun 2011)
New Revision: 22523
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanelAddPanel1.java
Log:
Save work on tabPanel dynamic tab create selenium test
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanelAddPanel1.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanelAddPanel1.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanelAddPanel1.java 2011-06-06 12:46:33 UTC (rev 22523)
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * 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.richTabPanel;
+
+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.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+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/richTabPanel/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestRichTabPanelAddPanel1 extends AbstractMetamerTest {
+
+ private JQueryLocator panel = pjq("div[id$=tabPanel]");
+ private JQueryLocator[] items = {pjq("div[id$=tab1]"), pjq("div[id$=tab2]"), pjq("div[id$=tab3]"), pjq("div[id$=tab4]"),
+ pjq("div[id$=tab5]")};
+ private JQueryLocator[] itemContents = {pjq("div[id$=tab1] > div.rf-tab-cnt"), pjq("div[id$=tab2] > div.rf-tab-cnt"),
+ pjq("div[id$=tab3] > div.rf-tab-cnt"), pjq("div[id$=tab4] > div.rf-tab-cnt"), pjq("div[id$=tab5] > div.rf-tab-cnt"),
+ pjq("div[id$=tab6] > div.rf-tab-cnt"), pjq("div[id$=tab7] > div.rf-tab-cnt"), pjq("div[id$=tab8] > div.rf-tab-cnt")};
+ private JQueryLocator[] activeHeaders = {pjq("td[id$=tab1:header:active]"), pjq("td[id$=tab2:header:active]"),
+ pjq("td[id$=tab3:header:active]"), pjq("td[id$=tab4:header:active]"), pjq("td[id$=tab5:header:active]")};
+ private JQueryLocator[] inactiveHeaders = {pjq("td[id$=tab1:header:inactive]"), pjq("td[id$=tab2:header:inactive]"),
+ pjq("td[id$=tab3:header:inactive]"), pjq("td[id$=tab4:header:inactive]"), pjq("td[id$=tab5:header:inactive]"),
+ pjq("td[id$=tab6:header:inactive]"), pjq("td[id$=tab7:header:inactive]"), pjq("td[id$=tab8:header:inactive]") };
+ private JQueryLocator[] disabledHeaders = {pjq("td[id$=tab1:header:disabled]"), pjq("td[id$=tab2:header:disabled]"),
+ pjq("td[id$=tab3:header:disabled]"), pjq("td[id$=tab4:header:disabled]"), pjq("td[id$=tab5:header:disabled]")};
+
+ private JQueryLocator hCreateTabBtn = pjq("input[id$=hCreateTabButton]");
+ private JQueryLocator aa4jCreateTabBtn = pjq("input[id$=a4jCreateTabButton]");
+
+ private JQueryLocator tabsCount = pjq("table.rf-tab-hdr-tabs td.rf-tab-hdr-inact");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richTabPanel/addTab.xhtml");
+ }
+
+ @Test
+ public void testInit() {
+ boolean displayed = selenium.isDisplayed(panel);
+ assertTrue(displayed, "Tab panel is not present on the page.");
+
+ displayed = selenium.isDisplayed(activeHeaders[0]);
+ assertTrue(displayed, "Header of tab1 should be active.");
+ for (int i = 1; i < 5; i++) {
+ displayed = selenium.isDisplayed(activeHeaders[i]);
+ assertFalse(displayed, "Header of tab " + (i + 1) + " should not be active.");
+ }
+
+ displayed = selenium.isDisplayed(inactiveHeaders[0]);
+ assertFalse(displayed, "Header of tab1 should not be inactive.");
+ displayed = selenium.isDisplayed(inactiveHeaders[1]);
+ assertTrue(displayed, "Header of tab2 should be inactive.");
+
+ displayed = selenium.isDisplayed(disabledHeaders[3]);
+ assertTrue(displayed, "Header of tab4 should be disabled.");
+ for (int i = 0; i < 3; i++) {
+ displayed = selenium.isDisplayed(disabledHeaders[i]);
+ assertFalse(displayed, "Header of tab " + (i + 1) + " should not be disabled.");
+ }
+
+ displayed = selenium.isDisplayed(itemContents[0]);
+ assertTrue(displayed, "Content of item1 should be visible.");
+
+ for (int i = 1; i < 5; i++) {
+ displayed = selenium.isDisplayed(items[i]);
+ assertFalse(displayed, "Tab" + (i + 1) + "'s content should not be visible.");
+ }
+ }
+
+ @Test(dependsOnMethods = {"testInit"})
+ public void testCreateTab() {
+ selenium.click(pjq("input[name$=switchTypeInput][value=client]"));
+ selenium.waitForPageToLoad();
+
+ int baseTabsCount = selenium.getCount(tabsCount);
+
+ // add 3 new tabs
+ for (int i=1; i<4; ++i){
+ selenium.click(hCreateTabBtn);
+ selenium.waitForPageToLoad();
+ waitGui.until(countEquals.count(baseTabsCount + i).locator(tabsCount));
+ }
+ }
+
+ /*
+ * Test plan:
+ * 1. click on 'create tab' btn 3 time and verify that new tabs appeared
+ * 2. verify that switch between newly created tabs still works as in previous tabs (staticaly created)
+ * 3. verify a4j ajax btn to create new tabs
+ */
+
+ public void testSwitchTypeNull() {
+ for (int i = 7; i >= 5; i--) {
+ final int index = i;
+ guardXhr(selenium).click(inactiveHeaders[index]);
+ waitGui.failWith("Tab " + (index + 1) + " is not displayed.").until(isDisplayed.locator(itemContents[index]));
+ }
+ }
+
+ @Test(dependsOnMethods = {"testCreateTab"})
+ public void testSwitchTypeAjax() {
+ selenium.click(pjq("input[name$=switchTypeInput][value=ajax]"));
+ selenium.waitForPageToLoad();
+
+ testSwitchTypeNull();
+ }
+
+ @Test(dependsOnMethods = {"testCreateTab"})
+ public void testSwitchTypeClient() {
+ selenium.click(pjq("input[name$=switchTypeInput][value=client]"));
+ selenium.waitForPageToLoad();
+
+ for (int i = 7; i >= 5; i--) {
+ final int index = i;
+ guardNoRequest(selenium).click(inactiveHeaders[index]);
+ waitGui.failWith("Tab " + (index + 1) + " is not displayed.").until(isDisplayed.locator(itemContents[index]));
+ }
+ }
+
+}
13 years, 6 months
JBoss Rich Faces SVN: r22522 - in modules/tests/metamer/trunk/application/src/main: webapp/components/richTab and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-06-06 08:46:12 -0400 (Mon, 06 Jun 2011)
New Revision: 22522
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richTab/withA4j.xhtml
Log:
Modify rich:tab with a4j:ajax + add new actionListener
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2011-06-01 15:34:13 UTC (rev 22521)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2011-06-06 12:46:12 UTC (rev 22522)
@@ -386,6 +386,16 @@
public void actionListener(AjaxBehaviorEvent event) {
logToPage("* action listener invoked");
}
+
+ /**
+ * An action listener that does nothing.
+ *
+ * @param event
+ * an event representing the activation of a user interface component (not used)
+ */
+ public void actionListener2(AjaxBehaviorEvent event) {
+ logToPage("* action listener *2 invoked");
+ }
/**
* An item change listener that logs to the page old and new value.
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richTab/withA4j.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richTab/withA4j.xhtml 2011-06-01 15:34:13 UTC (rev 22521)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richTab/withA4j.xhtml 2011-06-06 12:46:12 UTC (rev 22522)
@@ -38,7 +38,7 @@
<ui:define name="component">
- <rich:tabPanel id="tabPanel" itemChangeListener="#{richBean.itemChangeListener}" >
+ <rich:tabPanel id="tabPanel" switchType="ajax" >
<rich:tab id="tab1"
action="#{richBean.dummyAction}"
@@ -77,8 +77,8 @@
switchType="#{richTabBean.attributes['switchType'].value}"
title="#{richTabBean.attributes['title'].value}" >
<a4j:ajax
- event="click"
- listener="#{richBean.actionListener}" />
+ event="enter"
+ listener="#{richBean.actionListener2}" />
content of tab 1
</rich:tab>
<rich:tab id="tab2" name="tab2" header="tab2 header"
13 years, 6 months
JBoss Rich Faces SVN: r22520 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSlider.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-06-01 11:18:22 -0400 (Wed, 01 Jun 2011)
New Revision: 22520
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSlider/TestRichSliderWithJSR303.java
Log:
Add selenium tests for rich:inputNumberSlider with JSR303 validation
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSlider/TestRichSliderWithJSR303.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSlider/TestRichSliderWithJSR303.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSlider/TestRichSliderWithJSR303.java 2011-06-01 15:18:22 UTC (rev 22520)
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * 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.richInputNumberSlider;
+
+import java.net.URL;
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.geometry.Point;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.utils.URLUtils;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Test for faces/components/richInputNumberSpinner/jsr303.xhtml page
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public class TestRichSliderWithJSR303 extends AbstractMetamerTest {
+
+ /** Wrong value for input validated to min value */
+ public static final String WRONG_MIN_VAL = "1";
+ /** Wrong value for input validated to max value */
+ public static final String WRONG_MAX_VAL = "5";
+ /** Wrong value for input validated to custom value */
+ public static final String WRONG_CUSTOM_VAL = "-1";
+
+ /** Wrong value for input validated to min value */
+ public static final String CORRECT_MIN_VAL = "3";
+ /** Wrong value for input validated to max value */
+ public static final String CORRECT_MAX_VAL = "1";
+ /** Wrong value for input validated to custom value */
+ public static final String CORRECT_CUSTOM_VAL = "5";
+
+
+ /** validation message for input validated to min value */
+ public static final String MSG_MIN = "must be greater than or equal to 2";
+ /** validation message for input validated to max value */
+ public static final String MSG_MAX = "must be less than or equal to 2";
+ /** validation message for input validated to custom value */
+ public static final String MSG_CUSTOM = "must be a positive number";
+
+ private JQueryLocator inputFormat = pjq("span[id$=:slider{0}] span.rf-insl-inp-cntr > input");
+ private JQueryLocator msgFormat = pjq("span.rf-msg[id$=:inputMsg{0}] span.rf-msg-det");
+ private JQueryLocator outputFormat = pjq("span[id$=:output{0}]");
+ private JQueryLocator sliderFormat = pjq("span[id$=:slider{0}] span.rf-insl-trc");
+
+ private JQueryLocator hCommandBtn = pjq("input[id$=:hButton]");
+ private JQueryLocator a4jCommandBtn = pjq("input[id$=:a4jButton]");
+
+ /** Codes for inputs */
+ private enum ID {
+ /** input validated to min val */
+ MIN(1),
+ /** input validated to max val */
+ MAX(2),
+ /** input validated to custom (positive) val */
+ CUSTOM(3);
+
+ private int id;
+ private ID(int i) {
+ this.id = i;
+ }
+ public int val() {
+ return id;
+ }
+ }
+
+ /** Position coordinates for slider.
+ * Width is 200px, positions are relative to this
+ */
+ private enum POSITION {
+ LESS_THAN_ZERO(10),
+ ZERO(100),
+ MORE_THAN_TWO(150);
+
+ private int position;
+ private POSITION(int position) {
+ this.position = position;
+ }
+ public int val(){
+ return position;
+ }
+ }
+
+ private void setAllCorrect() {
+ selenium.type(inputFormat.format(ID.MIN.val()), CORRECT_MIN_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MIN.val()), Event.BLUR);
+ selenium.type(inputFormat.format(ID.MAX.val()), CORRECT_MAX_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MAX.val()), Event.BLUR);
+ selenium.type(inputFormat.format(ID.CUSTOM.val()), CORRECT_CUSTOM_VAL);
+ selenium.fireEvent(inputFormat.format(ID.CUSTOM.val()), Event.BLUR);
+ }
+
+ private void setAllWrong() {
+ selenium.type(inputFormat.format(ID.MIN.val()), WRONG_MIN_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MIN.val()), Event.BLUR);
+ selenium.type(inputFormat.format(ID.MAX.val()), WRONG_MAX_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MAX.val()), Event.BLUR);
+ selenium.type(inputFormat.format(ID.CUSTOM.val()), WRONG_CUSTOM_VAL);
+ selenium.fireEvent(inputFormat.format(ID.CUSTOM.val()), Event.BLUR);
+
+ // wait until validation appears on last input before go ahead (e.g. submit form)
+ waitGui.until(textEquals.text(MSG_CUSTOM).locator(msgFormat.format(ID.CUSTOM.val())));
+ }
+
+ @Override
+ public URL getTestUrl() {
+ return URLUtils.buildUrl(contextPath, "faces/components/richInputNumberSlider/jsr303.xhtml");
+ }
+
+ @Test
+ public void testMin() {
+ selenium.type(inputFormat.format(ID.MIN.val()), WRONG_MIN_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MIN.val()), Event.BLUR);
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MIN.val())).text(MSG_MIN));
+ }
+
+ @Test
+ public void testSlideToMin() {
+ setAllCorrect();
+
+ selenium.mouseDownAt(sliderFormat.format(ID.MIN.val()), new Point(POSITION.ZERO.val(), 0));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MIN.val())).text(MSG_MIN));
+ }
+
+ @Test
+ public void testMax() {
+ selenium.type(inputFormat.format(ID.MAX.val()), WRONG_MAX_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MAX.val()), Event.BLUR);
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MAX.val())).text(MSG_MAX));
+ }
+
+ @Test
+ public void testSlideToMax() {
+ setAllCorrect();
+
+ selenium.mouseDownAt(sliderFormat.format(ID.MAX.val()), new Point(POSITION.MORE_THAN_TWO.val(), 0));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MAX.val())).text(MSG_MAX));
+ }
+
+ @Test
+ public void testCustom() {
+ selenium.type(inputFormat.format(ID.CUSTOM.val()), WRONG_CUSTOM_VAL);
+ selenium.fireEvent(inputFormat.format(ID.CUSTOM.val()), Event.BLUR);
+ waitGui.until(textEquals.text(MSG_CUSTOM).locator(msgFormat.format(ID.CUSTOM.val())));
+ }
+
+ @Test
+ public void testSlideToNegative() {
+ setAllCorrect();
+
+ selenium.mouseDownAt(sliderFormat.format(ID.CUSTOM.val()), new Point(POSITION.LESS_THAN_ZERO.val(), 0));
+ waitGui.until(textEquals.locator(msgFormat.format(ID.CUSTOM.val())).text(MSG_CUSTOM));
+ }
+
+ @Test
+ public void testAllCorrect() {
+
+ setAllCorrect();
+
+ waitGui.until(textEquals.text(CORRECT_MIN_VAL)
+ .locator(outputFormat.format(ID.MIN.val())));
+ Assert.assertEquals(selenium.getText(outputFormat.format(ID.MAX.val())), CORRECT_MAX_VAL);
+ Assert.assertEquals(selenium.getText(outputFormat.format(ID.CUSTOM.val())), CORRECT_CUSTOM_VAL);
+
+ }
+
+ @Test
+ public void testAllWrong() {
+
+ setAllCorrect();
+ setAllWrong();
+
+ selenium.click(hCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MIN.val())).text(MSG_MIN));
+ Assert.assertEquals(selenium.getText(msgFormat.format(ID.MAX.val())), MSG_MAX);
+ Assert.assertEquals(selenium.getText(msgFormat.format(ID.CUSTOM.val())), MSG_CUSTOM);
+
+ setAllCorrect();
+ setAllWrong();
+
+ selenium.click(a4jCommandBtn);
+
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MIN.val())).text(MSG_MIN));
+ Assert.assertEquals(selenium.getText(msgFormat.format(ID.MAX.val())), MSG_MAX);
+ Assert.assertEquals(selenium.getText(msgFormat.format(ID.CUSTOM.val())), MSG_CUSTOM);
+ }
+
+}
13 years, 6 months
JBoss Rich Faces SVN: r22519 - modules/tests/metamer/trunk/application/src/main/webapp/components/richInputNumberSlider.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-06-01 11:18:00 -0400 (Wed, 01 Jun 2011)
New Revision: 22519
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richInputNumberSlider/jsr303.xhtml
Log:
Fix missing output for rich:inputNumberSlider
There was wrong bean bound to output component
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richInputNumberSlider/jsr303.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richInputNumberSlider/jsr303.xhtml 2011-06-01 15:17:43 UTC (rev 22518)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richInputNumberSlider/jsr303.xhtml 2011-06-01 15:18:00 UTC (rev 22519)
@@ -65,11 +65,11 @@
<h:panelGrid columns="2">
output1
- <h:outputText id="output1" value="#{richInplaceInputBean.value1}"/>
+ <h:outputText id="output1" value="#{richInputNumberSliderBean.value1}"/>
output2
- <h:outputText id="output2" value="#{richInplaceInputBean.value2}"/>
+ <h:outputText id="output2" value="#{richInputNumberSliderBean.value2}"/>
output3
- <h:outputText id="output3" value="#{richInplaceInputBean.value3}"/>
+ <h:outputText id="output3" value="#{richInputNumberSliderBean.value3}"/>
</h:panelGrid>
</ui:define>
13 years, 6 months
JBoss Rich Faces SVN: r22518 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSpinner.
by richfaces-svn-commits@lists.jboss.org
Author: jjamrich
Date: 2011-06-01 11:17:43 -0400 (Wed, 01 Jun 2011)
New Revision: 22518
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSpinner/TestRichSpinnerWithJSR303.java
Log:
Add tests for validation on spinnig
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSpinner/TestRichSpinnerWithJSR303.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSpinner/TestRichSpinnerWithJSR303.java 2011-05-31 15:19:04 UTC (rev 22517)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSpinner/TestRichSpinnerWithJSR303.java 2011-06-01 15:17:43 UTC (rev 22518)
@@ -21,9 +21,11 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richInputNumberSpinner;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+
import java.net.URL;
-
import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.geometry.Point;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.utils.URLUtils;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
@@ -38,13 +40,6 @@
*/
public class TestRichSpinnerWithJSR303 extends AbstractMetamerTest {
- /** Code for input validated to min value */
- public static final int MIN_ID = 1;
- /** Code for input validated to max value */
- public static final int MAX_ID = 2;
- /** Code for input validated to custom condition */
- public static final int CUSTOM_ID = 3;
-
/** Wrong value for input validated to min value */
public static final String WRONG_MIN_VAL = "1";
/** Wrong value for input validated to max value */
@@ -74,26 +69,73 @@
private JQueryLocator hCommandBtn = pjq("input[id$=:hButton]");
private JQueryLocator a4jCommandBtn = pjq("input[id$=:a4jButton]");
+ private JQueryLocator spinnerIncFormat = jq("span[id$=:input{0}] span.rf-insp-inc");
+ private JQueryLocator spinnerDecFormat = jq("span[id$=:input{0}] span.rf-insp-dec");
+
+ /** Codes for inputs */
+ private enum ID {
+ /** input validated to min val */
+ MIN(1),
+ /** input validated to max val */
+ MAX(2),
+ /** input validated to custom (positive) val */
+ CUSTOM(3);
+
+ private int id;
+ private ID(int i) {
+ this.id = i;
+ }
+ public int val() {
+ return id;
+ }
+ }
+
private void setAllCorrect() {
- selenium.type(inputFormat.format(MIN_ID), CORRECT_MIN_VAL);
- selenium.fireEvent(inputFormat.format(MIN_ID), Event.BLUR);
- selenium.type(inputFormat.format(MAX_ID), CORRECT_MAX_VAL);
- selenium.fireEvent(inputFormat.format(MAX_ID), Event.BLUR);
- selenium.type(inputFormat.format(CUSTOM_ID), CORRECT_CUSTOM_VAL);
- selenium.fireEvent(inputFormat.format(CUSTOM_ID), Event.BLUR);
+ selenium.type(inputFormat.format(ID.MIN.val()), CORRECT_MIN_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MIN.val()), Event.BLUR);
+ selenium.type(inputFormat.format(ID.MAX.val()), CORRECT_MAX_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MAX.val()), Event.BLUR);
+ selenium.type(inputFormat.format(ID.CUSTOM.val()), CORRECT_CUSTOM_VAL);
+ selenium.fireEvent(inputFormat.format(ID.CUSTOM.val()), Event.BLUR);
}
private void setAllWrong() {
- selenium.type(inputFormat.format(MIN_ID), WRONG_MIN_VAL);
- selenium.fireEvent(inputFormat.format(MIN_ID), Event.BLUR);
- selenium.type(inputFormat.format(MAX_ID), WRONG_MAX_VAL);
- selenium.fireEvent(inputFormat.format(MAX_ID), Event.BLUR);
- selenium.type(inputFormat.format(CUSTOM_ID), WRONG_CUSTOM_VAL);
- selenium.fireEvent(inputFormat.format(CUSTOM_ID), Event.BLUR);
+ selenium.type(inputFormat.format(ID.MIN.val()), WRONG_MIN_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MIN.val()), Event.BLUR);
+ selenium.type(inputFormat.format(ID.MAX.val()), WRONG_MAX_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MAX.val()), Event.BLUR);
+ selenium.type(inputFormat.format(ID.CUSTOM.val()), WRONG_CUSTOM_VAL);
+ selenium.fireEvent(inputFormat.format(ID.CUSTOM.val()), Event.BLUR);
// wait until validation appears on last input before go ahead (e.g. submit form)
- waitGui.until(textEquals.locator(msgFormat.format(CUSTOM_ID)).text(MSG_CUSTOM));
+ waitGui.until(textEquals.text(MSG_CUSTOM).locator(msgFormat.format(ID.CUSTOM.val())));
}
+
+ private void spinUp(ID inputId, String toValue) {
+ int currentVal = Integer.parseInt(selenium.getValue(inputFormat.format(inputId.val())));
+ int diff = Integer.parseInt(toValue) - currentVal;
+
+ if (diff < 0) {
+ throw new IllegalArgumentException("Cannot spin from " + currentVal + " to " + toValue);
+ }
+
+ for (int i = 0; i < diff; ++i) {
+ selenium.clickAt(spinnerIncFormat.format(inputId.val()), new Point(1, 1));
+ }
+ }
+
+ private void spinDown(ID inputId, String toValue) {
+ int currentVal = Integer.parseInt(selenium.getValue(inputFormat.format(inputId.val())));
+ int diff = currentVal - Integer.parseInt(toValue);
+
+ if (diff < 0) {
+ throw new IllegalArgumentException("Cannot spin from " + currentVal + " to " + toValue);
+ }
+
+ for (int i = 0; i < diff; ++i) {
+ selenium.clickAt(spinnerDecFormat.format(inputId.val()), new Point(1, 1));
+ }
+ }
@Override
public URL getTestUrl() {
@@ -102,33 +144,60 @@
@Test
public void testMin() {
- selenium.type(inputFormat.format(MIN_ID), WRONG_MIN_VAL);
- selenium.fireEvent(inputFormat.format(MIN_ID), Event.BLUR);
- waitGui.until(textEquals.locator(msgFormat.format(MIN_ID)).text(MSG_MIN));
+ selenium.type(inputFormat.format(ID.MIN.val()), WRONG_MIN_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MIN.val()), Event.BLUR);
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MIN.val())).text(MSG_MIN));
}
@Test
+ public void testSpinToMin() {
+ selenium.type(inputFormat.format(ID.MIN.val()), CORRECT_MIN_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MIN.val()), Event.BLUR);
+
+ spinDown(ID.MIN, WRONG_MIN_VAL);
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MIN.val())).text(MSG_MIN));
+ }
+
+ @Test
public void testMax() {
- selenium.type(inputFormat.format(MAX_ID), WRONG_MAX_VAL);
- selenium.fireEvent(inputFormat.format(MAX_ID), Event.BLUR);
- waitGui.until(textEquals.locator(msgFormat.format(MAX_ID)).text(MSG_MAX));
+ selenium.type(inputFormat.format(ID.MAX.val()), WRONG_MAX_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MAX.val()), Event.BLUR);
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MAX.val())).text(MSG_MAX));
}
@Test
+ public void testSpinToMax() {
+ selenium.type(inputFormat.format(ID.MAX.val()), CORRECT_MAX_VAL);
+ selenium.fireEvent(inputFormat.format(ID.MAX.val()), Event.BLUR);
+
+ spinUp(ID.MAX, WRONG_MAX_VAL);
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MAX.val())).text(MSG_MAX));
+ }
+
+ @Test
public void testCustom() {
- selenium.type(inputFormat.format(CUSTOM_ID), WRONG_CUSTOM_VAL);
- selenium.fireEvent(inputFormat.format(CUSTOM_ID), Event.BLUR);
- waitGui.until(textEquals.locator(msgFormat.format(CUSTOM_ID)).text(MSG_CUSTOM));
+ selenium.type(inputFormat.format(ID.CUSTOM.val()), WRONG_CUSTOM_VAL);
+ selenium.fireEvent(inputFormat.format(ID.CUSTOM.val()), Event.BLUR);
+ waitGui.until(textEquals.text(MSG_CUSTOM).locator(msgFormat.format(ID.CUSTOM.val())));
}
+ @Test
+ public void testSpinToNegative() {
+ selenium.type(inputFormat.format(ID.CUSTOM.val()), CORRECT_CUSTOM_VAL);
+ selenium.fireEvent(inputFormat.format(ID.CUSTOM.val()), Event.BLUR);
+
+ spinDown(ID.CUSTOM, WRONG_CUSTOM_VAL);
+ waitGui.until(textEquals.text(MSG_CUSTOM).locator(msgFormat.format(ID.CUSTOM.val())));
+ }
+
@Test
public void testAllCorrect() {
setAllCorrect();
- waitGui.until(textEquals.locator(outputFormat.format(MIN_ID)).text(CORRECT_MIN_VAL));
- Assert.assertEquals(selenium.getText(outputFormat.format(MAX_ID)), CORRECT_MAX_VAL);
- Assert.assertEquals(selenium.getText(outputFormat.format(CUSTOM_ID)), CORRECT_CUSTOM_VAL);
+ waitGui.until(textEquals.text(CORRECT_MIN_VAL).locator(outputFormat.format(ID.MIN.val())));
+ Assert.assertEquals(selenium.getText(outputFormat.format(ID.MAX.val())), CORRECT_MAX_VAL);
+ Assert.assertEquals(selenium.getText(outputFormat.format(ID.CUSTOM.val())), CORRECT_CUSTOM_VAL);
}
@Test
@@ -139,18 +208,18 @@
selenium.click(hCommandBtn);
- waitGui.until(textEquals.locator(msgFormat.format(MIN_ID)).text(MSG_MIN));
- Assert.assertEquals(selenium.getText(msgFormat.format(MAX_ID)), MSG_MAX);
- Assert.assertEquals(selenium.getText(msgFormat.format(CUSTOM_ID)), MSG_CUSTOM);
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MIN.val())).text(MSG_MIN));
+ Assert.assertEquals(selenium.getText(msgFormat.format(ID.MAX.val())), MSG_MAX);
+ Assert.assertEquals(selenium.getText(msgFormat.format(ID.CUSTOM.val())), MSG_CUSTOM);
setAllCorrect();
setAllWrong();
selenium.click(a4jCommandBtn);
- waitGui.until(textEquals.locator(msgFormat.format(MIN_ID)).text(MSG_MIN));
- Assert.assertEquals(selenium.getText(msgFormat.format(MAX_ID)), MSG_MAX);
- Assert.assertEquals(selenium.getText(msgFormat.format(CUSTOM_ID)), MSG_CUSTOM);
+ waitGui.until(textEquals.locator(msgFormat.format(ID.MIN.val())).text(MSG_MIN));
+ Assert.assertEquals(selenium.getText(msgFormat.format(ID.MAX.val())), MSG_MAX);
+ Assert.assertEquals(selenium.getText(msgFormat.format(ID.CUSTOM.val())), MSG_CUSTOM);
}
}
13 years, 6 months