Author: ppitonak(a)redhat.com
Date: 2011-01-11 11:27:52 -0500 (Tue, 11 Jan 2011)
New Revision: 20950
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/a4jMediaOutput/TestImage.java
Log:
* testing standard HTML attributes refactored
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 2011-01-11
16:13:37 UTC (rev 20949)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2011-01-11
16:27:52 UTC (rev 20950)
@@ -1,6 +1,6 @@
/*******************************************************************************
* JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -266,9 +266,7 @@
* locator of tested element
*/
protected void testLang(ElementLocator<?> element) {
- JQueryLocator langInput = pjq("input[type=text][id$=langInput]");
JavaScript getAttributeLang = null;
-
if (SystemProperties.getBrowser().getType() == BrowserType.FIREFOX) {
getAttributeLang = new JavaScript("window.jQuery('" +
element.getRawLocator() + "').attr('lang')");
} else {
@@ -279,7 +277,7 @@
String langAttr = selenium.getEval(getAttributeLang);
assertTrue("null".equals(langAttr) || "".equals(langAttr),
"Attribute xml:lang should not be present.");
- selenium.type(langInput, "sk");
+ selenium.type(pjq("input[type=text][id$=langInput]"), "sk");
selenium.waitForPageToLoad();
// lang = sk
@@ -309,6 +307,25 @@
}
/**
+ * A helper method for testing standard HTML attributes (RichFaces attributes that
are directly put into markup), e.g. hreflang.
+ * @param element
+ * locator of tested element
+ * @param attribute
+ * tested attribute, e.g. "hreflang"
+ * @param value
+ * value that should be set, e.g. "cs"
+ */
+ protected void testHtmlAttribute(ElementLocator<?> element, String attribute,
String value) {
+ AttributeLocator<?> attr = element.getAttribute(new Attribute(attribute));
+ assertFalse(selenium.isAttributePresent(attr), "Attribute " + attribute
+ " should not be present.");
+
+ selenium.type(pjq("input[id$=" + attribute + "Input]"),
value);
+ selenium.waitForPageToLoad();
+
+ assertTrue(selenium.getAttribute(attr).contains(value), "Attribute " +
attribute + " should contain \"" + value + "\".");
+ }
+
+ /**
* 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/a4jMediaOutput/TestImage.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestImage.java 2011-01-11
16:13:37 UTC (rev 20949)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jMediaOutput/TestImage.java 2011-01-11
16:27:52 UTC (rev 20950)
@@ -99,27 +99,27 @@
@Test
public void testAccesskey() {
- testHtmlAttribute("accesskey", "r");
+ testHtmlAttribute(image, "accesskey", "r");
}
@Test
public void testAlign() {
- testHtmlAttribute("align", "left");
+ testHtmlAttribute(image, "align", "left");
}
@Test
public void testBorder() {
- testHtmlAttribute("border", "3");
+ testHtmlAttribute(image, "border", "3");
}
@Test
public void testCharset() {
- testHtmlAttribute("charset", "utf-8");
+ testHtmlAttribute(image, "charset", "utf-8");
}
@Test
public void testCoords() {
- testHtmlAttribute("coords", "circle: 150, 60, 60");
+ testHtmlAttribute(image, "coords", "circle: 150, 60, 60");
}
@Test
@@ -129,7 +129,7 @@
@Test
public void testHreflang() {
- testHtmlAttribute("hreflang", "sk");
+ testHtmlAttribute(image, "hreflang", "sk");
}
@Test
@@ -206,7 +206,7 @@
@Test
public void testRel() {
- testHtmlAttribute("rel", "metamer");
+ testHtmlAttribute(image, "rel", "metamer");
}
@Test
@@ -220,12 +220,12 @@
@Test
public void testRev() {
- testHtmlAttribute("rev", "metamer");
+ testHtmlAttribute(image, "rev", "metamer");
}
@Test
public void testShape() {
- testHtmlAttribute("shape", "default");
+ testHtmlAttribute(image, "shape", "default");
}
@Test
@@ -240,12 +240,12 @@
@Test
public void testTabindex() {
- testHtmlAttribute("tabindex", "50");
+ testHtmlAttribute(image, "tabindex", "50");
}
@Test
public void testTarget() {
- testHtmlAttribute("target", "_blank");
+ testHtmlAttribute(image, "target", "_blank");
}
@Test
@@ -255,16 +255,6 @@
@Test
public void testUsemap() {
- testHtmlAttribute("usemap", "metamer");
+ testHtmlAttribute(image, "usemap", "metamer");
}
-
- private void testHtmlAttribute(String attribute, String value) {
- AttributeLocator<?> attr = image.getAttribute(new Attribute(attribute));
- assertFalse(selenium.isAttributePresent(attr), "Attribute " + attribute
+ " should not be present.");
-
- selenium.type(pjq("input[id$=" + attribute + "Input]"),
value);
- selenium.waitForPageToLoad();
-
- assertTrue(selenium.getAttribute(attr).contains(value), "Attribute " +
attribute + " should contain \"" + value + "\".");
- }
}