Author: ppitonak(a)redhat.com
Date: 2010-11-15 09:01:25 -0500 (Mon, 15 Nov 2010)
New Revision: 20046
Modified:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTabPanelBean.properties
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.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/richTab/TestRichTab.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java
Log:
* new (common) implementation of testDir
Modified:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTabPanelBean.properties
===================================================================
---
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTabPanelBean.properties 2010-11-15
10:56:27 UTC (rev 20045)
+++
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichTabPanelBean.properties 2010-11-15
14:01:25 UTC (rev 20046)
@@ -1,5 +1,5 @@
-attr.dir.LTR=LTR
-attr.dir.RTL=RTL
+attr.dir.ltr=ltr
+attr.dir.rtl=rtl
attr.dir.null=
attr.headerAlignment.left=left
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-11-15
10:56:27 UTC (rev 20045)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-11-15
14:01:25 UTC (rev 20046)
@@ -24,6 +24,7 @@
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.net.URL;
@@ -197,6 +198,38 @@
}
/**
+ * A helper method for testing attribute "class". It sets
"metamer-ftest-class" to the input field and checks that
+ * it was changed on the page.
+ *
+ * @param element
+ * locator of tested element
+ * @param attribute
+ * name of the attribute that will be set (e.g. styleClass, headerClass,
itemContentClass
+ */
+ protected void testDir(ElementLocator<?> element) {
+ JQueryLocator ltrInput =
pjq("input[type=radio][name$=dirInput][value=ltr]");
+ JQueryLocator rtlInput =
pjq("input[type=radio][name$=dirInput][value=rtl]");
+ AttributeLocator<?> dirAttribute = element.getAttribute(new
Attribute("dir"));
+
+ // dir = null
+ assertFalse(selenium.isAttributePresent(dirAttribute), "Attribute dir should
not be present.");
+
+ // dir = ltr
+ selenium.click(ltrInput);
+ selenium.waitForPageToLoad();
+ assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should
be present.");
+ String value = selenium.getAttribute(dirAttribute);
+ assertEquals(value, "ltr", "Attribute dir");
+
+ // dir = rtl
+ selenium.click(rtlInput);
+ selenium.waitForPageToLoad();
+ assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should
be present.");
+ value = selenium.getAttribute(dirAttribute);
+ assertEquals(value, "rtl", "Attribute dir");
+ }
+
+ /**
* Hides header, footer and inputs for attributes.
*/
protected void hideControls() {
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-11-15
10:56:27 UTC (rev 20045)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-11-15
14:01:25 UTC (rev 20046)
@@ -19,7 +19,6 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*******************************************************************************/
-
package org.richfaces.tests.metamer.ftest.a4jOutputPanel;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
@@ -49,19 +48,15 @@
*/
public class TestA4JOutputPanel extends AbstractMetamerTest {
- Event[] events = new Event[] { CLICK, DBLCLICK, KEYDOWN, KEYPRESS, KEYUP, MOUSEDOWN,
MOUSEMOVE, MOUSEOUT,
- MOUSEOVER, MOUSEUP };
-
- String[] layouts = new String[] { "block", "inline" };
-
+ Event[] events = new Event[]{CLICK, DBLCLICK, KEYDOWN, KEYPRESS, KEYUP, MOUSEDOWN,
MOUSEMOVE, MOUSEOUT,
+ MOUSEOVER, MOUSEUP};
+ String[] layouts = new String[]{"block", "inline"};
@Inject
@Use(empty = true)
Event event;
-
@Inject
@Use(empty = true)
String layout;
-
private JQueryLocator increaseCounterButton = pjq("input[id$=button]");
private JQueryLocator outputDiv = pjq("div[id$=outputPanel]");
private JQueryLocator outputSpan = pjq("span[id$=outputPanel]");
@@ -72,9 +67,11 @@
public URL getTestUrl() {
return buildUrl(contextPath,
"faces/components/a4jOutputPanel/simple.xhtml");
}
-
+
@Test
- @Uses({ @Use(field = "event", value = "events"), @Use(field =
"layout", value = "layouts") })
+ @Uses({
+ @Use(field = "event", value = "events"),
+ @Use(field = "layout", value = "layouts")})
public void testEvent() {
JQueryLocator element = null;
@@ -127,30 +124,7 @@
@Test
public void testDir() {
- JQueryLocator optionLtr = pjq("input[name$=dirInput][value=ltr]");
- JQueryLocator optionRtl = pjq("input[name$=dirInput][value=rtl]");
- JQueryLocator optionNone = pjq("input[name$=dirInput][value=]");
- AttributeLocator<?> attributeDir = outputDiv.getAttribute(new
Attribute("dir"));
-
- // right-to-left
- selenium.click(optionRtl);
- selenium.waitForPageToLoad(TIMEOUT);
- String attributeValue = selenium.getAttribute(attributeDir);
- assertEquals(attributeValue, "rtl", "Attribute dir after rtl was
set.");
-
- // left-to-right
- selenium.click(optionLtr);
- selenium.waitForPageToLoad(TIMEOUT);
- attributeValue = selenium.getAttribute(attributeDir);
- assertEquals(attributeValue, "ltr", "Attribute dir after ltr was
set.");
-
- // not specified
- selenium.click(optionNone);
- selenium.waitForPageToLoad(TIMEOUT);
- if (selenium.isAttributePresent(attributeDir)) {
- attributeValue = selenium.getAttribute(attributeDir);
- assertEquals(attributeValue, "", "Attribute dir after none was
set.");
- }
+ testDir(outputDiv);
}
@Test
@@ -246,21 +220,21 @@
selenium.waitForPageToLoad(TIMEOUT);
assertTrue(selenium.belongsClass(outputDiv, "blue-background"),
"Panel should have class blue-background set.");
assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
- "Panel should not have class gray-background set.");
+ "Panel should not have class gray-background set.");
selenium.click(optionGray);
selenium.waitForPageToLoad(TIMEOUT);
assertTrue(selenium.belongsClass(outputDiv, "gray-background"),
"Panel should have class gray-background set.");
assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
- "Panel should not have class blue-background set.");
+ "Panel should not have class blue-background set.");
selenium.click(optionNone);
selenium.waitForPageToLoad(TIMEOUT);
if (selenium.isAttributePresent(attributeClass)) {
assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
- "Panel should not have class blue-background set.");
+ "Panel should not have class blue-background set.");
assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
- "Panel should not have class gray-background set.");
+ "Panel should not have class gray-background set.");
}
}
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-11-15
10:56:27 UTC (rev 20045)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java 2010-11-15
14:01:25 UTC (rev 20046)
@@ -57,7 +57,6 @@
pjq("div[id$=item3:header]"), pjq("div[id$=item4:header]"),
pjq("div[id$=item5:header]")};
private JQueryLocator[] itemContents = {pjq("div[id$=item1:content]"),
pjq("div[id$=item2:content]"),
pjq("div[id$=item3:content]"), pjq("div[id$=item4:content]"),
pjq("div[id$=item5:content]")};
- private IsDisplayed isDisplayed = IsDisplayed.getInstance();
private JQueryLocator[] activeHeaders =
{pjq("div.rf-ac-itm-hdr-act:eq(0)"),
pjq("div.rf-ac-itm-hdr-act:eq(1)"),
pjq("div.rf-ac-itm-hdr-act:eq(2)"),
pjq("div.rf-ac-itm-hdr-act:eq(3)"),
pjq("div.rf-ac-itm-hdr-act:eq(4)")};
private JQueryLocator[] inactiveHeaders =
{pjq("div.rf-ac-itm-hdr-inact:eq(0)"),
@@ -144,7 +143,7 @@
waitGui.failWith("Item 3 is not
displayed.").until(isDisplayed.locator(itemContents[2]));
assertPhases(PhaseId.RESTORE_VIEW, PhaseId.APPLY_REQUEST_VALUES,
PhaseId.PROCESS_VALIDATIONS,
- PhaseId.RENDER_RESPONSE);
+ PhaseId.RENDER_RESPONSE);
}
@Test
@@ -175,26 +174,7 @@
@Test
public void testDir() {
- JQueryLocator ltrInput = pjq("input[type=radio][id$=dirInput:0]");
- JQueryLocator rtlInput = pjq("input[type=radio][id$=dirInput:2]");
- AttributeLocator<?> dirAttribute = accordion.getAttribute(new
Attribute("dir"));
-
- // dir = null
- assertFalse(selenium.isAttributePresent(dirAttribute), "Attribute dir should
not be present.");
-
- // dir = ltr
- selenium.click(ltrInput);
- selenium.waitForPageToLoad();
- assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should
be present.");
- String value = selenium.getAttribute(dirAttribute);
- assertEquals(value, "ltr", "Attribute dir");
-
- // dir = rtl
- selenium.click(rtlInput);
- selenium.waitForPageToLoad();
- assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should
be present.");
- value = selenium.getAttribute(dirAttribute);
- assertEquals(value, "rtl", "Attribute dir");
+ testDir(accordion);
}
@Test
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTab/TestRichTab.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTab/TestRichTab.java 2010-11-15
10:56:27 UTC (rev 20045)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTab/TestRichTab.java 2010-11-15
14:01:25 UTC (rev 20046)
@@ -102,26 +102,7 @@
@Test
public void testDir() {
- JQueryLocator ltrInput =
pjq("input[type=radio][name$=dirInput][value=ltr]");
- JQueryLocator rtlInput =
pjq("input[type=radio][name$=dirInput][value=rtl]");
- AttributeLocator<?> dirAttribute = tab.getAttribute(new
Attribute("dir"));
-
- // dir = null
- assertFalse(selenium.isAttributePresent(dirAttribute), "Attribute dir should
not be present.");
-
- // dir = ltr
- selenium.click(ltrInput);
- selenium.waitForPageToLoad();
- assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should
be present.");
- String value = selenium.getAttribute(dirAttribute);
- assertEquals(value, "ltr", "Attribute dir");
-
- // dir = rtl
- selenium.click(rtlInput);
- selenium.waitForPageToLoad();
- assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should
be present.");
- value = selenium.getAttribute(dirAttribute);
- assertEquals(value, "rtl", "Attribute dir");
+ testDir(tab);
}
@Test
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-11-15
10:56:27 UTC (rev 20045)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanel.java 2010-11-15
14:01:25 UTC (rev 20046)
@@ -187,26 +187,7 @@
@Test
public void testDir() {
- JQueryLocator ltrInput =
pjq("input[type=radio][name$=dirInput][value=LTR]");
- JQueryLocator rtlInput =
pjq("input[type=radio][name$=dirInput][value=RTL]");
- AttributeLocator<?> dirAttribute = panel.getAttribute(new
Attribute("dir"));
-
- // dir = null
- assertFalse(selenium.isAttributePresent(dirAttribute), "Attribute dir should
not be present.");
-
- // dir = ltr
- selenium.click(ltrInput);
- selenium.waitForPageToLoad();
- assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should
be present.");
- String value = selenium.getAttribute(dirAttribute);
- assertEquals(value, "LTR", "Attribute dir");
-
- // dir = rtl
- selenium.click(rtlInput);
- selenium.waitForPageToLoad();
- assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should
be present.");
- value = selenium.getAttribute(dirAttribute);
- assertEquals(value, "RTL", "Attribute dir");
+ super.testDir(panel);
}
@Test