Author: ppitonak(a)redhat.com
Date: 2011-02-02 12:08:33 -0500 (Wed, 02 Feb 2011)
New Revision: 21397
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/simple.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java
Log:
https://issues.jboss.org/browse/RF-9037
* added 9 new tests for inplace select
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java 2011-02-02
16:01:47 UTC (rev 21396)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java 2011-02-02
17:08:33 UTC (rev 21397)
@@ -81,7 +81,18 @@
// TODO has to be tested in another way
attributes.remove("converter");
+ attributes.remove("converterMessage");
+ attributes.remove("required");
+ attributes.remove("requiredMessage");
attributes.remove("validator");
+ attributes.remove("validatorMessage");
+ attributes.remove("valueChangeListener");
+
+ // TODO remove as soon as RF-10411 is resolved
+ attributes.setAttribute("changedStateClass", null);
+ attributes.setAttribute("disabledStateClass", null);
+ attributes.setAttribute("editStateClass", null);
+ attributes.setAttribute("readyStateClass", null);
}
public Attributes getAttributes() {
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/simple.xhtml 2011-02-02
16:01:47 UTC (rev 21396)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/simple.xhtml 2011-02-02
17:08:33 UTC (rev 21397)
@@ -49,6 +49,7 @@
editEvent="#{richInplaceSelectBean.attributes['editEvent'].value}"
editStateClass="#{richInplaceSelectBean.attributes['editStateClass'].value}"
immediate="#{richInplaceSelectBean.attributes['immediate'].value}"
+
inputWidth="#{richInplaceSelectBean.attributes['inputWidth'].value}"
itemClass="#{richInplaceSelectBean.attributes['itemClass'].value}"
listClass="#{richInplaceSelectBean.attributes['listClass'].value}"
listHeight="#{richInplaceSelectBean.attributes['listHeight'].value}"
@@ -98,6 +99,7 @@
selectItemClass="#{richInplaceSelectBean.attributes['selectItemClass'].value}"
showControls="#{richInplaceSelectBean.attributes['showControls'].value}"
state="#{richInplaceSelectBean.attributes['state'].value}"
+
style="#{richInplaceSelectBean.attributes['style'].value}"
tabindex="#{richInplaceSelectBean.attributes['tabindex'].value}"
validatorMessage="#{richInplaceSelectBean.attributes['validatorMessage'].value}"
value="#{richInplaceSelectBean.attributes['value'].value}"
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java 2011-02-02
16:01:47 UTC (rev 21396)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java 2011-02-02
17:08:33 UTC (rev 21397)
@@ -30,9 +30,12 @@
import static org.testng.Assert.assertTrue;
import java.net.URL;
+import javax.faces.event.PhaseId;
import org.jboss.test.selenium.css.CssProperty;
import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.EventFiredCondition;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
@@ -101,6 +104,21 @@
}
@Test
+ public void testChangedStateClass() {
+ selenium.type(pjq("input[id$=changedStateClassInput]"),
"metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ selenium.click(options.format(10));
+ guardXhr(selenium).fireEvent(input, Event.BLUR);
+ waitGui.failWith("Output did not
change.").until(textEquals.locator(output).text("Hawaii"));
+
+ JQueryLocator elementWhichHasntThatClass = jq(select.getRawLocator() +
":not(.metamer-ftest-class)");
+ assertTrue(selenium.isElementPresent(select));
+ assertFalse(selenium.isElementPresent(elementWhichHasntThatClass));
+ }
+
+ @Test
public void testDefaultLabel() {
selenium.type(pjq("input[type=text][id$=defaultLabelInput]"), "new
label");
selenium.waitForPageToLoad();
@@ -117,6 +135,31 @@
}
@Test
+ public void testDisabled() {
+
selenium.click(pjq("input[type=radio][name$=disabledInput][value=true]"));
+ selenium.waitForPageToLoad();
+
+ selenium.type(pjq("input[type=text][id$=valueInput]"),
"Hawaii");
+ selenium.waitForPageToLoad();
+
+ assertTrue(selenium.isElementPresent(select), "Inplace input is not on the
page.");
+ assertTrue(selenium.isElementPresent(label), "Default label should be
present on the page.");
+ assertEquals(selenium.getText(label), "Hawaii", "Default
label");
+ assertFalse(selenium.isElementPresent(input), "Input should not be present
on the page.");
+ assertFalse(selenium.isElementPresent(okButton), "OK button should not be
present on the page.");
+ assertFalse(selenium.isElementPresent(cancelButton), "Cancel button should
not be present on the page.");
+ assertFalse(selenium.isElementPresent(edit), "Edit should not be present on
the page.");
+ }
+
+ @Test
+ public void testDisabledStateClass() {
+
selenium.click(pjq("input[type=radio][name$=disabledInput][value=true]"));
+ selenium.waitForPageToLoad();
+
+ testStyleClass(select, "disabledStateClass");
+ }
+
+ @Test
public void testEditEvent() {
selenium.type(pjq("input[type=text][id$=editEventInput]"),
"mouseup");
selenium.waitForPageToLoad();
@@ -128,6 +171,51 @@
}
@Test
+ public void testEditStateClass() {
+ selenium.type(pjq("input[id$=editStateClassInput]"),
"metamer-ftest-class");
+ selenium.waitForPageToLoad();
+
+ assertFalse(selenium.belongsClass(select, "metamer-ftest-class"),
"Inplace input should not have class metamer-ftest-class.");
+
+ selenium.click(select);
+ assertTrue(selenium.belongsClass(select, "metamer-ftest-class"),
"Inplace input should have class metamer-ftest-class.");
+
+ selenium.click(options.format(10));
+ guardXhr(selenium).fireEvent(input, Event.BLUR);
+ assertFalse(selenium.belongsClass(select, "metamer-ftest-class"),
"Inplace input should not have class metamer-ftest-class.");
+ }
+
+ @Test
+ public void testImmediate() {
+
selenium.click(pjq("input[type=radio][name$=immediateInput][value=true]"));
+ selenium.waitForPageToLoad();
+
+ String reqTime = selenium.getText(time);
+ selenium.click(select);
+ selenium.click(options.format(10));
+ guardXhr(selenium).fireEvent(input, Event.BLUR);
+ waitGui.failWith("Page was not updated").waitForChange(reqTime,
retrieveText.locator(time));
+
+ phaseInfo.assertPhases(PhaseId.RESTORE_VIEW, PhaseId.APPLY_REQUEST_VALUES,
PhaseId.PROCESS_VALIDATIONS,
+ PhaseId.UPDATE_MODEL_VALUES, PhaseId.INVOKE_APPLICATION,
PhaseId.RENDER_RESPONSE);
+ phaseInfo.assertListener(PhaseId.APPLY_REQUEST_VALUES, "value changed: ->
Hawaii");
+ }
+
+ @Test
+ public void testInputWidth() {
+ selenium.type(pjq("input[type=text][id$=inputWidthInput]"),
"300px");
+ selenium.waitForPageToLoad();
+
+ String width = selenium.getStyle(input, CssProperty.WIDTH);
+ assertEquals(width, "300px", "Width of input did not
change.");
+
+ selenium.type(pjq("input[type=text][id$=inputWidthInput]"),
"");
+ selenium.waitForPageToLoad();
+
+ assertFalse(selenium.isAttributePresent(input.getAttribute(Attribute.STYLE)),
"Input should not have attribute style.");
+ }
+
+ @Test
public void testItemClass() {
final String value = "metamer-ftest-class";
selenium.type(pjq("input[type=text][id$=itemClassInput]"), value);
@@ -401,6 +489,11 @@
}
@Test
+ public void testReadyStateClass() {
+ testStyleClass(select, "readyStateClass");
+ }
+
+ @Test
public void testRendered() {
selenium.click(pjq("input[type=radio][name$=renderedInput][value=false]"));
selenium.waitForPageToLoad();
@@ -459,7 +552,7 @@
selenium.click(options.format(10));
assertFalse(selenium.isDisplayed(popup), "Popup should not be
displayed.");
-
+
guardNoRequest(selenium).fireEvent(input, Event.BLUR);
assertFalse(selenium.isDisplayed(popup), "Popup should not be
displayed.");
assertEquals(selenium.getValue(input), "Click here to edit",
"Input should contain default label.");
@@ -528,4 +621,23 @@
assertFalse(selenium.isDisplayed(popup), "Popup should not be
displayed.");
}
}
+
+ @Test
+ public void testTabindex() {
+ AttributeLocator<?> attr = input.getAttribute(new
Attribute("tabindex"));
+
+ selenium.type(pjq("input[id$=tabindexInput]"), "47");
+ selenium.waitForPageToLoad();
+
+ assertTrue(selenium.getAttribute(attr).contains("47"), "Attribute
tabindex should contain \"47\".");
+ }
+
+ @Test
+ public void testValue() {
+ selenium.type(pjq("input[type=text][id$=valueInput]"), "North
Carolina");
+ selenium.waitForPageToLoad();
+
+ assertTrue(selenium.belongsClass(edit, "rf-is-none"), "Edit should
contain class rf-is-none when popup is closed.");
+ assertEquals(selenium.getText(label), "North Carolina", "Label
should contain selected value.");
+ }
}