Author: dsvyatobatsko
Date: 2009-03-31 13:56:01 -0400 (Tue, 31 Mar 2009)
New Revision: 13323
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/suggestionBox/suggestionBoxAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/SuggestionBoxTest.java
Log:
https://jira.jboss.org/jira/browse/RF-6237 completed
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/suggestionBox/suggestionBoxAutoTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-03-31
17:34:46 UTC (rev 13322)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-03-31
17:56:01 UTC (rev 13323)
@@ -993,6 +993,7 @@
}
/**
+ * Simulates keystroke events on the specified element, as though you typed the value
key-by-key.
* Workaround for selenium.type/selenium.typeKeys
* @param locator
* @param string
@@ -1016,7 +1017,31 @@
}
}
-
+
+ /**
+ * This method differs from <code>type</code> method in only that
<code>type</code> erases previous typing as though you are typing over it,
+ * while <code>typeOn</code> doesn't (go on typing)
+ * @param locator an element locator
+ * @param string the value to type
+ */
+ public void typeOn(String locator, String string) {
+ StringBuffer value = new StringBuffer(selenium.getValue(locator));
+ char[] chars = string.toCharArray();
+ for (int i = 0; i < chars.length; i++) {
+ String key = Character.toString(chars[i]);
+ value.append(key);
+
+ selenium.keyDown(locator, key);
+
+ if(!isFF()) {
+ selenium.type(locator, value.toString());
+ }
+
+ selenium.keyPress(locator, key);
+ selenium.keyUp(locator, key);
+ }
+ }
+
public void testOnclickEvent(String testElementId, String testElementResultId, String
beforeResult, String afterResult) {
writeStatus("Testing onclick event");
AssertTextEquals(testElementResultId, beforeResult);
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/SuggestionBoxTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/SuggestionBoxTest.java 2009-03-31
17:34:46 UTC (rev 13322)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/SuggestionBoxTest.java 2009-03-31
17:56:01 UTC (rev 13323)
@@ -243,16 +243,19 @@
waitForAjaxCompletion();
selenium.keyDown(inputId, "\\13");//enter
AssertValueEquals(inputId, "Belarus");
+ assertSelectedCapitals("Minsk");
type(inputId, "Belarus,Arm");
waitForAjaxCompletion();
selenium.keyDown(inputId, "\\13");//enter
AssertValueEquals(inputId, "Belarus,Armenia");
+ assertSelectedCapitals("Minsk", "Yerevan");
type(inputId, "Belarus[Rus");
waitForAjaxCompletion();
selenium.keyDown(inputId, "\\13");//enter
AssertValueEquals(inputId, "Belarus[Russia");
+ assertSelectedCapitals("Minsk", "Moscow");
writeStatus("@ is not supported token");
type(inputId, "Belarus@Kaz");
@@ -261,6 +264,81 @@
AssertValueEquals(inputId, "Belarus@Kaz");
}
+ @Test
+ public void testSuggestionObjectFeature(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ writeStatus("Check suggestion object feature works");
+ String inputId = tester.getClientId("suggestion");
+ typeOn(inputId, "Bel");
+ waitForAjaxCompletion();
+ selenium.keyDown(inputId, "\\13");//enter
+ assertSelectedCapitals("Minsk");
+ typeOn(inputId, ",Kaz");
+ waitForAjaxCompletion();
+ selenium.keyDown(inputId, "\\13");//enter
+ assertSelectedCapitals("Minsk", "Astana");
+ typeOn(inputId, ",Arm");
+ waitForAjaxCompletion();
+ selenium.keyDown(inputId, "\\13");//enter
+ assertSelectedCapitals("Minsk", "Astana",
"Yerevan");
+ }
+
+ @Test
+ public void testCore(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+
+ writeStatus("Check component is activated by user-defined events");
+ writeStatus("Check list of options is fetched from server and shown");
+ writeStatus("arbitrary option can be selected");
+
+ String suggestInputId = tester.getClientId("suggestion");
+ String suggestPopupId = tester.getClientId(AutoTester.COMPONENT_ID +
":suggest");
+
+ writeStatus("Check component is activated");
+ type(suggestInputId, "stan");
+ waitForAjaxCompletion();
+ AssertVisible(suggestPopupId, "Suggestion popup is not come up");
+
+ writeStatus("Check list of options is fetched from server and shown");
+ //5 + nothingLabel row
+ Assert.assertEquals(6, selenium.getXpathCount("//table[@id='" +
suggestPopupId + "']/tbody/tr"));
+
+ writeStatus("Check arbitrary option can be selected");
+ writeStatus("Try to select second item: Kyrgyzstan (Bishkek)");
+ selenium.click("//table[@id='" + suggestPopupId +
"']/tbody/tr[2]");
+ AssertValueEquals(suggestInputId, "Kyrgyzstan");
+ assertSelectedCapitals("Bishkek");
+ }
+
+ @Test
+ public void testMultiColumnPossibility(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ writeStatus("Check multi-column display is possible using var
attribute");
+
+ String suggestInputId = tester.getClientId("suggestion");
+ String suggestPopupId = tester.getClientId(AutoTester.COMPONENT_ID +
":suggest");
+ String firstOptionXpath = "//table[@id='" + suggestPopupId +
"']/tbody/tr[1]/td";
+ type(suggestInputId, "Bel");
+ waitForAjaxCompletion();
+ writeStatus("Check option's columns are rendered properly");
+ Assert.assertFalse(isVisible(firstOptionXpath + "[1]"));
+ AssertTextEquals(firstOptionXpath + "[2]", "Belarus");
+ AssertTextEquals(firstOptionXpath + "[3]", "Minsk");
+ AssertTextEquals(firstOptionXpath + "[4]", "207600.0");
+ AssertTextEquals(firstOptionXpath + "[5]", "9689800");
+ }
+
+ private void assertSelectedCapitals(String... capitals) {
+ String liXpath = "//*[@id='suggestionObject']/ul/li";
+ Assert.assertEquals(capitals.length,
selenium.getXpathCount(liXpath).intValue());
+ for (int i = 0; i < capitals.length; i++) {
+ AssertTextEquals(liXpath + "[" + (i + 1) + "]",
capitals[i]);
+ }
+ }
+
@Override
public void sendAjax() {
type(getAutoTester(this).getClientId("suggestion"), "Bel");
@@ -275,7 +353,7 @@
@Override
public String getTestUrl() {
- return null;
+ throw new UnsupportedOperationException();
}
}