Author: jjamrich
Date: 2011-08-17 17:34:37 -0400 (Wed, 17 Aug 2011)
New Revision: 22643
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichPickListBean.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/RichPickListComponentAttribute.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/TestPickList.java
Log:
Add requiredMessage attribute default value
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichPickListBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichPickListBean.java 2011-08-17
19:56:16 UTC (rev 22642)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichPickListBean.java 2011-08-17
21:34:37 UTC (rev 22643)
@@ -82,6 +82,8 @@
attributes.setAttribute("rendered", Boolean.TRUE);
attributes.setAttribute("minListHeight", "100");
+ attributes.setAttribute("requiredMessage", "Not empty target list
is required!");
+
attributes.setAttribute("addText", ">");
attributes.setAttribute("addAllText", ">>");
attributes.setAttribute("removeText", "<");
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/RichPickListComponentAttribute.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/RichPickListComponentAttribute.java 2011-08-17
19:56:16 UTC (rev 22642)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/RichPickListComponentAttribute.java 2011-08-17
21:34:37 UTC (rev 22643)
@@ -280,7 +280,7 @@
setProperty("rendered", rendered);
}
- public void setRequired(String required) {
+ public void setRequired(Boolean required) {
setProperty("required", required);
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/TestPickList.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/TestPickList.java 2011-08-17
19:56:16 UTC (rev 22642)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/TestPickList.java 2011-08-17
21:34:37 UTC (rev 22643)
@@ -21,16 +21,19 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richPickList;
+import static java.text.MessageFormat.format;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.assertFalse;
import java.net.URL;
+
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.utils.URLUtils;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
import org.testng.annotations.Test;
/**
@@ -43,18 +46,30 @@
public class TestPickList extends AbstractMetamerTest {
private RichPickListComponentAttribute attributes = new
RichPickListComponentAttribute();
+
+ private JQueryLocator phaseListenerFormat = jq("div#phasesPanel
li:eq({0})");
+
private JQueryLocator hSubmit = pjq("input[id$=hButton]");
private JQueryLocator a4jSubmit = pjq("input[id$=a4jButton]");
- private JQueryLocator pickListSourceItems =
pjq("div[id$=pickListSourceItems]");
- private JQueryLocator pickListSourceItem =
pickListSourceItems.getChild(jq("div[id$=pickListItem{0}]"));
+ private JQueryLocator pickListTop = pjq("div.rf-pick[id$=pickList]");
+ private JQueryLocator output = pjq("span[id$=output]");
+ private JQueryLocator pickListMsgBox = pjq("span.rf-msg >
span[id$=msg:form:pickList] > span.rf-msg-det");
+ private JQueryLocator targetCaptionLocator = pjq("div[id$=pickListTarget]
div.rf-pick-target-caption");
+ private JQueryLocator sourceCaptionLocator = pjq("div[id$=pickListSource]
div.rf-pick-source-caption");
+ private JQueryLocator pickListSrcItems =
pjq("div[id$=pickListSourceItems]");
+ private JQueryLocator pickListSrcItem =
pickListSrcItems.getChild(jq("div[id$=pickListItem{0}]"));
+ private JQueryLocator pickListSrcItemByText =
pickListSrcItems.getChild(jq("div.rf-pick-opt:contains({0})"));
+
private JQueryLocator pickListTargetItems =
pjq("div[id$=pickListTargetItems]");
private JQueryLocator pickListTargetItem =
pickListTargetItems.getChild(jq("div[id$=pickListItem{0}]"));
+ private JQueryLocator pickListTargetItemByText =
pickListTargetItems.getChild(jq("div.rf-pick-opt:contains({0})"));
// after click on 'add' button, item is moved to 'staging' container
(not child of #pickListTargetItems)
- private JQueryLocator pickListTargetItemsStage =
pjq("div[id$=pickListTargetList] div.rf-pick-lst-scrl");
- private JQueryLocator pickListTargetItemStage =
pickListTargetItemsStage.getChild(jq("div[id$=pickListItem{0}]"));
+ private JQueryLocator pickListTrgtItemsStage = pjq("div[id$=pickListTargetList]
div.rf-pick-lst-scrl");
+ private JQueryLocator pickListTrgtItemStage =
pickListTrgtItemsStage.getChild(jq("div[id$=pickListItem{0}]"));
+ private JQueryLocator pickListTrgtItemStageByText =
pickListTrgtItemsStage.getChild(jq("div.rf-pick-opt:contains({0})"));
private JQueryLocator addBtn = pjq("button.rf-pick-add");
private JQueryLocator addAllBtn = pjq("button.rf-pick-add-all");
@@ -63,10 +78,13 @@
private Attribute classAttr = new Attribute("class");
private Attribute disabledAttr = new Attribute("disabled");
+ private Attribute styleAttr = new Attribute("style");
private String STYLE_CLASS_ITEM_DISABLED = "rf-pick-opt-dis";
private String STYLE_CLASS_BTN_DISABLED = "rf-pick-btn-dis";
private String STYLE_CLASS_ITEM_SELECTED = "rf-pick-sel";
+
+ private String phaseListenerLogFormat = "*3 value changed: {0} -> {1}";
@Override
public URL getTestUrl() {
@@ -74,12 +92,24 @@
}
private void addItem(int id) {
- selenium.click(pickListSourceItem.format(id));
+ selenium.click(pickListSrcItem.format(id));
selenium.click(addBtn);
}
+ private void addItem(String value) {
+ selenium.click(pickListSrcItemByText.format(value));
+ selenium.click(addBtn);
+ }
+
private void removeItem(int id) {
- selenium.click(pickListTargetItem.format(id));
+
+ if (selenium.isElementPresent(pickListTrgtItemStage.format(id))){
+ selenium.click(pickListTrgtItemStage.format(id));
+ } else {
+ // if doesn't exist at this point, there we don't know what happens
+ selenium.click(pickListTargetItem.format(id));
+ }
+
selenium.click(removeBtn);
}
@@ -132,7 +162,7 @@
// check if source items are disabled (check second - first item after 0 item
added)
String pickListSourceItemClass = selenium.getAttribute(
- pickListSourceItem.format(1).getAttribute(classAttr));
+ pickListSrcItem.format(1).getAttribute(classAttr));
assertTrue(pickListSourceItemClass.contains(STYLE_CLASS_ITEM_DISABLED));
// all buttons should be disabled
@@ -445,106 +475,213 @@
// attributes.setRequiredMessage(requiredMessage);
}
- // @Test
+ @Test
public void testSelectItemClass() {
- // attributes.setSelectItemClass(selectItemClass);
+ String selectItemClass = "my-select-item-class";
+ attributes.setSelectItemClass(selectItemClass);
+
+ selenium.click(pickListSrcItemByText.format("richfaces"));
+
+ String classVal =
selenium.getAttribute(pickListSrcItemByText.format("richfaces").getAttribute(classAttr));
+ assertTrue(classVal.contains(selectItemClass));
}
- // @Test
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-11222")
public void testShowButton() {
- // TODO JJa 2011-08-05: create JIRA for this attribute: its not working
+ // this attribute doessn't work until the resolution of RF-11209
}
- // @Test
+ @Test
public void testSourceCaption() {
- // attributes.setSourceCaption(sourceCaption);
+ String sourceCaption = "This is source";
+ attributes.setSourceCaption(sourceCaption);
+
+ waitModel.until(textEquals.locator(sourceCaptionLocator).text(sourceCaption));
}
- // @Test
+ @Test
public void testStyle() {
- // attributes.setStyle(style);
+ testStyle(pickListTop, "style");
}
- // @Test
- public void testStyleClass() {
- // attributes.setStyleClass(styleClass);
+ @Test
+ public void testStyleClass() {
+ testStyleClass(pickListTop, "styleClass");
}
- // @Test
+ @Test
public void testTargetCaption() {
- // attributes.setTargetCaption(targetCaption);
+ String targetCaption = "This is target";
+ attributes.setTargetCaption(targetCaption);
+
+ waitModel.until(textEquals.locator(targetCaptionLocator).text(targetCaption));
}
- // @Test
+ @Test
public void testValidator() {
+ addAllItems();
+ selenium.click(a4jSubmit);
- // verify difference between submit incorrect value by h and a4j btn.
- // Seems that while h submit cause incorrect value removed from target list, a4j
don't do it
-
- // attributes.setValidator(validator);
+ // following message is predefined by validator
+ waitModel.until(textEquals.locator(pickListMsgBox).text("PickList don't
like '@' char!"));
}
- // @Test
+ @Test
public void testValidatorMessage() {
- // attributes.setValidatorMessage(validatorMessage);
+ String validationMessage = "We are sorry, but @ is not allowed to join
us!";
+ attributes.setValidatorMessage(validationMessage);
+ addAllItems();
+ selenium.click(a4jSubmit);
+
+ // verify our own validation message
+ waitModel.until(textEquals.locator(pickListMsgBox).text(validationMessage));
}
- // @Test
+ @Test
public void testValue() {
- // attributes.setValue(value);
+ addItem("richfaces"); // "richfaces"
+ selenium.click(a4jSubmit);
+
+ waitModel.until(textEquals.locator(output).text("[richfaces]"));
}
- // @Test
+ @Test
public void testValueChangeListener() {
+ addItem("richfaces"); //
+ selenium.click(a4jSubmit);
+
+ // valueChangeListener output as 4th record
+ waitModel.until(textEquals.locator(phaseListenerFormat.format(3))
+ .text(format(phaseListenerLogFormat, "[]",
"[richfaces]")));
+
+ addItem("Alabama");
+ selenium.click(a4jSubmit);
+
+ // valueChangeListener output as 4th record
+ waitModel.until(textEquals.locator(phaseListenerFormat.format(3))
+ .text(format(phaseListenerLogFormat, "[richfaces]",
"[richfaces, Alabama]")));
}
/**
* Verify that addBtn is disabled until item from source items picked
*/
- // @Test
+ @Test
public void testDisableAddBtn() {
+ int itemIdx = 0;
+ String addBtnClass = selenium.getAttribute(addBtn.getAttribute(classAttr));
+
+ // assert that button is visually disabled
+ assertTrue(addBtnClass != null);
+ assertTrue(addBtnClass.contains(STYLE_CLASS_BTN_DISABLED));
+
+ selenium.click(pickListSrcItem.format(itemIdx));
+
+ addBtnClass = selenium.getAttribute(addBtn.getAttribute(classAttr));
+
+ assertFalse(addBtnClass.contains(STYLE_CLASS_BTN_DISABLED));
+
}
/**
* Verify that removeBtn is disabled until item from target items picked
*/
- // @Test
+ @Test
public void testDisableRemoveBtn() {
+ int itemIdx = 0;
+ addAllItems();
+
+ String removeBtnClass =
selenium.getAttribute(removeBtn.getAttribute(classAttr));
+
+ // assert that button is visually disabled
+ assertTrue(removeBtnClass != null);
+ assertTrue(removeBtnClass.contains(STYLE_CLASS_BTN_DISABLED));
+
+ selenium.click(pickListTrgtItemStage.format(itemIdx));
+
+ removeBtnClass = selenium.getAttribute(removeBtn.getAttribute(classAttr));
+
+ assertFalse(removeBtnClass.contains(STYLE_CLASS_BTN_DISABLED));
}
/**
* Verify addAll button working correctly
*/
- // @Test
+ @Test
public void testAddAllBtn(){
+ addAllItems();
+
waitModel.until(countEquals.count(54).locator(pickListTrgtItemsStage.getChild(jq("div.rf-pick-opt"))));
}
/**
* Verify removeAll button working correctly
*/
- // @Test
+ @Test
public void testRemoveAllBtn() {
+ int itemAtIdx = 50;
+ addAllItems();
+ // validator doesn't allow '@', so remove it before save
+ removeItem(itemAtIdx);
+
+ selenium.click(hSubmit);
+
waitModel.until(countEquals.count(53).locator(pickListTargetItems.getChild(jq("div.rf-pick-opt"))));
+
+ removeAllItems();
+ // nothing should remain in target container
+
waitModel.until(countEquals.count(0).locator(pickListTargetItems.getChild(jq("div.rf-pick-opt"))));
+
}
/**
* Verify submit by JSF submit button
*/
- // @Test
+ @Test
public void testSaveJSF() {
+ int itemIdx = 0;
+ addItem(itemIdx);
+ // verify that item "added" to target list really appears in target
(staging) container.
+ waitModel.until(elementPresent.locator(pickListTrgtItemStage.format(itemIdx)));
+
+ // submit by JSF submit btn:
+ selenium.click(hSubmit);
+
+ // now item moved to target and submitted should appear in target (not staging)
+ waitModel.until(elementPresent.locator(pickListTargetItem.format(itemIdx)));
+
+ // todo check output!
}
/**
* Verify submit by ajax button
*/
- // @Test
+ @Test
public void testSaveAjax() {
+ int itemIdx = 0;
+ addItem(itemIdx);
+ // verify that item "added" to target list really appears in target
(staging) container.
+ waitModel.until(elementPresent.locator(pickListTrgtItemStage.format(itemIdx)));
+
+ // submit by ajax btn:
+ selenium.click(a4jSubmit);
+
+ // and here is difference between jsf and ajax submit.
+ // With ajax, submitted item doesn'e move from stage to target
+ waitModel.until(elementPresent.locator(pickListTrgtItemStage.format(itemIdx)));
+
+ // now call rerenderAll on whole page
+ selenium.click(rerenderAllIcon);
+
+ // now item moved to target and submitted should appear in target (not staging)
+ waitModel.until(elementPresent.locator(pickListTargetItem.format(itemIdx)));
+
+ // todo check output!
}
/**
@@ -557,15 +694,15 @@
public void testKeepSelected() {
int itemIdx = 0;
- String classBeforeSelect =
selenium.getAttribute(pickListSourceItem.format(itemIdx).getAttribute(classAttr));
+ String classBeforeSelect =
selenium.getAttribute(pickListSrcItem.format(itemIdx).getAttribute(classAttr));
assertFalse(classBeforeSelect.contains(STYLE_CLASS_ITEM_SELECTED),
"pickList item shouldn't be selected before any click made! Current
class(es) found: " + classBeforeSelect);
- selenium.click(pickListSourceItem.format(itemIdx));
+ selenium.click(pickListSrcItem.format(itemIdx));
- String pickedItemText = selenium.getText(pickListSourceItem.format(itemIdx));
+ String pickedItemText = selenium.getText(pickListSrcItem.format(itemIdx));
- String classAfterSelect =
selenium.getAttribute(pickListSourceItem.format(itemIdx).getAttribute(classAttr));
+ String classAfterSelect =
selenium.getAttribute(pickListSrcItem.format(itemIdx).getAttribute(classAttr));
assertTrue(classAfterSelect.contains(STYLE_CLASS_ITEM_SELECTED),
"pickList item should be selected after click on item was made. Current
class(es) found: " + classAfterSelect);
@@ -575,12 +712,12 @@
waitGui.until(elementPresent.locator(jq("div[id$=pickListTargetList]
div.rf-pick-lst-scrl > div[id$=pickListItem0]")));
// and check if item remain selected
- String classAfterMove =
selenium.getAttribute(pickListTargetItemStage.format(itemIdx).getAttribute(classAttr));
+ String classAfterMove =
selenium.getAttribute(pickListTrgtItemStage.format(itemIdx).getAttribute(classAttr));
assertTrue(classAfterMove.contains(STYLE_CLASS_ITEM_SELECTED),
"pickList item should keep selected after move to target list. Current
class(es) found: " + classAfterMove);
// verify that the same text is within item with the same ID index
- assertEquals(selenium.getText(pickListTargetItemStage.format(itemIdx)),
pickedItemText);
+ assertEquals(selenium.getText(pickListTrgtItemStage.format(itemIdx)),
pickedItemText);
}
/**
@@ -592,17 +729,17 @@
int itemIdx = 5;
// select item
- selenium.click(pickListSourceItem.format(itemIdx));
+ selenium.click(pickListSrcItem.format(itemIdx));
- String pickedItemText = selenium.getText(pickListSourceItem.format(itemIdx));
+ String pickedItemText = selenium.getText(pickListSrcItem.format(itemIdx));
// add item to target list
selenium.click(addBtn);
// item index doesn't change when moved to target list
- assertTrue(selenium.isElementPresent(pickListTargetItemStage.format(itemIdx)));
+ assertTrue(selenium.isElementPresent(pickListTrgtItemStage.format(itemIdx)));
// verify that the same text is within item with the same ID index
- assertEquals(selenium.getText(pickListTargetItemStage.format(itemIdx)),
pickedItemText);
+ assertEquals(selenium.getText(pickListTrgtItemStage.format(itemIdx)),
pickedItemText);
}
/**
@@ -613,13 +750,13 @@
// this item will be selected and verified appropriate class change/add
int itemIdx = 0;
- String classBeforeSelect =
selenium.getAttribute(pickListSourceItem.format(itemIdx).getAttribute(classAttr));
+ String classBeforeSelect =
selenium.getAttribute(pickListSrcItem.format(itemIdx).getAttribute(classAttr));
assertFalse(classBeforeSelect.contains(STYLE_CLASS_ITEM_SELECTED),
"pickList item shouldn't be selected before any click made! Current
class(es) found: " + classBeforeSelect);
- selenium.click(pickListSourceItem.format(itemIdx));
+ selenium.click(pickListSrcItem.format(itemIdx));
- String classAfterSelect =
selenium.getAttribute(pickListSourceItem.format(itemIdx).getAttribute(classAttr));
+ String classAfterSelect =
selenium.getAttribute(pickListSrcItem.format(itemIdx).getAttribute(classAttr));
assertTrue(classAfterSelect.contains(STYLE_CLASS_ITEM_SELECTED),
"pickList item should be selected after click on item was made. Current
class(es) found: " + classAfterSelect);