Author: jjamrich
Date: 2011-07-25 04:34:11 -0400 (Mon, 25 Jul 2011)
New Revision: 22563
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAutocomplete/TestAutocompleteVisualState.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/Autocomplete.java
Log:
RFPL-1079: Test reloading of components to validate keeping of visual state
Add routines into Abstract Metamer test and implement first test for
rich:autocomplete.
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2011-07-22
14:52:32 UTC (rev 22562)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2011-07-25
08:34:11 UTC (rev 22563)
@@ -59,6 +59,7 @@
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.ExtendedLocator;
+import org.jboss.test.selenium.locator.IdLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.locator.reference.LocatorReference;
import org.jboss.test.selenium.locator.reference.ReferencedLocator;
@@ -88,6 +89,8 @@
protected JQueryLocator time = jq("span[id$=requestTime]");
protected JQueryLocator renderChecker = jq("span[id$=renderChecker]");
protected JQueryLocator statusChecker =
jq("span[id$=statusCheckerOutput]");
+ protected IdLocator fullPageRefreshIcon =
id("controlsForm:fullPageRefreshImage");
+ protected IdLocator rerenderAllIcon = id("controlsForm:reRenderAllImage");
protected TextRetriever retrieveRequestTime = retrieveText.locator(time);
protected Retriever<String> retrieveWindowData = new
ScriptEvaluationRetriever().script(js("window.data"));
protected TextRetriever retrieveRenderChecker =
retrieveText.locator(jq("#renderChecker"));
@@ -150,15 +153,17 @@
/**
* Do a full page refresh (regular HTTP request) by triggering a command with no
action bound.
*/
- public void fullPageRefresh() {
- guardHttp(selenium).click(id("controlsForm:fullPageRefreshImage"));
+ public void fullPageRefresh() {
+ waitGui.until(elementPresent.locator(fullPageRefreshIcon));
+ guardHttp(selenium).click(fullPageRefreshIcon);
}
/**
* Rerender all content of the page (AJAX request) by trigerring a command with no
action but render bound.
*/
- public void rerenderAll() {
- guardXhr(selenium).click(id("controlsForm:reRenderAllImage"));
+ public void rerenderAll() {
+ waitGui.until(elementPresent.locator(rerenderAllIcon));
+ guardXhr(selenium).click(rerenderAllIcon);
}
/**
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/Autocomplete.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/Autocomplete.java 2011-07-22
14:52:32 UTC (rev 22562)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/Autocomplete.java 2011-07-25
08:34:11 UTC (rev 22563)
@@ -60,10 +60,15 @@
final String key = String.valueOf(keys.charAt(i));
selenium.focus(input);
selenium.keyPress(input, key);
- selenium.fireEvent(input, Event.KEYDOWN);
+ selenium.fireEvent(input, Event.KEYDOWN);
}
}
+ public void type(String value) {
+ selenium.type(input, value);
+ selenium.focus(input);
+ }
+
public void confirmByKeys() {
pressEnter();
}
@@ -103,6 +108,13 @@
return selenium.getValue(input);
}
+ public void clearInputValue() {
+ selenium.type(input, "");
+ // selenium.fireEvent(input, Event.KEYUP);
+ // selenium.fireEvent(input, Event.BLUR);
+ selenium.focus(input);
+ }
+
private JQueryLocator getLabeledOption(String label) {
return labeledOption.format(label);
}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAutocomplete/TestAutocompleteVisualState.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAutocomplete/TestAutocompleteVisualState.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAutocomplete/TestAutocompleteVisualState.java 2011-07-25
08:34:11 UTC (rev 22563)
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * 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.richAutocomplete;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.utils.URLUtils;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.model.Autocomplete;
+import org.testng.annotations.Test;
+
+/**
+ * Test for keeping visual state for autocomplete on page:
+ * faces/components/richAutocomplete/autocomplete.xhtml
+ *
+ * There were some problems with
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public class TestAutocompleteVisualState extends AbstractMetamerTest {
+
+ AutocompleteReloadTester reloadTester = new AutocompleteReloadTester();
+ Autocomplete autocomplete = new Autocomplete();
+
+ @Override
+ public URL getTestUrl() {
+ return URLUtils.buildUrl(contextPath,
"faces/components/richAutocomplete/autocomplete.xhtml");
+ }
+
+
+ @Test
+ public void testRefreshFullPage() {
+ reloadTester.testFullPageRefresh();
+ }
+
+ @Test
+ public void testRerenderAll() {
+ reloadTester.testRerenderAll();
+ }
+
+ private class AutocompleteReloadTester extends ReloadTester<String> {
+
+ @Override
+ public void doRequest(String inputValue) {
+ // autocomplete.clearInputValue();
+ autocomplete.type(inputValue);
+
waitAjax.until(textEquals.locator(pjq("span[id$=:output]")).text(inputValue));
+ }
+
+ @Override
+ public void verifyResponse(String inputValue) {
+ String found = autocomplete.getInputText();
+ assertEquals(found, inputValue);
+ }
+
+ @Override
+ public String[] getInputValues() {
+ return new String[] {"not-in-list-value"};
+ }
+
+ }
+
+}