Author: jpapouse
Date: 2012-01-10 05:57:10 -0500 (Tue, 10 Jan 2012)
New Revision: 23137
Modified:
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/TestRichHotKeyAttributes.java
Log:
test for @preventDefault attribute (rich:hotKey)
Modified:
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 2012-01-10
10:16:49 UTC (rev 23136)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/HotKeyAttributes.java 2012-01-10
10:57:10 UTC (rev 23137)
@@ -32,6 +32,7 @@
key,
onkeydown,
onkeyup,
+ preventDefault,
rendered,
selector
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/TestRichHotKeyAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/TestRichHotKeyAttributes.java 2012-01-10
10:16:49 UTC (rev 23136)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richHotKey/TestRichHotKeyAttributes.java 2012-01-10
10:57:10 UTC (rev 23137)
@@ -26,6 +26,7 @@
import java.awt.event.KeyEvent;
import java.util.List;
+import org.jboss.test.selenium.encapsulated.FrameLocator;
import org.testng.annotations.Test;
@@ -58,8 +59,25 @@
assertEquals(events.get(0), "hotkey 1 : onkeydown");
assertEquals(events.get(1), "hotkey 1 : onkeyup");
}
+
+ @Test
+ public void testPreventDefaultFalse() {
+ ATTRIBUTES_FIRST.set(HotKeyAttributes.preventDefault, false);
+ try {
+ testKeyForPreventDefault(KeyEvent.VK_CONTROL, KeyEvent.VK_F,
"ctrl+f", 1);
+ } finally {
+ selenium.keyPressNative(String.valueOf(KeyEvent.VK_ESCAPE));
+ }
+ }
@Test
+ public void testPreventDefaultTrue() {
+ testKeyForPreventDefault(KeyEvent.VK_CONTROL, KeyEvent.VK_F, "ctrl+f",
2);
+ testKeyForPreventDefault(KeyEvent.VK_CONTROL, KeyEvent.VK_H, "ctrl+h",
2);
+ testKeyForPreventDefault(KeyEvent.VK_CONTROL, KeyEvent.VK_U, "ctrl+u",
2);
+ }
+
+ @Test
public void testRendered() {
ATTRIBUTES_FIRST.set(HotKeyAttributes.rendered, false);
ATTRIBUTES_FIRST.set(HotKeyAttributes.key, "x");
@@ -81,4 +99,14 @@
checkEvent("hotkey 1", 2);
}
+ private void testKeyForPreventDefault(int firstKey, int secondKey, String keyString,
int expectedNum) {
+ clearHotKeyEvents();
+ ATTRIBUTES_FIRST.set(HotKeyAttributes.key, keyString);
+ selenium.keyDownNative(String.valueOf(firstKey));
+ selenium.keyPressNative(String.valueOf(secondKey));
+ selenium.keyPressNative(String.valueOf(secondKey));
+ selenium.keyUpNative(String.valueOf(firstKey));
+ checkEvent("onkeydown", expectedNum);
+ }
+
}
Show replies by date