Author: konstantin.mishin
Date: 2009-03-09 12:22:36 -0400 (Mon, 09 Mar 2009)
New Revision: 12892
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/HotKeyBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/hotKey/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/hotKey/hotKey.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/HotKeyTest.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
Log:
RF-6288
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/HotKeyBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/HotKeyBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/HotKeyBean.java 2009-03-09
16:22:36 UTC (rev 12892)
@@ -0,0 +1,18 @@
+package org.ajax4jsf.bean;
+
+public class HotKeyBean {
+
+ private String key;
+
+ public void init() {
+ key = null;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getKey() {
+ return key;
+ }
+}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-03-09
14:33:16 UTC (rev 12891)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-03-09
16:22:36 UTC (rev 12892)
@@ -186,6 +186,11 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
+ <managed-bean-name>hotKey</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.HotKeyBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>sliderBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.InputNumberSliderBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/hotKey/hotKey.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/hotKey/hotKey.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/hotKey/hotKey.xhtml 2009-03-09
16:22:36 UTC (rev 12892)
@@ -0,0 +1,23 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.template}">
+ <ui:define name="component">
+ <h:form id="attrForm">
+ <h:outputText value="key" />
+ <h:inputText id="key" value="#{hotKey.key}">
+ <a4j:support event="onchange" reRender="panelGroup"/>
+ </h:inputText>
+ </h:form>
+ <h:panelGroup id="panelGroup">
+ <rich:hotKey key="#{hotKey.key}"
handler="document.getElementById('input').value =
'#{hotKey.key}'"/>
+ <input id="input" />
+ </h:panelGroup>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/HotKeyTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/HotKeyTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/HotKeyTest.java 2009-03-09
16:22:36 UTC (rev 12892)
@@ -0,0 +1,97 @@
+package org.richfaces.testng;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class HotKeyTest extends SeleniumTestBase {
+
+ private String key;
+
+ private String input;
+
+ private void init(Template template) {
+ renderPage(null, template, "#{dataList.init}");
+ String attrForm = getParentId() + "attrForm";
+ key = attrForm + ":key";
+ input = "input";
+ }
+
+ /**
+ * Create hotKey component with timing="immediate"
+ * (or "onload")attribute and check that it works -
+ * alpha/numeric/arrows/special(ins/del/pgup/pgdn/home/end)/enter/esc keys
+ */
+ @Test
+ public void testKeyAttribute(Template template) {
+ init(template);
+
+ String keySequence = "alt+a";
+ selenium.type(key, keySequence);
+ waitForAjaxCompletion();
+ selenium.altKeyDown();
+ selenium.keyDown(input, "a");
+ selenium.altKeyUp();
+ Assert.assertEquals(selenium.getValue(input), keySequence);
+
+ keySequence = "ctrl+1";
+ selenium.type(key, keySequence);
+ waitForAjaxCompletion();
+ selenium.controlKeyDown();
+ selenium.keyDown(input, "1");
+ selenium.controlKeyUp();
+ Assert.assertEquals(selenium.getValue(input), keySequence);
+
+ keySequence = "shift+down";
+ selenium.type(key, keySequence);
+ waitForAjaxCompletion();
+ selenium.shiftKeyDown();
+ selenium.keyDown(input, "\\40");
+ selenium.shiftKeyUp();
+ Assert.assertEquals(selenium.getValue(input), keySequence);
+
+ keySequence = "insert";
+ selenium.type(key, keySequence);
+ waitForAjaxCompletion();
+ selenium.keyDown(input, "\\45");
+ Assert.assertEquals(selenium.getValue(input), keySequence);
+
+ keySequence = "del";
+ selenium.type(key, keySequence);
+ waitForAjaxCompletion();
+ selenium.keyDown(input, "\\46");
+ Assert.assertEquals(selenium.getValue(input), keySequence);
+
+ keySequence = "pageup";
+ selenium.type(key, keySequence);
+ waitForAjaxCompletion();
+ selenium.keyDown(input, "\\33");
+ Assert.assertEquals(selenium.getValue(input), keySequence);
+
+ keySequence = "end";
+ selenium.type(key, keySequence);
+ waitForAjaxCompletion();
+ selenium.keyDown(input, "\\35");
+ Assert.assertEquals(selenium.getValue(input), keySequence);
+
+ keySequence = "return";
+ selenium.type(key, keySequence);
+ waitForAjaxCompletion();
+ selenium.keyDown(input, "\\13");
+ Assert.assertEquals(selenium.getValue(input), keySequence);
+
+ keySequence = "esc";
+ selenium.type(key, keySequence);
+ waitForAjaxCompletion();
+ selenium.keyDown(input, "\\27");
+ Assert.assertEquals(selenium.getValue(input), keySequence);
+
+ }
+
+ @Override
+ public String getTestUrl() {
+ return "pages/hotKey/hotKey.xhtml";
+ }
+
+}