Author: lfryc(a)redhat.com
Date: 2010-08-20 13:48:56 -0400 (Fri, 20 Aug 2010)
New Revision: 18866
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/RichJQueryAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestTiming.java
Log:
rich:jQuery - added tests for @timing attribute (RFPL-668)
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java 2010-08-20
17:48:48 UTC (rev 18865)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java 2010-08-20
17:48:56 UTC (rev 18866)
@@ -52,6 +52,9 @@
String inputType = selenium.getAttribute(typeLocator);
+ if (value == null) {
+ value = "";
+ }
String valueAsString = value.toString();
if ("text".equals(inputType)) {
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/RichJQueryAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/RichJQueryAttributes.java 2010-08-20
17:48:48 UTC (rev 18865)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/RichJQueryAttributes.java 2010-08-20
17:48:56 UTC (rev 18866)
@@ -21,6 +21,8 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richJQuery;
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.component.JQueryTiming;
import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
@@ -37,7 +39,7 @@
setProperty("event", event);
}
- public void setQuery(String query) {
+ public void setQuery(JavaScript query) {
setProperty("query", query);
}
@@ -45,11 +47,13 @@
setProperty("rendered", rendered);
}
- public void setSelector(String selector) {
- setProperty("selector", selector);
+ public void setSelector(JQueryLocator jQueryLocator) {
+ String rawLocator = jQueryLocator == null ? null :
jQueryLocator.getRawLocator();
+ setProperty("selector", rawLocator);
}
public void setTiming(JQueryTiming timing) {
- setProperty("timing", timing.toString());
+ String timingString = timing == null ? null : timing.toString();
+ setProperty("timing", timingString);
}
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestTiming.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestTiming.java 2010-08-20
17:48:48 UTC (rev 18865)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestTiming.java 2010-08-20
17:48:56 UTC (rev 18866)
@@ -23,13 +23,20 @@
import java.net.URL;
+import org.jboss.test.selenium.css.CssProperty;
+import org.jboss.test.selenium.encapsulated.JavaScript;
import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.waiting.conditions.StyleEquals;
import org.richfaces.component.JQueryTiming;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.Test;
import static org.jboss.test.selenium.utils.URLUtils.*;
import static org.jboss.test.selenium.locator.LocatorFactory.*;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.testng.Assert.assertEquals;
+import static org.jboss.test.selenium.encapsulated.JavaScript.js;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
@@ -37,7 +44,7 @@
*/
public class TestTiming extends AbstractMetamerTest {
- JQueryLocator button = jq("#jQueryTestButton");
+ JQueryLocator button = jq("input:button[id$=jQueryTestButton]");
RichJQueryAttributes attributes = new RichJQueryAttributes();
@@ -46,8 +53,37 @@
return buildUrl(contextPath,
"faces/components/richJQuery/simple.xhtml");
}
+ private void setupImmediateTypeAttributes() {
+ attributes.setEvent("click");
+ attributes.setQuery(js("$(this).css('color',
'red')"));
+ attributes.setSelector(button);
+ attributes.setTiming(JQueryTiming.immediate);
+ }
+
+ private void setupDomReadyTypeAttributes() {
+ attributes.setEvent(null);
+ attributes.setQuery(js("css('color', 'red')"));
+ attributes.setSelector(button);
+ attributes.setTiming(JQueryTiming.domready);
+ }
+
@Test
public void testImmediate() {
- attributes.setTiming(JQueryTiming.immediate);
+ setupImmediateTypeAttributes();
+ selenium.click(button);
+
waitGui.until(styleEquals.locator(button).property(CssProperty.COLOR).value("red"));
}
+
+ @Test
+ public void testDomReady() {
+ setupDomReadyTypeAttributes();
+ assertEquals("red", selenium.getStyle(button, CssProperty.COLOR));
+ }
+
+ @Test
+ public void testDomReadyByDefault() {
+ setupDomReadyTypeAttributes();
+ attributes.setTiming(null);
+ assertEquals("red", selenium.getStyle(button, CssProperty.COLOR));
+ }
}
\ No newline at end of file
Show replies by date