From richfaces-svn-commits at lists.jboss.org Fri Dec 11 02:25:05 2009 Content-Type: multipart/mixed; boundary="===============0240548297339333122==" MIME-Version: 1.0 From: richfaces-svn-commits at lists.jboss.org To: richfaces-svn-commits at lists.jboss.org Subject: [richfaces-svn-commits] JBoss Rich Faces SVN: r16110 - in branches/sandbox/rf-demo-ftest-iexplore/src/test: resources/org/jboss/richfaces/integrationTest/suggestionBox and 1 other directory. Date: Fri, 11 Dec 2009 02:25:05 -0500 Message-ID: <200912110725.nBB7P5pv016727@svn01.web.mwc.hst.phx2.redhat.com> --===============0240548297339333122== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: lfryc(a)redhat.com Date: 2009-12-11 02:25:05 -0500 (Fri, 11 Dec 2009) New Revision: 16110 Modified: branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richface= s/integrationTest/suggestionBox/SuggestionBoxTestCase.java branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/ric= hfaces/integrationTest/suggestionBox/locators.properties Log: * SuggestionBoxTestCase - typeKey replaced by type and fireEvent(Event.KEYDOWN) + had to add obtain= ing of current value if typing into already changed input - implementation of getValue for obtaining CSS style values from style-attr= ibute changed to getStyleValue - internally uses library's getStyle(locator= , styleName) - the suggestionBox need to be opened in Firefox before obtain= ing top, left and opacity styles - tests of styling suggestionBox refactored Modified: branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/r= ichfaces/integrationTest/suggestionBox/SuggestionBoxTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfac= es/integrationTest/suggestionBox/SuggestionBoxTestCase.java 2009-12-11 01:4= 4:15 UTC (rev 16109) +++ branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfac= es/integrationTest/suggestionBox/SuggestionBoxTestCase.java 2009-12-11 07:2= 5:05 UTC (rev 16110) @@ -24,7 +24,9 @@ = import static org.testng.Assert.assertEquals; = +import org.apache.commons.lang.math.Range; import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCa= se; +import org.jboss.test.selenium.dom.Event; import org.jboss.test.selenium.waiting.Condition; import org.jboss.test.selenium.waiting.Wait; import org.testng.annotations.BeforeMethod; @@ -33,7 +35,8 @@ /** * Test case that tests the suggestion box. * = - * @author Pavol Pitonak + * @author Pavol Pitonak, Lukas Fryc * @version $Revision$ */ public class SuggestionBoxTestCase extends AbstractSeleniumRichfacesTestCa= se { @@ -85,15 +88,18 @@ scrollIntoView(LOC_FIRST_INPUT, true); = // select Atlanta - selenium.typeKeys(LOC_FIRST_INPUT, "at"); + selenium.type(LOC_FIRST_INPUT, "at"); + selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN); + = waitForElement(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)); = selenium.click(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)); = // select Madison - selenium.typeKeys(LOC_FIRST_INPUT, ",ma"); + selenium.type(LOC_FIRST_INPUT, selenium.getValue(LOC_FIRST_INPUT) = + ",ma"); + selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN); = - waitForTextEquals(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)= , "MadisonWisconsin"); + waitForTextEquals(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)= , "Wisconsin"); selenium.click(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)); = String text =3D selenium.getText(format(LOC_FIRST_TOWN_TABLE_PREFO= RMATTED, 1, 0)); @@ -130,17 +136,23 @@ scrollIntoView(LOC_FIRST_INPUT, true); = // select Atlanta - selenium.typeKeys(LOC_FIRST_INPUT, "[at"); + selenium.type(LOC_FIRST_INPUT, "[at"); + selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN); + = waitForElement(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)); = selenium.click(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)); - selenium.typeKeys(LOC_FIRST_INPUT, "]"); + selenium.type(LOC_FIRST_INPUT, selenium.getValue(LOC_FIRST_INPUT) = + "]"); + selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN); = // select Madison - selenium.typeKeys(LOC_FIRST_INPUT, "[ma"); - waitForTextEquals(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)= , "MadisonWisconsin"); + selenium.type(LOC_FIRST_INPUT, selenium.getValue(LOC_FIRST_INPUT) = + "[ma"); + selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN); + = + waitForTextEquals(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)= , "Wisconsin"); selenium.click(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)); - selenium.typeKeys(LOC_FIRST_INPUT, "]"); + selenium.type(LOC_FIRST_INPUT, selenium.getValue(LOC_FIRST_INPUT) = + "]"); + selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN); = String text =3D selenium.getText(format(LOC_FIRST_TOWN_TABLE_PREFO= RMATTED, 1, 0)); assertEquals(text, "Georgia", format(MSG_TABLE_PREFORMATTED, 1, 0)= ); @@ -176,7 +188,8 @@ scrollIntoView(LOC_FIRST_INPUT, true); = // select aaa - selenium.typeKeys(LOC_FIRST_INPUT, "aaa"); + selenium.type(LOC_FIRST_INPUT, "aaa"); + selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN); = waitForElement(format(LOC_FIRST_SUGGESTION_BOX_PREFORMATTED, 0)); String text =3D selenium.getText(format(LOC_FIRST_SUGGESTION_BOX_P= REFORMATTED, 0)); @@ -184,242 +197,106 @@ } = /** - * Tests the "Border" slider. It tests values 3, 5, and 7. + * Tests the "Border" slider. It tests values 5, 0, 3, 7, 1 */ - @Test - public void testBorder() { - scrollIntoView(LOC_FIRST_INPUT, true); + @Test + public void testBorder() { + scrollIntoView(LOC_FIRST_INPUT, true); = - selenium.type(LOC_FIRST_BORDER_INPUT, "3"); - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_BORDER_STYLE, "border-width") = =3D=3D 3; - } - }); + StepRange range =3D new StepRange(1, 5, 1); + for (int i : new int[] { 5, 0, 3, 7, 1 }) { + selenium.type(LOC_FIRST_BORDER_INPUT, String.valueOf(i)); + selenium.fireEvent(LOC_FIRST_BORDER_INPUT, Event.BLUR); + String result =3D range.getRoundedValue(i).toString(); + Wait.failWith(format(MSG_SUGGESTION_BOX_BORDER_PREFORMATTED, String.val= ueOf(i))).until( + new StyleCondition(LOC_FIRST_BORDER_STYLE, "border-top-width", result= )); + assertEquals(getStyleValue(LOC_FIRST_BORDER_STYLE, "border-right-width"= ), result); + assertEquals(getStyleValue(LOC_FIRST_BORDER_STYLE, "border-bottom-width= "), result); + assertEquals(getStyleValue(LOC_FIRST_BORDER_STYLE, "border-left-width")= , result); + assertEquals(selenium.getValue(LOC_FIRST_BORDER_INPUT), result); + } + } = - int width =3D getValue(LOC_FIRST_BORDER_STYLE, "border-width"); - assertEquals(width, 3, format(MSG_SUGGESTION_BOX_BORDER_PREFORMATT= ED, 3)); - - selenium.type(LOC_FIRST_BORDER_INPUT, "5"); - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_BORDER_STYLE, "border-width") = =3D=3D 5; - } - }); - - width =3D getValue(LOC_FIRST_BORDER_STYLE, "border-width"); - assertEquals(width, 5, format(MSG_SUGGESTION_BOX_BORDER_PREFORMATT= ED, 5)); - - selenium.type(LOC_FIRST_BORDER_INPUT, "7"); // 7 -> 5 - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_BORDER_STYLE, "border-width") = =3D=3D 5; - } - }); - - width =3D getValue(LOC_FIRST_BORDER_STYLE, "border-width"); - assertEquals(width, 5, format(MSG_SUGGESTION_BOX_BORDER_PREFORMATT= ED, 7)); - } - /** - * Tests the "Width" slider. It tests values 150, 350, 400, and 176. + * Tests the "Width" slider. It tests values 350, 149, 176, 351, 200, = 150, 500 */ @Test public void testWidth() { scrollIntoView(LOC_FIRST_INPUT, true); = - selenium.type(LOC_FIRST_WIDTH_INPUT, "150"); - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_WIDTH_STYLE, "width") =3D=3D 150; - } - }); - - int width =3D getValue(LOC_FIRST_WIDTH_STYLE, "width"); - assertEquals(width, 150, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMAT= TED, 150)); - - selenium.type(LOC_FIRST_WIDTH_INPUT, "350"); - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_WIDTH_STYLE, "width") =3D=3D 350; - } - }); - - width =3D getValue(LOC_FIRST_WIDTH_STYLE, "width"); - assertEquals(width, 350, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMAT= TED, 350)); - - selenium.type(LOC_FIRST_WIDTH_INPUT, "400"); // 400 -> 350 - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_WIDTH_STYLE, "width") =3D=3D 350; - } - }); - - width =3D getValue(LOC_FIRST_WIDTH_STYLE, "width"); - assertEquals(width, 350, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMAT= TED, 400)); - - selenium.type(LOC_FIRST_WIDTH_INPUT, "176"); // 176 -> 200 - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_WIDTH_STYLE, "width") =3D=3D 200; - } - }); - - width =3D getValue(LOC_FIRST_WIDTH_STYLE, "width"); - assertEquals(width, 200, format(MSG_SUGGESTION_BOX_WIDTH_PREFORMAT= TED, 176)); + StepRange range =3D new StepRange(150, 350, 50); + final String locInput =3D LOC_FIRST_WIDTH_INPUT; + for (int i : new int[] { 350, 149, 176, 351, 200, 150, 500 }) { + selenium.type(locInput, String.valueOf(i)); + selenium.fireEvent(locInput, Event.BLUR); + String result =3D range.getRoundedValue(i).toString(); + Wait.failWith(format(MSG_SUGGESTION_BOX_WIDTH_PREFORMATTED, String.valu= eOf(i))).until( + new StyleCondition(LOC_FIRST_WIDTH_STYLE, "width", result)); + assertEquals(selenium.getValue(locInput), result); + } } = /** - * Tests the "Height" slider. It tests values 100, 300, 400, and 176. + * Tests the "Height" slider. It tests values 300, 99, 176, 301, 200, = 100, 400 */ @Test public void testHeight() { scrollIntoView(LOC_FIRST_INPUT, true); = - selenium.type(LOC_FIRST_HEIGHT_INPUT, "100"); - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_HEIGHT_STYLE, "height") =3D=3D 1= 00; - } - }); - - int height =3D getValue(LOC_FIRST_HEIGHT_STYLE, "height"); - assertEquals(height, 100, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORM= ATTED, 100)); - - selenium.type(LOC_FIRST_HEIGHT_INPUT, "300"); - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_HEIGHT_STYLE, "height") =3D=3D 3= 00; - } - }); - - height =3D getValue(LOC_FIRST_HEIGHT_STYLE, "height"); - assertEquals(height, 300, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORM= ATTED, 300)); - - selenium.type(LOC_FIRST_HEIGHT_INPUT, "400"); // 400 -> 300 - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_HEIGHT_STYLE, "height") =3D=3D 3= 00; - } - }); - - height =3D getValue(LOC_FIRST_HEIGHT_STYLE, "height"); - assertEquals(height, 300, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORM= ATTED, 400)); - - selenium.type(LOC_FIRST_HEIGHT_INPUT, "176"); // 176 -> 200 - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_HEIGHT_STYLE, "height") =3D=3D 2= 00; - } - }); - - height =3D getValue(LOC_FIRST_HEIGHT_STYLE, "height"); - assertEquals(height, 200, format(MSG_SUGGESTION_BOX_HEIGHT_PREFORM= ATTED, 176)); + StepRange range =3D new StepRange(100, 300, 50); + final String locInput =3D LOC_FIRST_HEIGHT_INPUT; + for (int i : new int[] { 300, 99, 176, 301, 200, 100, 400 }) { + selenium.type(locInput, String.valueOf(i)); + selenium.fireEvent(locInput, Event.BLUR); + String result =3D range.getRoundedValue(i).toString(); + Wait.failWith(format(MSG_SUGGESTION_BOX_HEIGHT_PREFORMATTED, String.val= ueOf(i))).until( + new StyleCondition(LOC_FIRST_HEIGHT_STYLE, "height", result)); + assertEquals(selenium.getValue(locInput), result); + } } = /** - * Tests the "Shadow Depth" slider. It tests values 3, 5, 6, and 7. It= test + * Tests the "Shadow Depth" slider. It tests values 7, 4, 2, 6, 3, 0, = 8. It test * both top and left offset. */ - @Test - public void testShadowDepth() { - scrollIntoView(LOC_FIRST_INPUT, true); + @Test + public void testShadowDepth() { + scrollIntoView(LOC_FIRST_INPUT, true); = - selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "3"); - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") =3D= =3D 3; - } - }); - - int top =3D getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top"); - assertEquals(top, 3, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFOR= MATTED, 3)); - int left =3D getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left"); - assertEquals(left, 3, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFO= RMATTED, 3)); - - selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "5"); - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") =3D= =3D 5; - } - }); - - top =3D getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top"); - assertEquals(top, 5, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFOR= MATTED, 5)); - left =3D getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left"); - assertEquals(left, 5, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFO= RMATTED, 5)); - - selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "6"); - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") =3D= =3D 6; - } - }); - - top =3D getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top"); - assertEquals(top, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFOR= MATTED, 6)); - left =3D getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left"); - assertEquals(left, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFO= RMATTED, 6)); - - selenium.type(LOC_FIRST_SHADOW_DEPTH_INPUT, "7"); // 7 -> 6 - Wait.until(new Condition() { - public boolean isTrue() { - return getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top") =3D= =3D 6; - } - }); - - top =3D getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "top"); - assertEquals(top, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFOR= MATTED, 7)); - left =3D getValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left"); - assertEquals(left, 6, format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFO= RMATTED, 7)); + StepRange range =3D new StepRange(3, 6, 1); + final String locInput =3D LOC_FIRST_SHADOW_DEPTH_INPUT; + for (int i : new int[] { 7, 4, 2, 6, 3, 0, 8 }) { + selenium.type(locInput, String.valueOf(i)); + selenium.fireEvent(locInput, Event.BLUR); + selenium.type(LOC_FIRST_INPUT, String.valueOf(i)); + selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN); + String result =3D range.getRoundedValue(i).toString(); + Wait.failWith(format(MSG_SUGGESTION_BOX_SHADOW_DEPTH_PREFORMATTED, Stri= ng.valueOf(i))).until( + new StyleCondition(LOC_FIRST_SHADOW_DEPTH_STYLE, "top", result)); + assertEquals(getStyleValue(LOC_FIRST_SHADOW_DEPTH_STYLE, "left"), resul= t); + assertEquals(selenium.getValue(locInput), result); + } } = /** - * Tests the "Shadow Opacity" slider. It tests values 1, 5, 9, and 11. + * Tests the "Shadow Opacity" slider. It tests values 10, 5, 0, 9, 1, = -1, 12. */ @Test public void testShadowOpacity() { scrollIntoView(LOC_FIRST_INPUT, true); - - selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "1"); - Wait.until(new Condition() { - public boolean isTrue() { - return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) =3D=3D 0= .1; - } - }); - - double opacity =3D getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE); - assertEquals(opacity, 0.1, format(MSG_SUGGESTION_BOX_SHADOW_OPACIT= Y_PREFORMATTED, 1)); - - selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "5"); - Wait.until(new Condition() { - public boolean isTrue() { - return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) =3D=3D 0= .5; - } - }); - - opacity =3D getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE); - assertEquals(opacity, 0.5, format(MSG_SUGGESTION_BOX_SHADOW_OPACIT= Y_PREFORMATTED, 5)); - - selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "9"); - Wait.until(new Condition() { - public boolean isTrue() { - return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) =3D=3D 0= .9; - } - }); - - opacity =3D getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE); - assertEquals(opacity, 0.9, format(MSG_SUGGESTION_BOX_SHADOW_OPACIT= Y_PREFORMATTED, 9)); - - selenium.type(LOC_FIRST_SHADOW_OPACITY_INPUT, "11"); // 11 -> 9 - Wait.until(new Condition() { - public boolean isTrue() { - return getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE) =3D=3D 0= .9; - } - }); - - opacity =3D getOpacity(LOC_FIRST_SHADOW_OPACITY_STYLE); - assertEquals(opacity, 0.9, format(MSG_SUGGESTION_BOX_SHADOW_OPACIT= Y_PREFORMATTED, 11)); + = + StepRange range =3D new StepRange(1, 9, 1); + final String locInput =3D LOC_FIRST_SHADOW_OPACITY_INPUT; + for (int i : new int[] { 10, 5, 0, 9, 1, -1, 12 }) { + selenium.type(locInput, String.valueOf(i)); + selenium.fireEvent(locInput, Event.BLUR); + selenium.type(LOC_FIRST_INPUT, String.valueOf(i)); + selenium.fireEvent(LOC_FIRST_INPUT, Event.KEYDOWN); + String result =3D range.getRoundedValue(i).toString(); + Wait.failWith(format(MSG_SUGGESTION_BOX_SHADOW_OPACITY_PREFORMATTED, St= ring.valueOf(i))).until( + new StyleCondition(LOC_FIRST_SHADOW_OPACITY_STYLE, "opacity", format(= "0.{0}", result))); + assertEquals(selenium.getValue(locInput), result); + } } = /** @@ -494,7 +371,9 @@ public void testSecondExampleOneCity() { scrollIntoView(LOC_SECOND_INPUT, true); = - selenium.typeKeys(LOC_SECOND_INPUT, "a"); + selenium.type(LOC_SECOND_INPUT, "a"); + selenium.fireEvent(LOC_SECOND_INPUT, Event.KEYDOWN); + = waitForElement(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 1)); selenium.click(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 1));= // Augusta = @@ -512,11 +391,15 @@ public void testSecondExampleMoreCities() { scrollIntoView(LOC_SECOND_INPUT, true); = - selenium.typeKeys(LOC_SECOND_INPUT, "a"); + selenium.type(LOC_SECOND_INPUT, "a"); + selenium.fireEvent(LOC_SECOND_INPUT, Event.KEYDOWN); + = waitForElement(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 1)); selenium.click(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 1));= // Augusta = - selenium.typeKeys(LOC_SECOND_INPUT, ",m"); + selenium.type(LOC_SECOND_INPUT, selenium.getValue(LOC_SECOND_INPUT= ) + ",m"); + selenium.fireEvent(LOC_SECOND_INPUT, Event.KEYDOWN); + = waitForTextEquals(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 2= ), "Madison"); selenium.click(format(LOC_SECOND_SUGGESTION_BOX_PREFORMATTED, 2));= // Madison = @@ -587,44 +470,109 @@ abstractTestSource(2, "View Source", strings); } = - /** - * Pulls out the value of the specified attribute from the specified - * location. - * = - * @param loc - * an attribute locator - * @param attr - * an 'subattribute' whose value we want (e.g.
, then loc=3D//div(a)style and att= r=3Dleft - * @return the value of the subattribute - */ - private int getValue(String loc, String attr) { - String tmp =3D selenium.getAttribute(loc); - int firstIdx =3D tmp.indexOf(attr) + 2 + attr.length(); - int secondIdx =3D tmp.indexOf("px;", firstIdx); - return Integer.parseInt(tmp.substring(firstIdx, secondIdx)); - } + = + /** + * Condition for Wait.until(Condition) which waits for the item specified= by + * locator becomes in given style given value + */ + private class StyleCondition implements Condition { + private String locator; + private String style; + private String value; = - /** - * Pulls out opacity from the specified attribute. - * = - * @param loc - * an attribute locator - * @return the value of opacity - */ - private double getOpacity(String loc) { - String tmp =3D selenium.getAttribute(loc); - int firstIdx =3D tmp.indexOf("opacity") + 9; - int secondIdx =3D tmp.indexOf(";", firstIdx); - return Double.parseDouble(tmp.substring(firstIdx, secondIdx)); - } + /** + * @param locator + * locator of item which we will be testing for becoming + * given style in given value + * @param style + * tested on item given by locator to equality with given + * value + * @param value + * of given style which we are testing on item specified by + * locator + */ + public StyleCondition(String locator, String style, String value) { + this.locator =3D locator; + this.style =3D style; + this.value =3D value; + } = - /** - * Loads the page containing the calendar component. - */ + public boolean isTrue() { + return getStyleValue(locator, style).equals(value); + } + } + + /** + * Pulls out the value of the specified attribute from the specified + * location. + * = + * @param loc + * an attribute locator + * @param attr + * an style value what we want to pull out + * @return the value of the subattribute + */ + private String getStyleValue(String loc, String attr) { + return getStyle(loc, attr).replaceFirst("px", ""); + } + = + /** + * Class representing Range of numbers with defined offset between them (= step) + * = + * Can test the number for presence in range and round the number into nu= mber, which is in the range. + */ + private class StepRange extends Range { + + private int minimum; + private int maximum; + private int step; + = + public StepRange(int minimum, int maximum, int step) { + this.minimum =3D minimum; + this.maximum =3D maximum; + this.step =3D step; + } + = + @Override + public boolean containsNumber(Number number) { + return number.intValue() =3D=3D getRoundedValue(number).intValue(); + } + + @Override + public Number getMaximumNumber() { + return maximum; + } + + @Override + public Number getMinimumNumber() { + return minimum; + } + = + public Number getRoundedValue(Number number) { + if (number.intValue() < minimum) + return minimum; + if (number.intValue() > maximum) + return maximum; + int delta =3D number.intValue() % step; + if (delta !=3D 0) { + if (delta > (step / 2)) { + return number.intValue() - delta + step; + } else { + return number.intValue() - delta; + } + } + return number; + } + } + + /** + * Loads the page containing the calendar component. + */ @SuppressWarnings("unused") @BeforeMethod private void loadPage() { openComponent("Suggestion Box"); } + = + = } Modified: branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jb= oss/richfaces/integrationTest/suggestionBox/locators.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/ri= chfaces/integrationTest/suggestionBox/locators.properties 2009-12-11 01:44:= 15 UTC (rev 16109) +++ branches/sandbox/rf-demo-ftest-iexplore/src/test/resources/org/jboss/ri= chfaces/integrationTest/suggestionBox/locators.properties 2009-12-11 07:25:= 05 UTC (rev 16110) @@ -1,4 +1,4 @@ -FIRST_SUGGESTION_BOX_PREFORMATTED=3Djquery=3Dtable[id$=3Dsuggest].rich-sb-= int-decor-table tr:eq({0}) +FIRST_SUGGESTION_BOX_PREFORMATTED=3Djquery\=3Dtable[id$\=3Dsuggest].rich-s= b-int-decor-table tr\:eq({0}) td\:last = FIRST_INPUT=3Djquery=3Dfieldset:eq(0) input[id$=3Dtext] FIRST_BORDER_INPUT=3Djquery=3Dfieldset:eq(0) td.sb_test_column1 > table > = tbody > tr:eq(0) > td:eq(1) input @@ -10,15 +10,15 @@ = FIRST_TOWN_TABLE_PREFORMATTED=3Djquery=3Dfieldset:eq(0) td.sb_test_column2= div#myDiv tr:eq({0}) > td:eq({1}) = -FIRST_BORDER_STYLE=3Djquery=3Ddiv[id$=3DsuggestionBoxId] div.rich-sb-ext-d= ecor-2(a)style -FIRST_WIDTH_STYLE=3Djquery=3Ddiv[id$=3DsuggestionBoxId]@style -FIRST_HEIGHT_STYLE=3Djquery=3Ddiv[id$=3DsuggestionBoxId]@style -FIRST_SHADOW_DEPTH_STYLE=3Djquery=3Ddiv[id$=3DsuggestionBoxId] > div:eq(1)= @style -FIRST_SHADOW_OPACITY_STYLE=3Djquery=3Ddiv[id$=3DsuggestionBoxId] > div:eq(= 1)@style +FIRST_BORDER_STYLE=3Djquery\=3Ddiv[id$\=3DsuggestionBoxId] div.rich-sb-ext= -decor-2 +FIRST_WIDTH_STYLE=3Djquery\=3Ddiv[id$\=3DsuggestionBoxId] +FIRST_HEIGHT_STYLE=3Djquery\=3Ddiv[id$\=3DsuggestionBoxId] +FIRST_SHADOW_DEPTH_STYLE=3Djquery\=3Ddiv[id$\=3DsuggestionBoxId] > div\:eq= (1) +FIRST_SHADOW_OPACITY_STYLE=3Djquery\=3Ddiv[id$\=3DsuggestionBoxId] > div\:= eq(1) FIRST_CELLPADDING=3Djquery=3Ddiv[id$=3DsuggestionBoxId] table[id$=3Dsugges= t]@cellpadding = SECOND_INPUT=3Djquery=3Dfieldset:eq(1) input[id$=3Dstatesinput] SECOND_BUTTON=3Djquery=3Dfieldset:eq(1) img[src*=3Darrow.png] SECOND_SUGGESTION_LINES=3Djquery=3Ddiv[id$=3Dsuggestion] table[id$=3Dsugge= st] tr -SECOND_SUGGESTION_BOX_PREFORMATTED=3Djquery=3Ddiv[id$=3Dsuggestion] table[= id$=3Dsuggest] tr:eq({0}) +SECOND_SUGGESTION_BOX_PREFORMATTED=3Djquery\=3Ddiv[id$\=3Dsuggestion] tabl= e[id$\=3Dsuggest] tr\:eq({0}) td\:last SECOND_STATE=3Djquery=3Dfieldset:eq(1) span[id$=3Dobjects] --===============0240548297339333122==--