Author: ppitonak(a)redhat.com
Date: 2010-12-20 13:13:50 -0500 (Mon, 20 Dec 2010)
New Revision: 20700
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichAccordionBean.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTogglePanel/TestRichTogglePanel.java
Log:
* added test for itemChangeListener, execute, data and activeItem
* fixed test for immediate
* refactored
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichAccordionBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichAccordionBean.java 2010-12-20
18:11:05 UTC (rev 20699)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichAccordionBean.java 2010-12-20
18:13:50 UTC (rev 20700)
@@ -58,7 +58,8 @@
attributes.setAttribute("activeItem", "item1");
attributes.setAttribute("rendered", true);
-
+
+ attributes.remove("itemChangeListener");
}
public Attributes getAttributes() {
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java 2010-12-20
18:11:05 UTC (rev 20699)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java 2010-12-20
18:13:50 UTC (rev 20700)
@@ -30,6 +30,7 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
import java.net.URL;
@@ -101,8 +102,7 @@
@Test
public void testSwitchTypeAjax() {
- JQueryLocator selectOption =
pjq("input[type=radio][id$=switchTypeInput:0]");
- selenium.click(selectOption);
+ selenium.click(pjq("input[type=radio][id$=switchTypeInput:0]"));
selenium.waitForPageToLoad();
testSwitchTypeNull();
@@ -110,8 +110,7 @@
@Test
public void testSwitchTypeClient() {
- JQueryLocator selectOption =
pjq("input[type=radio][id$=switchTypeInput:1]");
- selenium.click(selectOption);
+ selenium.click(pjq("input[type=radio][id$=switchTypeInput:1]"));
selenium.waitForPageToLoad();
for (int i = 2; i >= 0; i--) {
@@ -124,8 +123,7 @@
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-10040")
public void testSwitchTypeServer() {
- JQueryLocator selectOption =
pjq("input[type=radio][id$=switchTypeInput:3]");
- selenium.click(selectOption);
+ selenium.click(pjq("input[type=radio][id$=switchTypeInput:3]"));
selenium.waitForPageToLoad();
for (int i = 2; i >= 0; i--) {
@@ -136,9 +134,43 @@
}
@Test
+ public void testActiveItem() {
+ selenium.type(pjq("input[type=text][id$=activeItemInput]"),
"item5");
+ selenium.waitForPageToLoad();
+
+ boolean accordionDisplayed = selenium.isDisplayed(accordion);
+ assertTrue(accordionDisplayed, "Accordion is not present on the
page.");
+
+ for (int i = 0; i < 5; i++) {
+ accordionDisplayed = selenium.isDisplayed(itemHeaders[i]);
+ assertTrue(accordionDisplayed, "Item" + (i + 1) + "'s
header should be visible.");
+ }
+
+ accordionDisplayed = selenium.isDisplayed(itemContents[4]);
+ assertTrue(accordionDisplayed, "Content of item5 should be visible.");
+
+ for (int i = 0; i < 4; i++) {
+ accordionDisplayed = selenium.isDisplayed(itemContents[i]);
+ assertFalse(accordionDisplayed, "Item" + (i + 1) + "'s
content should not be visible.");
+ }
+
+ selenium.type(pjq("input[type=text][id$=activeItemInput]"),
"item4");
+ selenium.waitForPageToLoad();
+
+ for (int i = 0; i < 5; i++) {
+ accordionDisplayed = selenium.isDisplayed(itemHeaders[i]);
+ assertTrue(accordionDisplayed, "Item" + (i + 1) + "'s
header should be visible.");
+ }
+
+ for (int i = 0; i < 5; i++) {
+ accordionDisplayed = selenium.isDisplayed(itemContents[i]);
+ assertFalse(accordionDisplayed, "Item" + (i + 1) + "'s
content should not be visible.");
+ }
+ }
+
+ @Test
public void testBypassUpdates() {
- JQueryLocator input =
pjq("input[type=radio][name$=bypassUpdatesInput][value=true]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=bypassUpdatesInput][value=true]"));
selenium.waitForPageToLoad();
selenium.click(itemHeaders[2]);
@@ -161,8 +193,7 @@
result = selenium.getEval(new JavaScript("window.RichFaces.$('" +
accordionId + "').prevItem('item1')"));
assertEquals(result, "null", "Result of function
prevItem('item1')");
- JQueryLocator input =
pjq("input[type=radio][name$=cycledSwitchingInput][value=true]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=cycledSwitchingInput][value=true]"));
selenium.waitForPageToLoad();
// RichFaces.$('form:accordion').nextItem('item5') will be item1
@@ -175,20 +206,53 @@
}
@Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10061")
+ public void testData() {
+ selenium.type(pjq("input[type=text][id$=dataInput]"), "RichFaces
4");
+ selenium.waitForPageToLoad();
+
+ selenium.type(pjq("input[type=text][id$=onitemchangeInput]"),
"data = event.data");
+ selenium.waitForPageToLoad();
+
+ guardXhr(selenium).click(itemHeaders[2]);
+ waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(itemContents[2]));
+
+ String data = selenium.getEval(new JavaScript("window.data"));
+ assertEquals(data, "RichFaces 4", "Data sent with ajax
request");
+ }
+
+ @Test
public void testDir() {
testDir(accordion);
}
@Test
+ public void testExecute() {
+ selenium.type(pjq("input[type=text][id$=executeInput]"), "@this
executeChecker");
+ selenium.waitForPageToLoad();
+
+ guardXhr(selenium).click(itemHeaders[2]);
+ waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(itemContents[2]));
+
+ JQueryLocator logItems = jq("ul.phases-list li:eq({0})");
+ for (int i = 0; i < 6; i++) {
+ if ("*
executeChecker".equals(selenium.getText(logItems.format(i)))) {
+ return;
+ }
+ }
+
+ fail("Attribute execute does not work");
+ }
+
+ @Test
public void testHeight() {
- JQueryLocator input = pjq("input[type=text][id$=heightInput]");
AttributeLocator<?> attribute = accordion.getAttribute(new
Attribute("style"));
// height = null
assertFalse(selenium.isAttributePresent(attribute), "Attribute style should
not be present.");
// height = 300px
- selenium.type(input, "300px");
+ selenium.type(pjq("input[type=text][id$=heightInput]"),
"300px");
selenium.waitForPageToLoad(TIMEOUT);
assertTrue(selenium.isAttributePresent(attribute), "Attribute style should
be present.");
@@ -198,17 +262,28 @@
@Test
public void testImmediate() {
- JQueryLocator input =
pjq("input[type=radio][name$=immediateInput][value=true]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=immediateInput][value=true]"));
selenium.waitForPageToLoad();
selenium.click(itemHeaders[2]);
waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(itemContents[2]));
assertPhases(PhaseId.RESTORE_VIEW, PhaseId.APPLY_REQUEST_VALUES,
PhaseId.RENDER_RESPONSE);
+
+ String listenerOutput = selenium.getText(jq("div#phasesPanel
li:eq(2)"));
+ assertEquals(listenerOutput, "* item changed item1 -> item3",
"Item change listener's output");
}
@Test
+ public void testItemChangeListener() {
+ selenium.click(itemHeaders[2]);
+ waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(itemContents[2]));
+
+ String listenerOutput = selenium.getText(jq("div#phasesPanel
li:eq(5)"));
+ assertEquals(listenerOutput, "* item changed: item1 -> item3",
"Item change listener's output");
+ }
+
+ @Test
public void testItemContentClass() {
testStyleClass(itemContents[2], "itemContentClass");
}
@@ -303,9 +378,6 @@
public void testLimitRender() {
JQueryLocator timeLoc = jq("span[id$=requestTime]");
-// selenium.type(pjq("input[type=text][id$=renderInput]"),
"@this");
-// selenium.waitForPageToLoad();
-
selenium.click(pjq("input[type=radio][name$=limitRenderInput][value=true]"));
selenium.waitForPageToLoad();
@@ -355,8 +427,7 @@
@Test
public void testRendered() {
- JQueryLocator input =
pjq("input[type=radio][name$=renderedInput][value=false]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=renderedInput][value=false]"));
selenium.waitForPageToLoad();
assertFalse(selenium.isElementPresent(accordion), "Accordion should not be
rendered when rendered=false.");
@@ -379,14 +450,13 @@
@Test
public void testWidth() {
- JQueryLocator input = pjq("input[type=text][id$=widthInput]");
AttributeLocator<?> attribute = accordion.getAttribute(new
Attribute("style"));
// width = null
assertFalse(selenium.isAttributePresent(attribute), "Attribute style should
not be present.");
// width = 50%
- selenium.type(input, "50%");
+ selenium.type(pjq("input[type=text][id$=widthInput]"),
"50%");
selenium.waitForPageToLoad(TIMEOUT);
assertTrue(selenium.isAttributePresent(attribute), "Attribute style should
be present.");
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java 2010-12-20
18:11:05 UTC (rev 20699)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java 2010-12-20
18:13:50 UTC (rev 20700)
@@ -30,6 +30,7 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.fail;
import java.net.URL;
@@ -37,7 +38,6 @@
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.encapsulated.JavaScript;
-import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.EventFiredCondition;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
@@ -111,8 +111,7 @@
@Test
public void testSwitchTypeAjax() {
- JQueryLocator selectOption =
pjq("input[name$=switchTypeInput][value=ajax]");
- selenium.click(selectOption);
+ selenium.click(pjq("input[name$=switchTypeInput][value=ajax]"));
selenium.waitForPageToLoad();
testSwitchTypeNull();
@@ -120,8 +119,7 @@
@Test
public void testSwitchTypeClient() {
- JQueryLocator selectOption =
pjq("input[name$=switchTypeInput][value=client]");
- selenium.click(selectOption);
+ selenium.click(pjq("input[name$=switchTypeInput][value=client]"));
selenium.waitForPageToLoad();
for (int i = 2; i >= 0; i--) {
@@ -134,8 +132,7 @@
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-10040")
public void testSwitchTypeServer() {
- JQueryLocator selectOption =
pjq("input[name$=switchTypeInput][value=server]");
- selenium.click(selectOption);
+ selenium.click(pjq("input[name$=switchTypeInput][value=server]"));
selenium.waitForPageToLoad();
for (int i = 2; i >= 0; i--) {
@@ -146,10 +143,44 @@
}
@Test
+ public void testActiveItem() {
+ selenium.type(pjq("input[type=text][id$=activeItemInput]"),
"tab5");
+ selenium.waitForPageToLoad();
+
+ boolean displayed = selenium.isDisplayed(panel);
+ assertTrue(displayed, "Tab panel is not present on the page.");
+
+ for (int i = 0; i < 4; i++) {
+ displayed = selenium.isDisplayed(activeHeaders[i]);
+ assertFalse(displayed, "Tab" + (i + 1) + "'s header should
not be active.");
+ }
+
+ displayed = selenium.isDisplayed(itemContents[4]);
+ assertTrue(displayed, "Content of tab5 should be visible.");
+
+ for (int i = 0; i < 4; i++) {
+ displayed = selenium.isDisplayed(itemContents[i]);
+ assertFalse(displayed, "Tab" + (i + 1) + "'s content
should not be visible.");
+ }
+
+ selenium.type(pjq("input[type=text][id$=activeItemInput]"),
"tab4");
+ selenium.waitForPageToLoad();
+
+ for (int i = 0; i < 5; i++) {
+ displayed = selenium.isDisplayed(activeHeaders[i]);
+ assertFalse(displayed, "Tab" + (i + 1) + "'s header should
not be active.");
+ }
+
+ for (int i = 0; i < 5; i++) {
+ displayed = selenium.isDisplayed(itemContents[i]);
+ assertFalse(displayed, "Tab" + (i + 1) + "'s content
should not be visible.");
+ }
+ }
+
+ @Test
@IssueTracking("https://issues.jboss.org/browse/RF-10054")
public void testBypassUpdates() {
- JQueryLocator input =
pjq("input[type=radio][name$=bypassUpdatesInput][value=true]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=bypassUpdatesInput][value=true]"));
selenium.waitForPageToLoad();
selenium.click(inactiveHeaders[2]);
@@ -172,8 +203,7 @@
result = selenium.getEval(new JavaScript("window.RichFaces.$('" +
panelId + "').prevItem('tab1')"));
assertEquals(result, "null", "Result of function
prevItem('tab1')");
- JQueryLocator input =
pjq("input[type=radio][name$=cycledSwitchingInput][value=true]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=cycledSwitchingInput][value=true]"));
selenium.waitForPageToLoad();
// RichFaces.$('form:tabPanel').nextItem('tab5') will be item1
@@ -186,24 +216,69 @@
}
@Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10061")
+ public void testData() {
+ selenium.type(pjq("input[type=text][id$=dataInput]"), "RichFaces
4");
+ selenium.waitForPageToLoad();
+
+ selenium.type(pjq("input[type=text][id$=onitemchangeInput]"),
"data = event.data");
+ selenium.waitForPageToLoad();
+
+ guardXhr(selenium).click(inactiveHeaders[2]);
+ waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(itemContents[2]));
+
+ String data = selenium.getEval(new JavaScript("window.data"));
+ assertEquals(data, "RichFaces 4", "Data sent with ajax
request");
+ }
+
+ @Test
public void testDir() {
super.testDir(panel);
}
@Test
+ public void testExecute() {
+ selenium.type(pjq("input[type=text][id$=executeInput]"), "@this
executeChecker");
+ selenium.waitForPageToLoad();
+
+ guardXhr(selenium).click(inactiveHeaders[2]);
+ waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(itemContents[2]));
+
+ JQueryLocator logItems = jq("ul.phases-list li:eq({0})");
+ for (int i = 0; i < 6; i++) {
+ if ("*
executeChecker".equals(selenium.getText(logItems.format(i)))) {
+ return;
+ }
+ }
+
+ fail("Attribute execute does not work");
+ }
+
+ @Test
@IssueTracking("https://issues.jboss.org/browse/RF-10054")
public void testImmediate() {
- JQueryLocator input =
pjq("input[type=radio][name$=immediateInput][value=true]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=immediateInput][value=true]"));
selenium.waitForPageToLoad();
selenium.click(inactiveHeaders[2]);
waitGui.failWith("Tab 3 is not
displayed.").until(isDisplayed.locator(itemContents[2]));
assertPhases(PhaseId.RESTORE_VIEW, PhaseId.APPLY_REQUEST_VALUES,
PhaseId.RENDER_RESPONSE);
+
+ String listenerOutput = selenium.getText(jq("div#phasesPanel
li:eq(2)"));
+ assertEquals(listenerOutput, "* item changed: tab1 -> tab3",
"Item change listener's output");
}
@Test
+ public void testItemChangeListener() {
+ selenium.click(inactiveHeaders[2]);
+ waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(itemContents[2]));
+
+ String listenerOutput = selenium.getText(jq("div#phasesPanel
li:eq(5)"));
+ assertEquals(listenerOutput, "* item changed: tab1 -> tab3",
"Item change listener's output");
+ }
+
+ @Test
public void testLang() {
testLang(panel);
}
@@ -308,8 +383,7 @@
@Test
public void testRendered() {
- JQueryLocator input =
pjq("input[type=radio][name$=renderedInput][value=false]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=renderedInput][value=false]"));
selenium.waitForPageToLoad();
assertFalse(selenium.isElementPresent(panel), "Tab panel should not be
rendered when rendered=false.");
@@ -327,10 +401,9 @@
@Test
public void testTabContentClass() {
- ElementLocator<?> classInput =
pjq("input[id$=tabContentClassInput]");
final String value = "metamer-ftest-class";
- selenium.type(classInput, value);
+ selenium.type(pjq("input[id$=tabContentClassInput]"), value);
selenium.waitForPageToLoad();
for (JQueryLocator loc : itemContents) {
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTogglePanel/TestRichTogglePanel.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTogglePanel/TestRichTogglePanel.java 2010-12-20
18:11:05 UTC (rev 20699)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTogglePanel/TestRichTogglePanel.java 2010-12-20
18:13:50 UTC (rev 20700)
@@ -29,6 +29,7 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
import java.net.URL;
@@ -234,10 +235,27 @@
}
@Test
+ public void testActiveItem() {
+ selenium.type(pjq("input[type=text][id$=activeItemInput]"),
"item3");
+ selenium.waitForPageToLoad();
+
+ boolean displayed = selenium.isDisplayed(panel);
+ assertTrue(displayed, "Toggle panel is not present on the page.");
+
+ displayed = selenium.isDisplayed(item1);
+ assertFalse(displayed, "Content of item1 should not be visible.");
+
+ displayed = selenium.isDisplayed(item2);
+ assertFalse(displayed, "Content of item2 should not be visible.");
+
+ displayed = selenium.isDisplayed(item3);
+ assertTrue(displayed, "Content of item3 should be visible.");
+ }
+
+ @Test
@IssueTracking("https://issues.jboss.org/browse/RF-10054")
public void testBypassUpdates() {
- JQueryLocator input =
pjq("input[type=radio][name$=bypassUpdatesInput][value=true]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=bypassUpdatesInput][value=true]"));
selenium.waitForPageToLoad();
selenium.click(tc3);
@@ -262,15 +280,48 @@
}
@Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10061")
+ public void testData() {
+ selenium.type(pjq("input[type=text][id$=dataInput]"), "RichFaces
4");
+ selenium.waitForPageToLoad();
+
+ selenium.type(pjq("input[type=text][id$=onitemchangeInput]"),
"data = event.data");
+ selenium.waitForPageToLoad();
+
+ guardXhr(selenium).click(tc3);
+ waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(item3));
+
+ String data = selenium.getEval(new JavaScript("window.data"));
+ assertEquals(data, "RichFaces 4", "Data sent with ajax
request");
+ }
+
+ @Test
public void testDir() {
super.testDir(panel);
}
@Test
+ public void testExecute() {
+ selenium.type(pjq("input[type=text][id$=executeInput]"), "@this
executeChecker");
+ selenium.waitForPageToLoad();
+
+ guardXhr(selenium).click(tc3);
+ waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(item3));
+
+ JQueryLocator logItems = jq("ul.phases-list li:eq({0})");
+ for (int i = 0; i < 6; i++) {
+ if ("*
executeChecker".equals(selenium.getText(logItems.format(i)))) {
+ return;
+ }
+ }
+
+ fail("Attribute execute does not work");
+ }
+
+ @Test
@IssueTracking("https://issues.jboss.org/browse/RF-10054")
public void testImmediate() {
- JQueryLocator input =
pjq("input[type=radio][name$=immediateInput][value=true]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=immediateInput][value=true]"));
selenium.waitForPageToLoad();
selenium.click(tc3);
@@ -279,10 +330,19 @@
assertPhases(PhaseId.RESTORE_VIEW, PhaseId.APPLY_REQUEST_VALUES,
PhaseId.RENDER_RESPONSE);
String listenerOutput = selenium.getText(jq("div#phasesPanel
li:eq(2)"));
- assertEquals(listenerOutput, "* item changed item1 -> item3",
"Item change listener's output");
+ assertEquals(listenerOutput, "* item changed: item1 -> item3",
"Item change listener's output");
}
@Test
+ public void testItemChangeListener() {
+ selenium.click(tc3);
+ waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(item3));
+
+ String listenerOutput = selenium.getText(jq("div#phasesPanel
li:eq(5)"));
+ assertEquals(listenerOutput, "* item changed: item1 -> item3",
"Item change listener's output");
+ }
+
+ @Test
public void testLang() {
testLang(panel);
}
@@ -384,8 +444,7 @@
@Test
public void testRendered() {
- JQueryLocator input =
pjq("input[type=radio][name$=renderedInput][value=false]");
- selenium.click(input);
+
selenium.click(pjq("input[type=radio][name$=renderedInput][value=false]"));
selenium.waitForPageToLoad();
assertFalse(selenium.isElementPresent(panel), "Toggle panel should not be
rendered when rendered=false.");