Author: ppitonak(a)redhat.com
Date: 2009-09-09 10:52:04 -0400 (Wed, 09 Sep 2009)
New Revision: 15506
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceSelect/InplaceSelectTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inputNumberSlider/InputNumberSliderTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inplaceSelect/locators.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inplaceSelect/messages.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inputNumberSlider/locators.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inputNumberSlider/messages.properties
Log:
* InplaceSelectTestCase and InputNumberSliderTestCase refactored
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceSelect/InplaceSelectTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceSelect/InplaceSelectTestCase.java 2009-09-09
13:44:10 UTC (rev 15505)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inplaceSelect/InplaceSelectTestCase.java 2009-09-09
14:52:04 UTC (rev 15506)
@@ -1,226 +1,264 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
package org.jboss.richfaces.integrationTest.inplaceSelect;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
-import java.awt.event.KeyEvent;
-
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Test case that tests the inplace select component.
- * <ul>
- * <li><b>TODO</b> test cancel buttons
- * </ul>
*
* @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
* @version $Revision$
*/
+// TODO test cancel buttons
public class InplaceSelectTestCase extends AbstractSeleniumRichfacesTestCase {
- // messages
- private final String MSG_COMPONENT_DESCRIPTION =
getMess("COMPONENT_DESCRIPTION");
- private final String MSG_CLICK_HERE_TO_EDIT = getMess("CLICK_HERE_TO_EDIT");
- private final String MSG_DOUBLE_CLICK_TO_EDIT =
getMess("DOUBLE_CLICK_TO_EDIT");
- private final String MSG_READ_ONLY = getMess("READ_ONLY");
- private final String MSG_DISPLAY_NONE = getMess("DISPLAY_NONE");
- private final String MSG_OPTION4_SELECTED = getMess("OPTION4_SELECTED");
- private final String MSG_ARKANSAS_SELECTED = getMess("ARKANSAS_SELECTED");
- private final String MSG_LITTLE_ROCK = getMess("LITTLE_ROCK");
- private final String MSG_COUNT_OF_ITEMS = getMess("COUNT_OF_ITEMS");
+ // messages
+ private final String MSG_CLICK_HERE_TO_EDIT =
getMsg("CLICK_HERE_TO_EDIT");
+ private final String MSG_DOUBLE_CLICK_TO_EDIT =
getMsg("DOUBLE_CLICK_TO_EDIT");
+ private final String MSG_READ_ONLY = getMsg("READ_ONLY");
+ private final String MSG_DISPLAY_NONE = getMsg("DISPLAY_NONE");
+ private final String MSG_OPTION4_SELECTED = getMsg("OPTION4_SELECTED");
+ private final String MSG_ARKANSAS_SELECTED = getMsg("ARKANSAS_SELECTED");
+ private final String MSG_LITTLE_ROCK = getMsg("LITTLE_ROCK");
+ private final String MSG_COUNT_OF_ITEMS = getMsg("COUNT_OF_ITEMS");
- // locators
- private final String LOC_FIRST = getLoc("FIRST");
- private final String LOC_FIRST_INPUT_1 = getLoc("FIRST_INPUT_1");
- private final String LOC_FIRST_INPUT_2 = getLoc("FIRST_INPUT_2");
- private final String LOC_FIRST_SELECT_VIEW = getLoc("FIRST_SELECT_VIEW");
- private final String LOC_FIRST_LIST_SPAN = getLoc("FIRST_LIST_SPAN");
- private final String LOC_FIRST_LIST_SPAN_N = getLoc("FIRST_LIST_SPAN_N");
- private final String LOC_SECOND_OK_BUTTON = getLoc("SECOND_OK_BUTTON");
+ // locators
+ private final String LOC_FIRST = getLoc("FIRST");
+ private final String LOC_FIRST_INPUT_1 = getLoc("FIRST_INPUT_1");
+ private final String LOC_FIRST_INPUT_2 = getLoc("FIRST_INPUT_2");
+ private final String LOC_FIRST_SELECT_VIEW = getLoc("FIRST_SELECT_VIEW");
+ private final String LOC_FIRST_LIST_SPAN = getLoc("FIRST_LIST_SPAN");
+ private final String LOC_FIRST_LIST_SPAN_N = getLoc("FIRST_LIST_SPAN_N");
+ private final String LOC_SECOND_OK_BUTTON = getLoc("SECOND_OK_BUTTON");
- private final String LOC_SECOND = getLoc("SECOND");
- private final String LOC_SECOND_INPUT_1 = getLoc("SECOND_INPUT_1");
- private final String LOC_SECOND_INPUT_2 = getLoc("SECOND_INPUT_2");
- private final String LOC_SECOND_LIST_SPAN = getLoc("SECOND_LIST_SPAN");
- private final String LOC_SECOND_LIST_SPAN_N = getLoc("SECOND_LIST_SPAN_N");
+ private final String LOC_SECOND = getLoc("SECOND");
+ private final String LOC_SECOND_INPUT_1 = getLoc("SECOND_INPUT_1");
+ private final String LOC_SECOND_INPUT_2 = getLoc("SECOND_INPUT_2");
+ private final String LOC_SECOND_LIST_SPAN = getLoc("SECOND_LIST_SPAN");
+ private final String LOC_SECOND_LIST_SPAN_N =
getLoc("SECOND_LIST_SPAN_N");
- private final String LOC_THIRD = getLoc("THIRD");
- private final String LOC_THIRD_INPUT_1 = getLoc("THIRD_INPUT_1");
- private final String LOC_THIRD_INPUT_2 = getLoc("THIRD_INPUT_2");
- private final String LOC_THIRD_LIST_SPAN = getLoc("THIRD_LIST_SPAN");
- private final String LOC_THIRD_LIST_SPAN_N = getLoc("THIRD_LIST_SPAN_N");
- private final String LOC_THIRD_CAPITAL = getLoc("THIRD_CAPITAL");
- private final String LOC_THIRD_SAVE_BUTTON = getLoc("THIRD_SAVE_BUTTON");
+ private final String LOC_THIRD = getLoc("THIRD");
+ private final String LOC_THIRD_INPUT_1 = getLoc("THIRD_INPUT_1");
+ private final String LOC_THIRD_INPUT_2 = getLoc("THIRD_INPUT_2");
+ private final String LOC_THIRD_LIST_SPAN = getLoc("THIRD_LIST_SPAN");
+ private final String LOC_THIRD_LIST_SPAN_N = getLoc("THIRD_LIST_SPAN_N");
+ private final String LOC_THIRD_CAPITAL = getLoc("THIRD_CAPITAL");
+ private final String LOC_THIRD_SAVE_BUTTON = getLoc("THIRD_SAVE_BUTTON");
- /**
- * Tests the first example. It checks the "readonly" and "style"
attribute
- * of the inplace select. Then it clicks into and out of the component and
- * verifies that nothing changed. Consequently it checks the number of items
- * in the component. In the end it selects the fourth item from the inplace
- * select and checks the text.
- */
- @Test
- public void testFirstInput() {
- scrollIntoView(LOC_FIRST, true);
+ /**
+ * Tests the first example. It checks the "readonly" and "style"
attribute
+ * of the inplace select. Then it clicks into and out of the component and
+ * verifies that nothing changed. Consequently it checks the number of items
+ * in the component. In the end it selects the fourth item from the inplace
+ * select and checks the text.
+ */
+ @Test
+ public void testFirstInput() {
+ scrollIntoView(LOC_FIRST, true);
- String text = selenium.getText(LOC_FIRST);
- assertTrue(text.equals("Click here to edit"), MSG_CLICK_HERE_TO_EDIT);
+ String text = selenium.getText(LOC_FIRST);
+ assertTrue(text.equals("Click here to edit"), MSG_CLICK_HERE_TO_EDIT);
- String attr = selenium.getAttribute(LOC_FIRST_INPUT_1 + "@readonly");
- assertTrue(attr.equals("readonly"), MSG_READ_ONLY);
+ String attr = selenium.getAttribute(LOC_FIRST_INPUT_1 + "@readonly");
+ assertTrue(attr.equals("readonly"), MSG_READ_ONLY);
- attr = selenium.getAttribute(LOC_FIRST_INPUT_2 + "@style");
- assertTrue(attr.contains("display: none;"), MSG_DISPLAY_NONE);
+ assertFalse(isDisplayed(LOC_FIRST_INPUT_2), MSG_DISPLAY_NONE);
- // expand and collapse the inplace select
- selenium.click(LOC_FIRST_INPUT_1);
- selenium.click(LOC_FIRST_INPUT_2);
+ // expand and collapse the inplace select
+ selenium.click(LOC_FIRST_INPUT_1);
+ selenium.click(LOC_FIRST_INPUT_2);
- text = selenium.getText(LOC_FIRST);
- assertTrue(text.equals("Click here to edit"), MSG_CLICK_HERE_TO_EDIT);
+ text = selenium.getText(LOC_FIRST);
+ assertTrue(text.equals("Click here to edit"), MSG_CLICK_HERE_TO_EDIT);
- // expand the component and select "Option 4"
- selenium.click(LOC_FIRST);
-
- int count = selenium.getXpathCount(LOC_FIRST_LIST_SPAN).intValue();
- assertEquals(count, 5, MSG_COUNT_OF_ITEMS);
-
- selenium.mouseMove(String.format(LOC_FIRST_LIST_SPAN_N, 4));
+ // expand the component and select "Option 4"
+ selenium.click(LOC_FIRST);
- // TODO explore whether this isn't too low-level
- selenium.getEval(format("selenium.browserbot.findElement(\"{0}\").component.save()",
LOC_FIRST_SELECT_VIEW));
+ int count = selenium.getXpathCount(LOC_FIRST_LIST_SPAN).intValue();
+ assertEquals(count, 5, MSG_COUNT_OF_ITEMS);
- // another way to select it
- // selenium.selectWindow(null); // select the main window
- // selenium.windowFocus();
- // selenium.keyPressNative(Integer.toString(KeyEvent.VK_ENTER));
+ selenium.mouseMove(format(LOC_FIRST_LIST_SPAN_N, 4));
- text = selenium.getText(LOC_FIRST);
- assertTrue(text.equals("Option 4"), MSG_OPTION4_SELECTED);
- }
+ // TODO explore whether this isn't too low-level
+
selenium.getEval(format("selenium.browserbot.findElement(\"{0}\").component.save()",
LOC_FIRST_SELECT_VIEW));
- /**
- * Tests the second example. It checks the "readonly" and "style"
attribute
- * of the inplace select. Then it clicks into and out of the component and
- * verifies that nothing changed. Consequently it checks the number of items
- * in the component. In the end it selects the fourth item from the inplace
- * select and checks the text.
- */
- @Test
- public void testSecondInput() {
- scrollIntoView(LOC_SECOND, true);
+ // another way to select it
+ // selenium.selectWindow(null); // select the main window
+ // selenium.windowFocus();
+ // selenium.keyPressNative(Integer.toString(KeyEvent.VK_ENTER));
- String text = selenium.getText(LOC_SECOND);
- assertTrue(text.equals("Double Click to edit"),
- MSG_DOUBLE_CLICK_TO_EDIT);
+ text = selenium.getText(LOC_FIRST);
+ assertTrue(text.equals("Option 4"), MSG_OPTION4_SELECTED);
+ }
- String attr = selenium.getAttribute(LOC_SECOND_INPUT_1 + "@readonly");
- assertTrue(attr.equals("readonly"), MSG_READ_ONLY);
+ /**
+ * Tests the second example. It checks the "readonly" and "style"
attribute
+ * of the inplace select. Then it clicks into and out of the component and
+ * verifies that nothing changed. Consequently it checks the number of items
+ * in the component. In the end it selects the fourth item from the inplace
+ * select and checks the text.
+ */
+ @Test
+ public void testSecondInput() {
+ scrollIntoView(LOC_SECOND, true);
- attr = selenium.getAttribute(LOC_SECOND_INPUT_2 + "@style");
- assertTrue(attr.contains("display: none;"), MSG_DISPLAY_NONE);
+ String text = selenium.getText(LOC_SECOND);
+ assertTrue(text.equals("Double Click to edit"),
MSG_DOUBLE_CLICK_TO_EDIT);
- // expand and collapse the inplace select
- selenium.click(LOC_SECOND_INPUT_1);
- selenium.click(LOC_SECOND_INPUT_2);
+ String attr = selenium.getAttribute(LOC_SECOND_INPUT_1 + "@readonly");
+ assertTrue(attr.equals("readonly"), MSG_READ_ONLY);
- int count = selenium.getXpathCount(LOC_SECOND_LIST_SPAN).intValue();
- assertEquals(count, 50, MSG_COUNT_OF_ITEMS);
+ assertFalse(isDisplayed(LOC_SECOND_INPUT_2), MSG_DISPLAY_NONE);
- text = selenium.getText(LOC_SECOND);
- assertTrue(text.equals("Double Click to edit"),
- MSG_DOUBLE_CLICK_TO_EDIT);
+ // expand and collapse the inplace select
+ selenium.click(LOC_SECOND_INPUT_1);
+ selenium.click(LOC_SECOND_INPUT_2);
- // expand the inplace select and click "Arkansas"
- selenium.mouseMove(String.format(LOC_SECOND_LIST_SPAN_N, 4));
- selenium.mouseDown(LOC_SECOND_OK_BUTTON);
+ int count = selenium.getXpathCount(LOC_SECOND_LIST_SPAN).intValue();
+ assertEquals(count, 50, MSG_COUNT_OF_ITEMS);
- text = selenium.getText(LOC_SECOND);
- assertTrue(text.equals("Arkansas"), MSG_ARKANSAS_SELECTED);
- }
+ text = selenium.getText(LOC_SECOND);
+ assertTrue(text.equals("Double Click to edit"),
MSG_DOUBLE_CLICK_TO_EDIT);
- /**
- * Tests the third example. It checks the "readonly" and "style"
attribute
- * of the inplace select. Then it clicks into and out of the component and
- * verifies that nothing changed. Consequently it checks the number of items
- * in the component. In the end it selects the fourth item from the inplace
- * select and checks the text.
- */
- @Test
- public void testThirdInput() {
- scrollIntoView(LOC_THIRD, true);
+ // expand the inplace select and click "Arkansas"
+ selenium.mouseMove(format(LOC_SECOND_LIST_SPAN_N, 4));
+ selenium.mouseDown(LOC_SECOND_OK_BUTTON);
- String text = selenium.getText(LOC_THIRD);
- assertTrue(text.equals("Click here to edit"), MSG_CLICK_HERE_TO_EDIT);
+ text = selenium.getText(LOC_SECOND);
+ assertTrue(text.equals("Arkansas"), MSG_ARKANSAS_SELECTED);
+ }
- String attr = selenium.getAttribute(LOC_THIRD_INPUT_1 + "@readonly");
- assertTrue(attr.equals("readonly"), MSG_READ_ONLY);
+ /**
+ * Tests the third example. It checks the "readonly" and "style"
attribute
+ * of the inplace select. Then it clicks into and out of the component and
+ * verifies that nothing changed. Consequently it checks the number of items
+ * in the component. In the end it selects the fourth item from the inplace
+ * select and checks the text.
+ */
+ @Test
+ public void testThirdInput() {
+ scrollIntoView(LOC_THIRD, true);
- attr = selenium.getAttribute(LOC_THIRD_INPUT_2 + "@style");
- assertTrue(attr.contains("display: none;"), MSG_DISPLAY_NONE);
+ String text = selenium.getText(LOC_THIRD);
+ assertTrue(text.equals("Click here to edit"), MSG_CLICK_HERE_TO_EDIT);
- // expand and collapse the inplace select
- selenium.click(LOC_THIRD_INPUT_1);
- selenium.click(LOC_THIRD_INPUT_2);
+ String attr = selenium.getAttribute(LOC_THIRD_INPUT_1 + "@readonly");
+ assertTrue(attr.equals("readonly"), MSG_READ_ONLY);
- int count = selenium.getXpathCount(LOC_THIRD_LIST_SPAN).intValue();
- assertEquals(count, 50, MSG_COUNT_OF_ITEMS);
+ assertFalse(isDisplayed(LOC_THIRD_INPUT_2), MSG_DISPLAY_NONE);
- text = selenium.getText(LOC_THIRD);
- assertTrue(text.endsWith("Click here to edit"), MSG_CLICK_HERE_TO_EDIT);
+ // expand and collapse the inplace select
+ selenium.click(LOC_THIRD_INPUT_1);
+ selenium.click(LOC_THIRD_INPUT_2);
- // remember for waiting
- text = selenium.getText(LOC_THIRD_CAPITAL);
-
- // select "Arkansas"
- selenium.mouseMove(String.format(LOC_THIRD_LIST_SPAN_N, 4));
- selenium.mouseDown(LOC_THIRD_SAVE_BUTTON);
+ int count = selenium.getXpathCount(LOC_THIRD_LIST_SPAN).intValue();
+ assertEquals(count, 50, MSG_COUNT_OF_ITEMS);
- // wait for remembered value change
- text = waitForTextChangesAndReturn(LOC_THIRD_CAPITAL, text);
- assertTrue(text.endsWith("Little Rock"), MSG_LITTLE_ROCK);
-
- text = selenium.getText(LOC_THIRD);
- assertTrue(text.equals("Arkansas"), MSG_ARKANSAS_SELECTED);
- }
+ text = selenium.getText(LOC_THIRD);
+ assertTrue(text.endsWith("Click here to edit"),
MSG_CLICK_HERE_TO_EDIT);
- /**
- * Tests the "View Source". It checks that the source code is not visible,
- * clicks on the link, and checks the first 2 components of source code,
- * i.e. that the source code begins with "<ui:composition".
- */
- @Test
- public void testFirstInputSource() {
- abstractTestSource(1, 1, "<", "ui:composition");
- }
+ // remember for waiting
+ text = selenium.getText(LOC_THIRD_CAPITAL);
- /**
- * Tests the "View Source". It checks that the source code is not visible,
- * clicks on the link, and checks the first 2 components of source code,
- * i.e. that the source code begins with "<ui:composition".
- */
- @Test
- public void testSecondInputSource() {
- abstractTestSource(2, 2, "<", "ui:composition");
- }
+ // select "Arkansas"
+ selenium.mouseMove(format(LOC_THIRD_LIST_SPAN_N, 4));
+ selenium.mouseDown(LOC_THIRD_SAVE_BUTTON);
- /**
- * Tests the "View Source". It checks that the source code is not visible,
- * clicks on the link, and checks the first 2 components of source code,
- * i.e. that the source code begins with "<ui:composition".
- */
- @Test
- public void testThirdInputSource() {
- abstractTestSource(3, 1, "<", "ui:composition");
- }
+ // wait for remembered value change
+ text = waitForTextChangesAndReturn(LOC_THIRD_CAPITAL, text);
+ assertTrue(text.endsWith("Little Rock"), MSG_LITTLE_ROCK);
- /**
- * Loads the page containing the calendar component.
- */
- @BeforeMethod
- private void loadPage() {
- super.loadPage("richInputs", 7, 1, MSG_COMPONENT_DESCRIPTION);
- }
+ text = selenium.getText(LOC_THIRD);
+ assertTrue(text.equals("Arkansas"), MSG_ARKANSAS_SELECTED);
+ }
+
+ /**
+ * Tests the "View Source" in the first example. It checks that the source
+ * code is not visible, clicks on the link, and checks 7 lines of source
+ * code.
+ */
+ @Test
+ public void testFirstExampleSource() {
+ String[] strings = new String[] { "<ui:composition
xmlns=\"http://www.w3.org/1999/xhtml\"",
+ "<rich:inplaceSelect
value=\"#{inplaceComponentsBean.inputValue}\"",
+ "defaultLabel=\"Click here to edit\">",
"<f:selectItem itemValue=\"0\" itemLabel=\"Option 1\"
/>",
+ "</rich:inplaceSelect>", "<rich:spacer
width=\"100%\" height=\"20px\"/>",
"</ui:composition>", };
+
+ abstractTestSource(1, "View Source", strings);
+ }
+
+ /**
+ * Tests the "View Source" in the second example. It checks that the
source
+ * code is not visible, clicks on the link, and checks 10 lines of source
+ * code.
+ */
+ @Test
+ public void testSecondExampleSource() {
+ String[] strings = new String[] { "<ui:composition
xmlns=\"http://www.w3.org/1999/xhtml\"", "<style>",
+ "<h:panelGroup style=\"width:200px;\"
layout=\"block\">",
+ "<rich:inplaceSelect
value=\"#{inplaceComponentsBean.inputValue}\"",
+ "defaultLabel=\"Double Click to edit\"
openOnEdit=\"true\"",
+ "showControls=\"true\" editEvent=\"ondblclick\"
layout=\"block\"",
+ "viewClass=\"inplace\"
changedClass=\"inplace\"",
+ "changedHoverClass=\"hover\"
viewHoverClass=\"hover\">",
+ " <f:selectItems
value=\"#{capitalsBean.capitalsOptions}\" />",
+ "<rich:spacer width=\"100%\" height=\"20px\"
/>", };
+
+ abstractTestSource(2, "View Source", strings);
+ }
+
+ /**
+ * Tests the "View Source" in the third example. It checks that the source
+ * code is not visible, clicks on the link, and checks 17 lines of source
+ * code.
+ */
+ @Test
+ public void testThirdExampleSource() {
+ String[] strings = new String[] { "<ui:composition
xmlns=\"http://www.w3.org/1999/xhtml\"", "<style>",
+ "<h:panelGrid columns=\"3\"
width=\"500px;\">",
+ "<rich:inplaceSelect
value=\"#{inplaceComponentsBean.inputValue}\"",
+ "defaultLabel=\"Click here to edit\"
showControls=\"true\"",
+ "controlsHorizontalPosition=\"left\"
controlsVerticalPosition=\"bottom\"",
"id=\"inplaceSelect\">",
+ "<f:facet name=\"controls\">", "<button
onmousedown=\"#{rich:component('inplaceSelect')}.save();\"",
+ "type=\"button\">Save</button>",
+ "<button
onmousedown=\"#{rich:component('inplaceSelect')}.cancel();\"",
+ "type=\"button\">Cancel</button>",
"<f:selectItems value=\"#{capitalsBean.capitalsOptions}\" />",
+ "<a4j:support event=\"onviewactivated\"
reRender=\"output\" />", "<h:outputText
id=\"output\"",
+ "value=\"Current State Capital:
#{inplaceComponentsBean.inputValue}\"",
+ "style=\"font-weight:bold;\" />", };
+
+ abstractTestSource(3, "View Source", strings);
+ }
+
+ /**
+ * Loads the page containing the calendar component.
+ */
+ @SuppressWarnings("unused")
+ @BeforeMethod
+ private void loadPage() {
+ openComponent("Inplace Select");
+ }
}
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inputNumberSlider/InputNumberSliderTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inputNumberSlider/InputNumberSliderTestCase.java 2009-09-09
13:44:10 UTC (rev 15505)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/inputNumberSlider/InputNumberSliderTestCase.java 2009-09-09
14:52:04 UTC (rev 15506)
@@ -1,3 +1,21 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
package org.jboss.richfaces.integrationTest.inputNumberSlider;
import static org.testng.Assert.assertEquals;
@@ -18,42 +36,33 @@
AbstractSeleniumRichfacesTestCase {
// messages
- private final String MSG_COMPONENT_DESCRIPTION =
getMess("COMPONENT_DESCRIPTION");
- private final String MSG_HANDLE_N_PX = getMess("HANDLE_N_PX");
- private final String MSG_TIP_N_PX = getMess("TIP_N_PX");
- private final String MSG_TIP_SHOULD_BE_VISIBLE =
getMess("TIP_SHOULD_BE_VISIBLE");
- private final String MSG_TIP_SHOULD_NOT_BE_VISIBLE =
getMess("TIP_SHOULD_NOT_BE_VISIBLE");
- private final String MSG_OFFSETS_SHOULD_BE_THE_SAME =
getMess("OFFSETS_SHOULD_BE_THE_SAME");
- private final String MSG_TIP_FIRST_HALF = getMess("TIP_FIRST_HALF");
- private final String MSG_TIP_SECOND_HALF = getMess("TIP_SECOND_HALF");
- private final String MSG_HANDLE_FIRST_HALF = getMess("HANDLE_FIRST_HALF");
- private final String MSG_HANDLE_SECOND_HALF = getMess("HANDLE_SECOND_HALF");
- private final String MSG_VALUE_IN_INPUT = getMess("VALUE_IN_INPUT");
+ private final String MSG_HANDLE_N_PX = getMsg("HANDLE_N_PX");
+ private final String MSG_TIP_N_PX = getMsg("TIP_N_PX");
+ private final String MSG_TIP_SHOULD_BE_VISIBLE =
getMsg("TIP_SHOULD_BE_VISIBLE");
+ private final String MSG_TIP_SHOULD_NOT_BE_VISIBLE =
getMsg("TIP_SHOULD_NOT_BE_VISIBLE");
+ private final String MSG_OFFSETS_SHOULD_BE_THE_SAME =
getMsg("OFFSETS_SHOULD_BE_THE_SAME");
+ private final String MSG_TIP_FIRST_HALF = getMsg("TIP_FIRST_HALF");
+ private final String MSG_TIP_SECOND_HALF = getMsg("TIP_SECOND_HALF");
+ private final String MSG_HANDLE_FIRST_HALF = getMsg("HANDLE_FIRST_HALF");
+ private final String MSG_HANDLE_SECOND_HALF = getMsg("HANDLE_SECOND_HALF");
+ private final String MSG_VALUE_IN_INPUT = getMsg("VALUE_IN_INPUT");
// locators
- private final String LOC_FIRST = String.format(getLoc("SLIDER_N"), 1);
- private final String LOC_FIRST_HANDLE = String.format(
- getLoc("SLIDER_N_HANDLE"), 1);
- private final String LOC_FIRST_TIP = String.format(getLoc("SLIDER_N_TIP"),
- 1);
- private final String LOC_FIRST_INPUT = String.format(
- getLoc("SLIDER_N_INPUT"), 1);
+ private final String LOC_EXAMPLE_HEADER = getLoc("EXAMPLE_HEADER");
+ private final String LOC_FIRST = format(getLoc("SLIDER_N"), 1);
+ private final String LOC_FIRST_HANDLE = format(getLoc("SLIDER_N_HANDLE"), 1);
+ private final String LOC_FIRST_TIP = format(getLoc("SLIDER_N_TIP"), 1);
+ private final String LOC_FIRST_INPUT = format(getLoc("SLIDER_N_INPUT"), 1);
- private final String LOC_SECOND = String.format(getLoc("SLIDER_N"), 2);
- private final String LOC_SECOND_HANDLE = String.format(
- getLoc("SLIDER_N_HANDLE"), 2);
- private final String LOC_SECOND_TIP = String.format(getLoc("SLIDER_N_TIP"),
- 2);
- private final String LOC_SECOND_INPUT = String.format(
- getLoc("SLIDER_N_INPUT"), 2);
+ private final String LOC_SECOND = format(getLoc("SLIDER_N"), 2);
+ private final String LOC_SECOND_HANDLE = format(getLoc("SLIDER_N_HANDLE"),
2);
+ private final String LOC_SECOND_TIP = format(getLoc("SLIDER_N_TIP"), 2);
+ private final String LOC_SECOND_INPUT = format(getLoc("SLIDER_N_INPUT"), 2);
- private final String LOC_THIRD = String.format(getLoc("SLIDER_N"), 3);
- private final String LOC_THIRD_HANDLE = String.format(
- getLoc("SLIDER_N_HANDLE"), 3);
- private final String LOC_THIRD_TIP = String.format(getLoc("SLIDER_N_TIP"),
- 3);
- private final String LOC_THIRD_INPUT = String.format(
- getLoc("SLIDER_N_INPUT"), 3);
+ private final String LOC_THIRD = format(getLoc("SLIDER_N"), 3);
+ private final String LOC_THIRD_HANDLE = format(getLoc("SLIDER_N_HANDLE"), 3);
+ private final String LOC_THIRD_TIP = format(getLoc("SLIDER_N_TIP"), 3);
+ private final String LOC_THIRD_INPUT = format(getLoc("SLIDER_N_INPUT"), 3);
/**
* Tests clicking on the first slider. First, it checks the offset of the handler and
@@ -63,24 +72,12 @@
*/
@Test
public void testFirstSliderMouse() {
- scrollIntoView(LOC_FIRST, true);
+ assertTrue(Math.abs(getOffset(LOC_FIRST_HANDLE + "@style") - 75) < 2,
format(MSG_HANDLE_N_PX, 75));
+ assertTrue(Math.abs(getOffset(LOC_FIRST_TIP + "@style") - 75) < 2,
format(MSG_TIP_N_PX, 75));
+ assertFalse(isDisplayed(LOC_FIRST_TIP), MSG_TIP_SHOULD_NOT_BE_VISIBLE);
- // TODO find out why it isn't offset by 75px but 74px
- assertTrue(Math.abs(getOffset(LOC_FIRST_HANDLE + "@style") - 75) < 2,
- String.format(MSG_HANDLE_N_PX, 75));
-
- assertTrue(Math.abs(getOffset(LOC_FIRST_TIP + "@style") - 75) < 2,
- String.format(MSG_TIP_N_PX, 75));
-
- String attr = selenium.getAttribute(LOC_FIRST_TIP + "@style");
- assertFalse(!attr.contains("display: none;"),
- MSG_TIP_SHOULD_NOT_BE_VISIBLE);
-
selenium.mouseDownAt(LOC_FIRST, "20,3");
-
- attr = selenium.getAttribute(LOC_FIRST_TIP + "@style");
- assertTrue(!attr.contains("display: none;"), MSG_TIP_SHOULD_BE_VISIBLE);
-
+ assertTrue(isDisplayed(LOC_FIRST_TIP), MSG_TIP_SHOULD_BE_VISIBLE);
selenium.mouseUp(LOC_FIRST);
int tipOffset = getOffset(LOC_FIRST_TIP + "@style");
@@ -102,8 +99,6 @@
*/
@Test
public void testFirstSliderKeyboard() {
- scrollIntoView(LOC_FIRST, true);
-
selenium.type(LOC_FIRST_INPUT, "10");
int tipOffset = getOffset(LOC_FIRST_TIP + "@style");
int handleOffset = getOffset(LOC_FIRST_HANDLE + "@style");
@@ -149,26 +144,13 @@
*/
@Test
public void testSecondSlider() {
- scrollIntoView(LOC_SECOND, true);
+ assertTrue(Math.abs(getOffset(LOC_SECOND_HANDLE + "@style") - 96) < 2,
format(MSG_HANDLE_N_PX, 96));
+ assertTrue(Math.abs(getOffset(LOC_SECOND_TIP + "@style") - 96) < 2,
format(MSG_TIP_N_PX, 96));
+ assertFalse(isDisplayed(LOC_SECOND_TIP), MSG_TIP_SHOULD_NOT_BE_VISIBLE);
- // TODO find out why it isn't offset by 96px
- assertTrue(Math.abs(getOffset(LOC_SECOND_HANDLE + "@style") - 96) < 2,
- String.format(MSG_HANDLE_N_PX, 96));
-
- assertTrue(Math.abs(getOffset(LOC_SECOND_TIP + "@style") - 96) < 2,
- String.format(MSG_TIP_N_PX, 96));
-
- String attr = selenium.getAttribute(LOC_SECOND_TIP + "@style");
- assertFalse(!attr.contains("display: none;"),
- MSG_TIP_SHOULD_NOT_BE_VISIBLE);
-
selenium.mouseDownAt(LOC_SECOND, "20,3");
-
- attr = selenium.getAttribute(LOC_SECOND_TIP + "@style");
// it is a slider without tip so it cannot be visible
- assertFalse(!attr.contains("display: none;"),
- MSG_TIP_SHOULD_NOT_BE_VISIBLE);
-
+ assertFalse(isDisplayed(LOC_SECOND_TIP), MSG_TIP_SHOULD_NOT_BE_VISIBLE);
selenium.mouseUp(LOC_SECOND);
int tipOffset = getOffset(LOC_SECOND_TIP + "@style");
@@ -188,26 +170,13 @@
*/
@Test
public void testThirdSliderMouse() {
- scrollIntoView(LOC_THIRD, true);
+ assertTrue(Math.abs(getOffset(LOC_THIRD_HANDLE + "@style") - 225) < 2,
format(MSG_HANDLE_N_PX, 225));
+ assertTrue(Math.abs(getOffset(LOC_THIRD_TIP + "@style") - 225) < 2,
format(MSG_TIP_N_PX, 225));
+ assertFalse(isDisplayed(LOC_THIRD_TIP), MSG_TIP_SHOULD_NOT_BE_VISIBLE);
- // TODO find out why it isn't offset by 75px but 74px
- assertTrue(Math.abs(getOffset(LOC_THIRD_HANDLE + "@style") - 225) < 2,
- String.format(MSG_HANDLE_N_PX, 225));
-
- assertTrue(Math.abs(getOffset(LOC_THIRD_TIP + "@style") - 225) < 2,
- String.format(MSG_TIP_N_PX, 225));
-
- String attr = selenium.getAttribute(LOC_THIRD_TIP + "@style");
- assertFalse(!attr.contains("display: none;"),
- MSG_TIP_SHOULD_NOT_BE_VISIBLE);
-
selenium.mouseDownAt(LOC_THIRD, "20,3");
-
- attr = selenium.getAttribute(LOC_THIRD_TIP + "@style");
// slider does not use the tip so it has to be invisible
- assertFalse(!attr.contains("display: none;"),
- MSG_TIP_SHOULD_NOT_BE_VISIBLE);
-
+ assertFalse(isDisplayed(LOC_THIRD_TIP), MSG_TIP_SHOULD_NOT_BE_VISIBLE);
selenium.mouseUp(LOC_THIRD);
int tipOffset = getOffset(LOC_THIRD_TIP + "@style");
@@ -230,8 +199,6 @@
*/
@Test
public void testThirdSliderKeyboard() {
- scrollIntoView(LOC_THIRD, true);
-
selenium.type(LOC_THIRD_INPUT, "10"); // 10 -> 0
int tipOffset = getOffset(LOC_THIRD_TIP + "@style");
int handleOffset = getOffset(LOC_THIRD_HANDLE + "@style");
@@ -277,16 +244,26 @@
assertEquals(value, 550, MSG_VALUE_IN_INPUT);
}
- /**
- * Tests the "View Source". It checks that the source code is not visible,
- * clicks on the link, and checks the first 2 components of source code,
- * i.e. that the source code begins with "<ui:composition".
- */
- @Test
- public void testSliderSource() {
- abstractTestSource(1, 1, "<", "ui:composition");
- }
+ /**
+ * Tests the "View Source". It checks that the source code is not visible,
+ * clicks on the link, and checks 9 lines of source code.
+ */
+ @Test
+ public void testExampleSource() {
+ String[] strings = new String[] { "<ui:composition
xmlns=\"http://www.w3.org/1999/xhtml\"",
+ "<p>Here is an example of default
inputNumberSlider:</p>",
+ "<rich:inputNumberSlider value=\"50\" />",
+ "<p>Here is \"minimalistic\"
input:</p>",
+ "<rich:inputNumberSlider value=\"50\"
showInput=\"false\"",
+ "enableManualInput=\"false\"
showBoundaryValues=\"false\"",
+ "showToolTip=\"false\" />",
+ "<rich:inputNumberSlider value=\"500\"
width=\"500\" maxValue=\"1000\"",
+ "step=\"50\" showToolTip=\"false\" />",
+ };
+ abstractTestSource(1, "View Source", strings);
+ }
+
/**
* Returns the offset of the element. It requires a locator for an
* attribute, e.g. //div@style. It returns the 'left' attribute, e.g. for
@@ -301,10 +278,12 @@
}
/**
- * Loads the page containing the calendar component.
- */
- @BeforeMethod
- private void loadPage() {
- super.loadPage("richInputs", 8, MSG_COMPONENT_DESCRIPTION);
- }
+ * Loads the page containing needed component.
+ */
+ @SuppressWarnings("unused")
+ @BeforeMethod
+ private void loadPage() {
+ openComponent("Input Number Slider");
+ scrollIntoView(LOC_EXAMPLE_HEADER, true);
+ }
}
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inplaceSelect/locators.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inplaceSelect/locators.properties 2009-09-09
13:44:10 UTC (rev 15505)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inplaceSelect/locators.properties 2009-09-09
14:52:04 UTC (rev 15506)
@@ -2,20 +2,20 @@
FIRST_SELECT_VIEW=//fieldset[1]//*[contains(@class,'rich-inplace-select-view')]
FIRST_INPUT_1=//fieldset[1]/div/span/input[1]
FIRST_INPUT_2=//fieldset[1]/div/span/input[2]
-FIRST_LIST_SPAN_N=//*[@class\='rich-inplace-select-list-scroll']/span[starts-with(text(),'Option')][%d]
+FIRST_LIST_SPAN_N=//*[@class\='rich-inplace-select-list-scroll']/span[starts-with(text(),'Option')][{0}]
FIRST_LIST_SPAN=//*[@class\='rich-inplace-select-list-scroll']/span[starts-with(text(),'Option')]
SECOND=//fieldset[2]/div/div[1]/div
SECOND_INPUT_1=//fieldset[2]/div/div[1]/div/input[1]
SECOND_INPUT_2=//fieldset[2]/div/div[1]/div/input[2]
-SECOND_LIST_SPAN_N=//*[not(contains(@class,'rich-inplace-select-view'))]/*/*/*/*[@class\='rich-inplace-select-list-scroll']/span[text()\='Alabama']/../span[%d]
+SECOND_LIST_SPAN_N=//*[not(contains(@class,'rich-inplace-select-view'))]/*/*/*/*[@class\='rich-inplace-select-list-scroll']/span[text()\='Alabama']/../span[{0}]
SECOND_LIST_SPAN=//*[not(contains(@class,'rich-inplace-select-view'))]/*/*/*/*[@class\='rich-inplace-select-list-scroll']/span[text()\='Alabama']/../span
SECOND_OK_BUTTON=//fieldset[2]/div/div[1]/div/div/div[2]/input[1]
THIRD=//fieldset[3]/div/form/table/tbody/tr/td[2]/span
THIRD_INPUT_1=//fieldset[3]/div/form/table/tbody/tr/td[2]/span/input[1]
THIRD_INPUT_2=//fieldset[3]/div/form/table/tbody/tr/td[2]/span/input[2]
-THIRD_LIST_SPAN_N=//*[not(contains(@class,'rich-inplace-select-view'))]/*/*/*/*[@class\='rich-inplace-select-list-scroll']/span[text()\='Alabama']/../span[%d]
+THIRD_LIST_SPAN_N=//*[not(contains(@class,'rich-inplace-select-view'))]/*/*/*/*[@class\='rich-inplace-select-list-scroll']/span[text()\='Alabama']/../span[{0}]
THIRD_LIST_SPAN=//*[not(contains(@class,'rich-inplace-select-view'))]/*/*/*/*[@class\='rich-inplace-select-list-scroll']/span[text()\='Alabama']/../span
THIRD_CAPITAL=//fieldset[3]/div/form/table/tbody/tr/td[3]/span
THIRD_SAVE_BUTTON=//fieldset[3]/div/form/table/tbody/tr/td[2]/span/div/button[1]
\ No newline at end of file
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inplaceSelect/messages.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inplaceSelect/messages.properties 2009-09-09
13:44:10 UTC (rev 15505)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inplaceSelect/messages.properties 2009-09-09
14:52:04 UTC (rev 15506)
@@ -1,4 +1,3 @@
-COMPONENT_DESCRIPTION=Inplace Selectis a simple input component which displays current
value as outputText
CLICK_HERE_TO_EDIT=The component should contain "Click here to edit".
DOUBLE_CLICK_TO_EDIT=The component should contain "Double click to edit".
READ_ONLY=The input field of the component should be read only.
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inputNumberSlider/locators.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inputNumberSlider/locators.properties 2009-09-09
13:44:10 UTC (rev 15505)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inputNumberSlider/locators.properties 2009-09-09
14:52:04 UTC (rev 15506)
@@ -1,4 +1,5 @@
-SLIDER_N=//fieldset[1]/div/table[%d]/tbody/tr[2]/td/table/tbody/tr/td
-SLIDER_N_HANDLE=//fieldset[1]/div/table[%d]/tbody/tr[2]/td/table/tbody/tr/td/div[1]/div[2]
-SLIDER_N_TIP=//fieldset[1]/div/table[%d]/tbody/tr[2]/td/table/tbody/tr/td/div[1]/div[1]
-SLIDER_N_INPUT=//fieldset[1]/div/table[%d]/tbody/tr[1]/td[3]/input
+EXAMPLE_HEADER=//fieldset/legend
+SLIDER_N=//fieldset[1]/div/table[{0}]/tbody/tr[2]/td/table/tbody/tr/td
+SLIDER_N_HANDLE=//fieldset[1]/div/table[{0}]/tbody/tr[2]/td/table/tbody/tr/td/div[1]/div[2]
+SLIDER_N_TIP=//fieldset[1]/div/table[{0}]/tbody/tr[2]/td/table/tbody/tr/td/div[1]/div[1]
+SLIDER_N_INPUT=//fieldset[1]/div/table[{0}]/tbody/tr[1]/td[3]/input
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inputNumberSlider/messages.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inputNumberSlider/messages.properties 2009-09-09
13:44:10 UTC (rev 15505)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/inputNumberSlider/messages.properties 2009-09-09
14:52:04 UTC (rev 15506)
@@ -1,6 +1,5 @@
-COMPONENT_DESCRIPTION=InputNumberSlider is a highly customizable component
-HANDLE_N_PX=Handle should be offset by %d pixels.
-TIP_N_PX=The box with a tip should be offset by %d pixels.
+HANDLE_N_PX=Handle should be offset by {0} pixels.
+TIP_N_PX=The box with a tip should be offset by {0} pixels.
TIP_SHOULD_BE_VISIBLE=The box with a tip should be visible.
TIP_SHOULD_NOT_BE_VISIBLE=The box with a tip should not be visible.
OFFSETS_SHOULD_BE_THE_SAME=Tip and handle's offsets should be the same.