Author: ppitonak(a)redhat.com
Date: 2009-09-15 08:59:18 -0400 (Tue, 15 Sep 2009)
New Revision: 15578
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelMenu/PanelMenuTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/pickList/PickListTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/suggestionBox/SuggestionBoxTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/toolBar/ToolBarTestCase.java
Log:
* test cases refactored to provide more stable results
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelMenu/PanelMenuTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelMenu/PanelMenuTestCase.java 2009-09-15
12:33:45 UTC (rev 15577)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/panelMenu/PanelMenuTestCase.java 2009-09-15
12:59:18 UTC (rev 15578)
@@ -27,6 +27,8 @@
import static org.testng.Assert.assertTrue;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.waiting.Condition;
+import org.jboss.test.selenium.waiting.Wait;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -165,10 +167,19 @@
// check items on the first level (1.1, 1.2, etc.)
for (int i = 1; i < 4; i++) {
- selenium.click(format(LOC_GROUP_N_TEXT, i));
- for (int j = 1; j < 4; j++) {
- selenium.click(format(LOC_ITEM_M_N_TEXT, i, j));
- waitFor(500); // it use Ajax mode
+ final int newI = i;
+ selenium.click(format(LOC_GROUP_N_TEXT, i));
+
+ for (int j = 1; j < 4; j++) {
+ final int newJ = j;
+ selenium.click(format(LOC_ITEM_M_N_TEXT, i, j));
+
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return format("Item {0}.{1} selected", newI,
newJ).equals(selenium.getText(LOC_PANEL));
+ }
+ });
+
text = selenium.getText(LOC_PANEL);
assertEquals(text, format("Item {0}.{1} selected", i, j),
MSG_CONTENT_OF_PANEL);
}
@@ -177,9 +188,16 @@
// check items on the second level (2.4.1, 2.4.2, 2.4.3)
selenium.click(format(LOC_ITEM_M_N_TEXT, 2, 4));
for (int i = 1; i < 4; i++) {
- selenium.click(format(LOC_SUBITEM_M_TEXT, i));
- waitFor(500); // it use Ajax mode
- text = selenium.getText(LOC_PANEL);
+ final int newI = i;
+ selenium.click(format(LOC_SUBITEM_M_TEXT, i));
+
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return format("Item 2.4.{0} selected",
newI).equals(selenium.getText(LOC_PANEL));
+ }
+ });
+
+ text = selenium.getText(LOC_PANEL);
assertEquals(text, format("Item 2.4.{0} selected", i),
MSG_CONTENT_OF_PANEL);
}
}
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/pickList/PickListTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/pickList/PickListTestCase.java 2009-09-15
12:33:45 UTC (rev 15577)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/pickList/PickListTestCase.java 2009-09-15
12:59:18 UTC (rev 15578)
@@ -26,6 +26,8 @@
import static org.testng.Assert.assertTrue;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.waiting.Condition;
+import org.jboss.test.selenium.waiting.Wait;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -87,13 +89,16 @@
public void testFirstCopySingleItem() {
scrollIntoView(LOC_FIRST_EXAMPLE_HEADER, true);
- int count = selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue();
+ final int count = selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue();
selenium.click(LOC_FIRST_LEFT_FIRST_ITEM);
selenium.click(LOC_FIRST_BUTTON_COPY);
- int newCount = selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue();
- assertEquals(newCount, count - 1, "There should be less lines in the left
table.");
+ Wait.failWith("There should be less lines in the left
table.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue() == count
-1;
+ }
+ });
}
// @Test
@@ -113,15 +118,18 @@
public void testFirstCopyAll() {
scrollIntoView(LOC_FIRST_EXAMPLE_HEADER, true);
- int count = selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue();
+ final int count = selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue();
selenium.click(LOC_FIRST_BUTTON_COPY_ALL);
+ Wait.failWith("All items from left table should be now in the right
table.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getXpathCount(LOC_FIRST_RIGHT_ITEMS).intValue() ==
count;
+ }
+ });
+
int newCount = selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue();
assertEquals(newCount, 0, "There should be no lines in the left
table.");
-
- newCount = selenium.getXpathCount(LOC_FIRST_RIGHT_ITEMS).intValue();
- assertEquals(newCount, count, "All items from left table should be now in
the right table.");
}
/**
@@ -133,13 +141,16 @@
selenium.click(LOC_FIRST_BUTTON_COPY_ALL);
- int count = selenium.getXpathCount(LOC_FIRST_RIGHT_ITEMS).intValue();
+ final int count = selenium.getXpathCount(LOC_FIRST_RIGHT_ITEMS).intValue();
selenium.click(LOC_FIRST_RIGHT_FIRST_ITEM);
selenium.click(LOC_FIRST_BUTTON_REMOVE);
- int newCount = selenium.getXpathCount(LOC_FIRST_RIGHT_ITEMS).intValue();
- assertEquals(newCount, count - 1, "There should be less lines in the right
table.");
+ Wait.failWith("There should be less lines in the right
table.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getXpathCount(LOC_FIRST_RIGHT_ITEMS).intValue() == count
- 1;
+ }
+ });
}
// @Test
@@ -159,15 +170,18 @@
public void testFirstRemoveAll() {
scrollIntoView(LOC_FIRST_EXAMPLE_HEADER, true);
- int count = selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue();
+ final int count = selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue();
selenium.click(LOC_FIRST_BUTTON_COPY_ALL);
selenium.click(LOC_FIRST_BUTTON_REMOVE_ALL);
- int newCount = selenium.getXpathCount(LOC_FIRST_RIGHT_ITEMS).intValue();
- assertEquals(newCount, 0, "There should be no lines in the right
table.");
-
- newCount = selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue();
+ Wait.failWith("There should be no lines in the right table.").until(new
Condition() {
+ public boolean isTrue() {
+ return selenium.getXpathCount(LOC_FIRST_RIGHT_ITEMS).intValue() == 0;
+ }
+ });
+
+ int newCount = selenium.getXpathCount(LOC_FIRST_LEFT_ITEMS).intValue();
assertEquals(newCount, count, "All items from right table should be now in
the left table.");
}
@@ -200,12 +214,15 @@
selenium.click(LOC_SECOND_LEFT_FIRST_ITEM);
selenium.click(LOC_SECOND_BUTTON_COPY);
+ Wait.failWith("There should be only one capital city.").until(new
Condition() {
+ public boolean isTrue() {
+ return selenium.getXpathCount(LOC_SECOND_CHOSEN_OPTIONS_LI).intValue() ==
1;
+ }
+ });
+
int newCount = selenium.getXpathCount(LOC_SECOND_LEFT_ITEMS).intValue();
assertEquals(newCount, count - 1, "There should be less lines in the left
table.");
- count = selenium.getXpathCount(LOC_SECOND_CHOSEN_OPTIONS_LI).intValue();
- assertEquals(count, 1, "There should be only one capital city.");
-
String capital = selenium.getText(LOC_SECOND_CHOSEN_OPTIONS_LI1);
assertEquals(capital, "Montgomery", "Capital of Alaska.");
}
@@ -227,10 +244,16 @@
public void testSecondCopyAll() {
scrollIntoView(LOC_SECOND_EXAMPLE_HEADER, true);
- int count = selenium.getXpathCount(LOC_SECOND_LEFT_ITEMS).intValue();
+ final int count = selenium.getXpathCount(LOC_SECOND_LEFT_ITEMS).intValue();
selenium.click(LOC_SECOND_BUTTON_COPY_ALL);
+ Wait.failWith("Not all capital cities were displayed in the
panel.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getXpathCount(LOC_SECOND_CHOSEN_OPTIONS_LI).intValue() ==
count;
+ }
+ });
+
int newCount = selenium.getXpathCount(LOC_SECOND_LEFT_ITEMS).intValue();
assertEquals(newCount, 0, "There should be no lines in the left
table.");
@@ -250,11 +273,17 @@
selenium.click(LOC_SECOND_BUTTON_COPY_ALL);
- int count = selenium.getXpathCount(LOC_SECOND_RIGHT_ITEMS).intValue();
+ final int count = selenium.getXpathCount(LOC_SECOND_RIGHT_ITEMS).intValue();
selenium.click(LOC_SECOND_RIGHT_FIRST_ITEM);
selenium.click(LOC_SECOND_BUTTON_REMOVE);
+ Wait.failWith("The capital city was not removed from panel.").until(new
Condition() {
+ public boolean isTrue() {
+ return selenium.getXpathCount(LOC_SECOND_CHOSEN_OPTIONS_LI).intValue() ==
count - 1;
+ }
+ });
+
int newCount = selenium.getXpathCount(LOC_SECOND_RIGHT_ITEMS).intValue();
assertEquals(newCount, count - 1, "There should be less lines in the right
table.");
@@ -284,14 +313,17 @@
selenium.click(LOC_SECOND_BUTTON_COPY_ALL);
selenium.click(LOC_SECOND_BUTTON_REMOVE_ALL);
+ Wait.failWith("All capitals from the panel should be
removed.").until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getXpathCount(LOC_SECOND_CHOSEN_OPTIONS_LI).intValue() ==
0;
+ }
+ });
+
int newCount = selenium.getXpathCount(LOC_SECOND_RIGHT_ITEMS).intValue();
assertEquals(newCount, 0, "There should be no lines in the right
table.");
newCount = selenium.getXpathCount(LOC_SECOND_LEFT_ITEMS).intValue();
assertEquals(newCount, count, "All items from right table should be now in
the left table.");
-
- count = selenium.getXpathCount(LOC_SECOND_CHOSEN_OPTIONS_LI).intValue();
- assertEquals(count, 0, "All capitals from the panel should be
removed.");
}
/**
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/suggestionBox/SuggestionBoxTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/suggestionBox/SuggestionBoxTestCase.java 2009-09-15
12:33:45 UTC (rev 15577)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/suggestionBox/SuggestionBoxTestCase.java 2009-09-15
12:59:18 UTC (rev 15578)
@@ -25,6 +25,8 @@
import static org.testng.Assert.assertEquals;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
+import org.jboss.test.selenium.waiting.Condition;
+import org.jboss.test.selenium.waiting.Wait;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -189,17 +191,32 @@
scrollIntoView(LOC_FIRST_INPUT, true);
selenium.type(LOC_FIRST_BORDER_INPUT, "3");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_BORDER_STYLE, "border-width") == 3;
+ }
+ });
+
int width = getValue(LOC_FIRST_BORDER_STYLE, "border-width");
assertEquals(width, 3, format(MSG_SUGGESTION_BOX_BORDER_PREFORMATTED, 3));
selenium.type(LOC_FIRST_BORDER_INPUT, "5");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_BORDER_STYLE, "border-width") == 5;
+ }
+ });
+
width = getValue(LOC_FIRST_BORDER_STYLE, "border-width");
assertEquals(width, 5, format(MSG_SUGGESTION_BOX_BORDER_PREFORMATTED, 5));
selenium.type(LOC_FIRST_BORDER_INPUT, "7"); // 7 -> 5
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_BORDER_STYLE, "border-width") == 5;
+ }
+ });
+
width = getValue(LOC_FIRST_BORDER_STYLE, "border-width");
assertEquals(width, 5, format(MSG_SUGGESTION_BOX_BORDER_PREFORMATTED, 7));
}
@@ -212,22 +229,42 @@
scrollIntoView(LOC_FIRST_INPUT, true);
selenium.type(LOC_FIRST_WIDTH_INPUT, "150");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_WIDTH_STYLE, "width") == 150;
+ }
+ });
+
int width = getValue(LOC_FIRST_WIDTH_STYLE, "width");
assertEquals(width, 150, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMATTED, 150));
selenium.type(LOC_FIRST_WIDTH_INPUT, "350");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_WIDTH_STYLE, "width") == 350;
+ }
+ });
+
width = getValue(LOC_FIRST_WIDTH_STYLE, "width");
assertEquals(width, 350, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMATTED, 350));
selenium.type(LOC_FIRST_WIDTH_INPUT, "400"); // 400 -> 350
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_WIDTH_STYLE, "width") == 350;
+ }
+ });
+
width = getValue(LOC_FIRST_WIDTH_STYLE, "width");
assertEquals(width, 350, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMATTED, 400));
selenium.type(LOC_FIRST_WIDTH_INPUT, "176"); // 176 -> 200
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_WIDTH_STYLE, "width") == 200;
+ }
+ });
+
width = getValue(LOC_FIRST_WIDTH_STYLE, "width");
assertEquals(width, 200, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMATTED, 176));
}
@@ -240,22 +277,42 @@
scrollIntoView(LOC_FIRST_INPUT, true);
selenium.type(LOC_FIRST_HEIGHT_INPUT, "100");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_HEIGHT_STYLE, "height") == 100;
+ }
+ });
+
int height = getValue(LOC_FIRST_HEIGHT_STYLE, "height");
assertEquals(height, 100, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORMATTED, 100));
selenium.type(LOC_FIRST_HEIGHT_INPUT, "300");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_HEIGHT_STYLE, "height") == 300;
+ }
+ });
+
height = getValue(LOC_FIRST_HEIGHT_STYLE, "height");
assertEquals(height, 300, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORMATTED, 300));
selenium.type(LOC_FIRST_HEIGHT_INPUT, "400"); // 400 -> 300
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_HEIGHT_STYLE, "height") == 300;
+ }
+ });
+
height = getValue(LOC_FIRST_HEIGHT_STYLE, "height");
assertEquals(height, 300, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORMATTED, 400));
selenium.type(LOC_FIRST_HEIGHT_INPUT, "176"); // 176 -> 200
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_HEIGHT_STYLE, "height") == 200;
+ }
+ });
+
height = getValue(LOC_FIRST_HEIGHT_STYLE, "height");
assertEquals(height, 200, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORMATTED, 176));
}
@@ -269,28 +326,48 @@
scrollIntoView(LOC_FIRST_INPUT, true);
selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "3");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") == 3;
+ }
+ });
+
int top = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top");
assertEquals(top, 3, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 3));
int left = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left");
assertEquals(left, 3, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 3));
selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "5");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") == 5;
+ }
+ });
+
top = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top");
assertEquals(top, 5, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 5));
left = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left");
assertEquals(left, 5, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 5));
selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "6");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") == 6;
+ }
+ });
+
top = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top");
assertEquals(top, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 6));
left = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left");
assertEquals(left, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 6));
selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "7"); // 7 -> 6
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") == 6;
+ }
+ });
+
top = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top");
assertEquals(top, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, 7));
left = getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left");
@@ -305,22 +382,42 @@
scrollIntoView(LOC_FIRST_INPUT, true);
selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "1");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) == 0.1;
+ }
+ });
+
double opacity = getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE);
assertEquals(opacity, 0.1, format(MSG_SUGGESTION_BOX_SHADOW_OPACITY_PREFORMATTED,
1));
selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "5");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) == 0.5;
+ }
+ });
+
opacity = getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE);
assertEquals(opacity, 0.5, format(MSG_SUGGESTION_BOX_SHADOW_OPACITY_PREFORMATTED,
5));
selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "9");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) == 0.9;
+ }
+ });
+
opacity = getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE);
assertEquals(opacity, 0.9, format(MSG_SUGGESTION_BOX_SHADOW_OPACITY_PREFORMATTED,
9));
selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "11"); // 11 -> 9
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) == 0.9;
+ }
+ });
+
opacity = getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE);
assertEquals(opacity, 0.9, format(MSG_SUGGESTION_BOX_SHADOW_OPACITY_PREFORMATTED,
11));
}
@@ -333,22 +430,42 @@
scrollIntoView(LOC_FIRST_INPUT, true);
selenium.type(LOC_FIRST_CELLPADDING_INPUT, "1");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return Integer.parseInt(selenium.getAttribute(LOC_FIRST_CELLPADDING)) ==
1;
+ }
+ });
+
int cellpadding =
Integer.parseInt(selenium.getAttribute(LOC_FIRST_CELLPADDING));
assertEquals(cellpadding, 1, format(MSG_SUGGESTION_BOX_CELLPADDING_PREFORMATTED,
1));
selenium.type(LOC_FIRST_CELLPADDING_INPUT, "10");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return Integer.parseInt(selenium.getAttribute(LOC_FIRST_CELLPADDING)) ==
10;
+ }
+ });
+
cellpadding = Integer.parseInt(selenium.getAttribute(LOC_FIRST_CELLPADDING));
assertEquals(cellpadding, 10, format(MSG_SUGGESTION_BOX_CELLPADDING_PREFORMATTED,
10));
selenium.type(LOC_FIRST_CELLPADDING_INPUT, "20");
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return Integer.parseInt(selenium.getAttribute(LOC_FIRST_CELLPADDING)) ==
20;
+ }
+ });
+
cellpadding = Integer.parseInt(selenium.getAttribute(LOC_FIRST_CELLPADDING));
assertEquals(cellpadding, 20, format(MSG_SUGGESTION_BOX_CELLPADDING_PREFORMATTED,
20));
selenium.type(LOC_FIRST_CELLPADDING_INPUT, "25"); // 25 -> 20
- waitFor(1500);
+ Wait.until(new Condition() {
+ public boolean isTrue() {
+ return Integer.parseInt(selenium.getAttribute(LOC_FIRST_CELLPADDING)) ==
20;
+ }
+ });
+
cellpadding = Integer.parseInt(selenium.getAttribute(LOC_FIRST_CELLPADDING));
assertEquals(cellpadding, 20, format(MSG_SUGGESTION_BOX_CELLPADDING_PREFORMATTED,
25));
}
@@ -402,9 +519,11 @@
waitForTextEquals(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 3),
"Madison");
selenium.click(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 3)); // Madison
- waitFor(700);
- String state = selenium.getText(LOC_SECOND_STATE);
- assertEquals(state, "Maine,Wisconsin",
MSG_AUGUSTA_MADISON_MAINE_WISCONSIN);
+ Wait.failWith(MSG_AUGUSTA_MADISON_MAINE_WISCONSIN).until(new Condition() {
+ public boolean isTrue() {
+ return
selenium.getText(LOC_SECOND_STATE).equals("Maine,Wisconsin");
+ }
+ });
}
/**
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/toolBar/ToolBarTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/toolBar/ToolBarTestCase.java 2009-09-15
12:33:45 UTC (rev 15577)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/toolBar/ToolBarTestCase.java 2009-09-15
12:59:18 UTC (rev 15578)
@@ -115,36 +115,51 @@
@Test
public void testThirdToolBarGroupSeparators() {
scrollIntoView(format(LOC_EXAMPLE_N_HEADER, 3), true);
- String text;
-
+
// select line
selenium.click(format(LOC_THIRD_TOOLBAR_GROUP_SEPARATOR_N, 1));
- waitForElement(LOC_GROUP_SEPARATOR_IMG);
+
+ Wait.failWith(format(MSG_GROUP_SEPARATOR_S,
"LineSeparatorImage")).until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getAttribute(LOC_GROUP_SEPARATOR_IMG +
"(a)src").contains("LineSeparatorImage");
+ }
+ });
+
assertTrue(selenium.isElementPresent(LOC_GROUP_SEPARATOR_IMG),
MSG_THERE_IS_NO_GROUP_SEPARATOR);
- text = selenium.getAttribute(LOC_GROUP_SEPARATOR_IMG + "@src");
- assertTrue(text.contains("LineSeparatorImage"),
format(MSG_GROUP_SEPARATOR_S, "LineSeparatorImage"));
-
+
// select grid
selenium.click(format(LOC_THIRD_TOOLBAR_GROUP_SEPARATOR_N, 2));
- waitForElement(LOC_GROUP_SEPARATOR_IMG);
+
+ Wait.failWith(format(MSG_GROUP_SEPARATOR_S,
"GridSeparatorImage")).until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getAttribute(LOC_GROUP_SEPARATOR_IMG +
"(a)src").contains("GridSeparatorImage");
+ }
+ });
+
assertTrue(selenium.isElementPresent(LOC_GROUP_SEPARATOR_IMG),
MSG_THERE_IS_NO_GROUP_SEPARATOR);
- text = selenium.getAttribute(LOC_GROUP_SEPARATOR_IMG + "@src");
- assertTrue(text.contains("GridSeparatorImage"),
format(MSG_GROUP_SEPARATOR_S, "GridSeparatorImage"));
-
+
// select disc
selenium.click(format(LOC_THIRD_TOOLBAR_GROUP_SEPARATOR_N, 3));
- waitForElement(LOC_GROUP_SEPARATOR_IMG);
+
+ Wait.failWith(format(MSG_GROUP_SEPARATOR_S,
"DotSeparatorImage")).until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getAttribute(LOC_GROUP_SEPARATOR_IMG +
"(a)src").contains("DotSeparatorImage");
+ }
+ });
+
assertTrue(selenium.isElementPresent(LOC_GROUP_SEPARATOR_IMG),
MSG_THERE_IS_NO_GROUP_SEPARATOR);
- text = selenium.getAttribute(LOC_GROUP_SEPARATOR_IMG + "@src");
- assertTrue(text.contains("DotSeparatorImage"),
format(MSG_GROUP_SEPARATOR_S, "DotSeparatorImage"));
-
+
// select square
selenium.click(format(LOC_THIRD_TOOLBAR_GROUP_SEPARATOR_N, 4));
- waitForElement(LOC_GROUP_SEPARATOR_IMG);
+
+ Wait.failWith(format(MSG_GROUP_SEPARATOR_S,
"SquareSeparatorImage")).until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getAttribute(LOC_GROUP_SEPARATOR_IMG +
"(a)src").contains("SquareSeparatorImage");
+ }
+ });
+
assertTrue(selenium.isElementPresent(LOC_GROUP_SEPARATOR_IMG),
MSG_THERE_IS_NO_GROUP_SEPARATOR);
- text = selenium.getAttribute(LOC_GROUP_SEPARATOR_IMG + "@src");
- assertTrue(text.contains("SquareSeparatorImage"),
format(MSG_GROUP_SEPARATOR_S, "SquareSeparatorImage"));
-
+
// select none
selenium.click(format(LOC_THIRD_TOOLBAR_GROUP_SEPARATOR_N, 5));
Wait.failWith(MSG_THERE_IS_GROUP_SEPARATOR).until(new Condition() {
@@ -160,35 +175,50 @@
@Test
public void testToolBarItemSeparators() {
scrollIntoView(format(LOC_EXAMPLE_N_HEADER, 3), true);
- String text;
-
+
// select line
selenium.click(format(LOC_THIRD_TOOLBAR_ITEM_SEPARATOR_N, 1));
- waitForElement(LOC_ITEM_SEPARATOR_IMG);
+
+ Wait.failWith(format(MSG_ITEM_SEPARATOR_S,
"LineSeparatorImage")).until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getAttribute(LOC_ITEM_SEPARATOR_IMG +
"(a)src").contains("LineSeparatorImage");
+ }
+ });
+
assertTrue(selenium.isElementPresent(LOC_ITEM_SEPARATOR_IMG),
MSG_THERE_IS_NO_ITEM_SEPARATOR);
- text = selenium.getAttribute(LOC_ITEM_SEPARATOR_IMG + "@src");
- assertTrue(text.contains("LineSeparatorImage"),
format(MSG_ITEM_SEPARATOR_S, "LineSeparatorImage"));
-
+
// select grid
selenium.click(format(LOC_THIRD_TOOLBAR_ITEM_SEPARATOR_N, 2));
- waitForElement(LOC_ITEM_SEPARATOR_IMG);
+
+ Wait.failWith(format(MSG_ITEM_SEPARATOR_S,
"GridSeparatorImage")).until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getAttribute(LOC_ITEM_SEPARATOR_IMG +
"(a)src").contains("GridSeparatorImage");
+ }
+ });
+
assertTrue(selenium.isElementPresent(LOC_ITEM_SEPARATOR_IMG),
MSG_THERE_IS_NO_ITEM_SEPARATOR);
- text = selenium.getAttribute(LOC_ITEM_SEPARATOR_IMG + "@src");
- assertTrue(text.contains("GridSeparatorImage"),
format(MSG_ITEM_SEPARATOR_S, "GridSeparatorImage"));
-
+
// select disc
selenium.click(format(LOC_THIRD_TOOLBAR_ITEM_SEPARATOR_N, 3));
- waitForElement(LOC_ITEM_SEPARATOR_IMG);
+
+ Wait.failWith(format(MSG_ITEM_SEPARATOR_S,
"DotSeparatorImage")).until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getAttribute(LOC_ITEM_SEPARATOR_IMG +
"(a)src").contains("DotSeparatorImage");
+ }
+ });
+
assertTrue(selenium.isElementPresent(LOC_ITEM_SEPARATOR_IMG),
MSG_THERE_IS_NO_ITEM_SEPARATOR);
- text = selenium.getAttribute(LOC_ITEM_SEPARATOR_IMG + "@src");
- assertTrue(text.contains("DotSeparatorImage"),
format(MSG_ITEM_SEPARATOR_S, "DotSeparatorImage"));
// select square
selenium.click(format(LOC_THIRD_TOOLBAR_ITEM_SEPARATOR_N, 4));
- waitForElement(LOC_ITEM_SEPARATOR_IMG);
+
+ Wait.failWith(format(MSG_ITEM_SEPARATOR_S,
"SquareSeparatorImage")).until(new Condition() {
+ public boolean isTrue() {
+ return selenium.getAttribute(LOC_ITEM_SEPARATOR_IMG +
"(a)src").contains("SquareSeparatorImage");
+ }
+ });
+
assertTrue(selenium.isElementPresent(LOC_ITEM_SEPARATOR_IMG),
MSG_THERE_IS_NO_ITEM_SEPARATOR);
- text = selenium.getAttribute(LOC_ITEM_SEPARATOR_IMG + "@src");
- assertTrue(text.contains("SquareSeparatorImage"),
format(MSG_ITEM_SEPARATOR_S, "SquareSeparatorImage"));
// select none
selenium.click(format(LOC_THIRD_TOOLBAR_ITEM_SEPARATOR_N, 5));