Author: jpapouse
Date: 2012-01-04 10:19:57 -0500 (Wed, 04 Jan 2012)
New Revision: 23126
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/AbstractRichHotKeyTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/HotKeyAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/TestRichHotKey.java
Modified:
modules/tests/metamer/trunk/ftest/src/test/resources/testng-misc.xml
Log:
tests for rich:hotKey
Modified: modules/tests/metamer/trunk/ftest/src/test/resources/testng-misc.xml
===================================================================
--- modules/tests/metamer/trunk/ftest/src/test/resources/testng-misc.xml 2012-01-04
14:35:01 UTC (rev 23125)
+++ modules/tests/metamer/trunk/ftest/src/test/resources/testng-misc.xml 2012-01-04
15:19:57 UTC (rev 23126)
@@ -16,6 +16,7 @@
<package name="org.richfaces.tests.metamer.ftest.richFunctions"
/>
<package
name="org.richfaces.tests.metamer.ftest.richGraphValidator" />
<package name="org.richfaces.tests.metamer.ftest.richHashParam"
/>
+ <package name="org.richfaces.tests.metamer.ftest.richHotKey"
/>
<package name="org.richfaces.tests.metamer.ftest.richJQuery"
/>
<package name="org.richfaces.tests.metamer.ftest.richMenuGroup"
/>
<package name="org.richfaces.tests.metamer.ftest.richMenuItem"
/>
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/AbstractRichHotKeyTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/AbstractRichHotKeyTest.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/AbstractRichHotKeyTest.java 2012-01-04
15:19:57 UTC (rev 23126)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2012s, 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.richHotKey;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.utils.URLUtils;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.attributes.Attributes;
+
+/**
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public abstract class AbstractRichHotKeyTest extends AbstractMetamerTest {
+
+ @Override
+ public URL getTestUrl() {
+ return URLUtils.buildUrl(contextPath,
"faces/components/richHotKey/simple.xhtml");
+ }
+
+ protected static final Attributes<HotKeyAttributes> ATTRIBUTES_FIRST = new
Attributes<HotKeyAttributes>(pjq("table.attributes[id$=attributes1]"));
+
+ protected static final Attributes<HotKeyAttributes> ATTRIBUTES_SECOND = new
Attributes<HotKeyAttributes>(pjq("table.attributes[id$=attributes2]"));
+
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/HotKeyAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/HotKeyAttributes.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/HotKeyAttributes.java 2012-01-04
15:19:57 UTC (rev 23126)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.richHotKey;
+
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
+
+/**
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public enum HotKeyAttributes implements AttributeEnum {
+
+ enabledInInput,
+ key,
+ rendered,
+ selector,
+ type
+
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/TestRichHotKey.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/TestRichHotKey.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/TestRichHotKey.java 2012-01-04
15:19:57 UTC (rev 23126)
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2012, 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.richHotKey;
+
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+
+import java.awt.event.KeyEvent;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.waiting.NegationCondition;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class TestRichHotKey extends AbstractRichHotKeyTest {
+
+ private static final int NUMBER_OF_TESTS = 5;
+
+ private final JQueryLocator clearButton = pjq("button.rf-log-element");
+ private final JQueryLocator firstInput = pjq("input[id$=firstInput]");
+ private final String hotKeyEeventLocator =
"span.rf-log-entry-msg-info:contains({0})";
+
+ @Test
+ public void testFirstAndSecondPair() {
+ for (int i=1; i<=NUMBER_OF_TESTS; i++) {
+ for (int j=0; j<i; j++) {
+ selenium.keyPressNative(String.valueOf(KeyEvent.VK_CONTROL));
+ selenium.keyPressNative(String.valueOf(KeyEvent.VK_X));
+ selenium.keyDownNative(String.valueOf(KeyEvent.VK_CONTROL));
+ selenium.keyPressNative(String.valueOf(KeyEvent.VK_X));
+ selenium.keyUpNative(String.valueOf(KeyEvent.VK_CONTROL));
+ selenium.keyPressNative(String.valueOf(KeyEvent.VK_ALT));
+ selenium.keyPressNative(String.valueOf(KeyEvent.VK_X));
+ selenium.keyDownNative(String.valueOf(KeyEvent.VK_ALT));
+ selenium.keyPressNative(String.valueOf(KeyEvent.VK_X));
+ selenium.keyUpNative(String.valueOf(KeyEvent.VK_ALT));
+ }
+ checkEvent("hotkey 1", i);
+ checkEvent("hotkey 2", i);
+ checkEvent("''", 2 * i);
+ clearHotKeyEvents();
+ }
+ }
+
+ @Test
+ public void testFirstOne() {
+ ATTRIBUTES_FIRST.set(HotKeyAttributes.key, "x");
+ selenium.focus(firstInput);
+ for (int i=1; i<=NUMBER_OF_TESTS; i++) {
+ for (int j=0; j<i; j++) {
+ selenium.keyPressNative(String.valueOf(KeyEvent.VK_X));
+ selenium.keyPressNative(String.valueOf(KeyEvent.VK_A));
+ }
+ checkEvent("hotkey 1", i);
+ checkEvent("''", i);
+ clearHotKeyEvents();
+ }
+ }
+
+ @Test
+ public void testFirstPair() {
+ testPair(KeyEvent.VK_CONTROL, KeyEvent.VK_X, "hotkey 1");
+ }
+
+ @Test
+ public void testSecondPair() {
+ testPair(KeyEvent.VK_ALT, KeyEvent.VK_X, "hotkey 2");
+ }
+
+ private void checkEvent(String text, int number) {
+ waitGui
+ .failWith("The number of hotkey events doesn't match. Found
<" + selenium.getCount(pjq(format(hotKeyEeventLocator, text))) + ">,
expected <" + number + ">.")
+ .until(countEquals.locator(pjq(format(hotKeyEeventLocator,
text))).count(number));
+ }
+
+ private void clearHotKeyEvents() {
+ selenium.click(clearButton);
+
waitGui.until(NegationCondition.getInstance().condition(elementPresent.locator(pjq(format(hotKeyEeventLocator,
"''")))));
+ }
+
+ private void testPair(int firstKey, int secondKey, String text) {
+ selenium.focus(firstInput);
+ for (int i=1; i<=NUMBER_OF_TESTS; i++) {
+ for (int j=0; j<i; j++) {
+ selenium.keyPressNative(String.valueOf(firstKey));
+ selenium.keyPressNative(String.valueOf(secondKey));
+ selenium.keyDownNative(String.valueOf(firstKey));
+ selenium.keyPressNative(String.valueOf(secondKey));
+ selenium.keyUpNative(String.valueOf(firstKey));
+ }
+ checkEvent(text, i);
+ checkEvent("''", i);
+ clearHotKeyEvents();
+ }
+ }
+
+}