Author: lfryc(a)redhat.com
Date: 2009-12-11 05:49:49 -0500 (Fri, 11 Dec 2009)
New Revision: 16112
Modified:
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/comboBox/ComboBoxTestCase.java
branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/richfaces/integrationTest/comboBox/messages.properties
Log:
* ComboBoxTestCase
- typeKeys -> type, fireEvent
- refactored testSuggestionsFirstComboBox() - it doesn't test the selection of item by
typing only, because string 'su' stands for all of the items in comboBox; now
'suggestion 1'
Modified:
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/comboBox/ComboBoxTestCase.java
===================================================================
---
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/comboBox/ComboBoxTestCase.java 2009-12-11
09:22:08 UTC (rev 16111)
+++
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/comboBox/ComboBoxTestCase.java 2009-12-11
10:49:49 UTC (rev 16112)
@@ -27,6 +27,7 @@
import static org.testng.Assert.assertEqualsNoOrder;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.dom.Event;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -105,32 +106,39 @@
selenium.click(LOC_FIRST_COMBO_BUTTON);
waitForElement(format(LOC_FIRST_COMBO_SUGGESTIONS, 0));
int count = getJQueryCount(format(LOC_FIRST_COMBO_SUGGESTIONS,-1));
- assertEquals(count, MSG_SUGGESTIONS_FIRST_COMBO_COUNT_1, "Number of
suggestions after after clicking on button.");
+ assertEquals(count, MSG_SUGGESTIONS_FIRST_COMBO_COUNT_1, "Number of
suggestions after clicking on button.");
- selenium.click(LOC_FIRST_COMBO_INPUT);
- selenium.typeKeys(LOC_FIRST_COMBO_INPUT, "su");
- selenium.typeKeys(LOC_FIRST_COMBO_INPUT, " ");
+ // verify selecting item by mouse
+ try {
+ selenium.clickAt(format(LOC_FIRST_COMBO_SUGGESTIONS, 2), "");
+ } catch (Exception ex) {
+ // TODO: why the exception is thrown?
+ }
+ waitFor(1000);
+ String text = selenium.getValue(LOC_FIRST_COMBO_INPUT);
+ assertEquals(text, MSG_SUGGESTIONS_FIRST_COMBO_INPUT, "Third suggestion was
chosen.");
+
+ // verify filtering
+ selenium.type(LOC_FIRST_COMBO_INPUT, "suggestion ");
+ selenium.fireEvent(LOC_FIRST_COMBO_INPUT, Event.KEYUP);
count = getJQueryCount(format(LOC_FIRST_COMBO_SUGGESTIONS, -1));
- assertEquals(count, MSG_SUGGESTIONS_FIRST_COMBO_COUNT_2, "Number of
suggestions after typing 'su'.");
+ assertEquals(count, MSG_SUGGESTIONS_FIRST_COMBO_COUNT_1, "Number of
suggestions after typing 'sugestion '.");
+
+ selenium.type(LOC_FIRST_COMBO_INPUT, "suggestion 1");
+ selenium.fireEvent(LOC_FIRST_COMBO_INPUT, Event.KEYUP);
- String[] suggestions = new String[5];
- for (int i = 0; i < 5; i++) {
+ count = getJQueryCount(format(LOC_FIRST_COMBO_SUGGESTIONS, -1));
+ assertEquals(count, MSG_SUGGESTIONS_FIRST_COMBO_COUNT_2, "Number of
suggestions after typing 'suggestion 1'.");
+
+ String[] suggestions = new String[count];
+ for (int i = 0; i < count; i++) {
suggestions[i] = selenium.getText(format(LOC_FIRST_COMBO_SUGGESTIONS, i));
}
- String[] expected = new String[] { "suggestion 1", "suggestion
2", "suggestion 3", "suggestion 4", "suggestion 5", };
+ String[] expected = new String[] { "suggestion 1" };
- assertEqualsNoOrder(suggestions, expected, "Suggestions after typing
'sa'.");
-
- try {
- selenium.clickAt(format(LOC_FIRST_COMBO_SUGGESTIONS, 2), "");
- } catch (Exception ex) {
- // why the exception is thrown?
- }
- waitFor(1000);
- String text = selenium.getValue(LOC_FIRST_COMBO_INPUT);
- assertEquals(text, MSG_SUGGESTIONS_FIRST_COMBO_INPUT, "Third suggestion was
chosen.");
+ assertEqualsNoOrder(suggestions, expected, "Suggestions after typing
'suggestion 1'.");
}
/**
@@ -149,8 +157,8 @@
assertEquals(count, MSG_SUGGESTIONS_SECOND_COMBO_COUNT_1, "Number of
suggestions after after clicking on button.");
selenium.click(LOC_SECOND_COMBO_INPUT);
- selenium.typeKeys(LOC_SECOND_COMBO_INPUT, "sa");
- selenium.typeKeys(LOC_SECOND_COMBO_INPUT, " ");
+ selenium.type(LOC_SECOND_COMBO_INPUT, "sa");
+ selenium.fireEvent(LOC_SECOND_COMBO_INPUT, Event.KEYUP);
count = getJQueryCount(format(LOC_SECOND_COMBO_SUGGESTIONS, -1));
assertEquals(count, MSG_SUGGESTIONS_SECOND_COMBO_COUNT_2, "Number of
suggestions after typing 'sa'.");
@@ -167,7 +175,7 @@
try {
selenium.clickAt(format(LOC_SECOND_COMBO_SUGGESTIONS, 2), "");
} catch (Exception ex) {
- // why the exception is thrown?
+ // TODO: why the exception is thrown?
}
waitFor(1000);
@@ -190,8 +198,8 @@
assertEquals(count, MSG_SUGGESTIONS_THIRD_COMBO_COUNT_1, "Number of
suggestions after after clicking on button.");
selenium.click(LOC_THIRD_COMBO_INPUT);
- selenium.typeKeys(LOC_THIRD_COMBO_INPUT, "sa");
- selenium.typeKeys(LOC_THIRD_COMBO_INPUT, " ");
+ selenium.type(LOC_THIRD_COMBO_INPUT, "sa");
+ selenium.fireEvent(LOC_THIRD_COMBO_INPUT, Event.KEYUP);
count = getJQueryCount(format(LOC_THIRD_COMBO_SUGGESTIONS, -1));
assertEquals(count, MSG_SUGGESTIONS_THIRD_COMBO_COUNT_2, "Number of
suggestions after typing 'sa'.");
@@ -208,7 +216,7 @@
try {
selenium.clickAt(format(LOC_THIRD_COMBO_SUGGESTIONS, 3), "");
} catch (Exception ex) {
- // why the exception is thrown?
+ // TODO: why the exception is thrown?
}
waitFor(1000);
Modified:
branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/richfaces/integrationTest/comboBox/messages.properties
===================================================================
---
branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/richfaces/integrationTest/comboBox/messages.properties 2009-12-11
09:22:08 UTC (rev 16111)
+++
branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/richfaces/integrationTest/comboBox/messages.properties 2009-12-11
10:49:49 UTC (rev 16112)
@@ -3,7 +3,7 @@
INITIAL_STATE_INITIAL_VALUE_3=Enter some value
SUGGESTIONS_FIRST_COMBO_COUNT_1=5
-SUGGESTIONS_FIRST_COMBO_COUNT_2=5
+SUGGESTIONS_FIRST_COMBO_COUNT_2=1
SUGGESTIONS_FIRST_COMBO_INPUT=suggestion 3
SUGGESTIONS_SECOND_COMBO_COUNT_1=50