Author: ppitonak(a)redhat.com
Date: 2010-09-17 09:57:14 -0400 (Fri, 17 Sep 2010)
New Revision: 19240
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
Log:
* added methods for testing style and class attributes
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-09-17
13:40:20 UTC (rev 19239)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-09-17
13:57:14 UTC (rev 19240)
@@ -24,12 +24,15 @@
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
import java.net.URL;
import org.jboss.test.selenium.AbstractTestCase;
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.ajax.JavaScriptCondition;
@@ -44,7 +47,7 @@
* Abstract test case used as a basis for majority of test cases.
*
* @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
+ * @version $Rev$
*/
public abstract class AbstractMetamerTest extends AbstractTestCase {
@@ -54,8 +57,8 @@
public static final long TIMEOUT = 5000;
@Inject
- @Templates({ "plain", "richDataTable1,redDiv",
"richDataTable2,redDiv", "a4jRepeat1", "a4jRepeat2",
"hDataTable1",
- "hDataTable2", "uiRepeat1", "uiRepeat2" })
+ @Templates({"plain", "richDataTable1,redDiv",
"richDataTable2,redDiv", "a4jRepeat1", "a4jRepeat2",
"hDataTable1",
+ "hDataTable2", "uiRepeat1", "uiRepeat2"})
private TemplatesList template;
/**
@@ -146,6 +149,43 @@
}
/**
+ * A helper method for testing attribute "style". It sets
"background-color: yellow; font-size: 1.5em;" to the input
+ * field and checks that it was changed on the page.
+ *
+ * @param element
+ * locator of tested element
+ */
+ protected void testStyle(ElementLocator<?> element) {
+ ElementLocator<?> styleInput = pjq("input[id$=styleInput]");
+ final String value = "background-color: yellow; font-size: 1.5em;";
+
+ selenium.type(styleInput, value);
+ selenium.waitForPageToLoad();
+
+ AttributeLocator<?> styleAttr = element.getAttribute(Attribute.STYLE);
+ assertEquals(selenium.getAttribute(styleAttr), value, "Attribute
style");
+ }
+
+ /**
+ * 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 testStyleClass(ElementLocator<?> element, String attribute) {
+ ElementLocator<?> classInput = pjq("input[id$=" + attribute +
"Input]");
+ final String value = "metamer-ftest-class";
+
+ selenium.type(classInput, value);
+ selenium.waitForPageToLoad();
+
+ assertTrue(selenium.belongsClass(element, value), attribute + " does not
work");
+ }
+
+ /**
* Hides header, footer and inputs for attributes.
*/
protected void hideControls() {
Show replies by date