Author: jjamrich
Date: 2011-09-23 09:27:31 -0400 (Fri, 23 Sep 2011)
New Revision: 22746
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.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/TestSimple.java
Log:
RFPL-1439: Update jQuery test to use unified way to setting attributes
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java 2011-09-23
13:27:03 UTC (rev 22745)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java 2011-09-23
13:27:31 UTC (rev 22746)
@@ -22,6 +22,7 @@
import org.richfaces.tests.metamer.ftest.richDropTarget.DropTargetAttributes;
import org.richfaces.tests.metamer.ftest.richEditor.EditorAttributes;
import org.richfaces.tests.metamer.ftest.richGraphValidator.GraphValidatorAttributes;
+import org.richfaces.tests.metamer.ftest.richJQuery.RichJQueryAttributes;
import org.richfaces.tests.metamer.ftest.richTooltip.TooltipAttributes;
public class AttributeList {
@@ -47,5 +48,6 @@
public static Attributes<DropTargetAttributes> dropTargetAttributes = new
Attributes<DropTargetAttributes>();
public static Attributes<EditorAttributes> editorAttributes = new
Attributes<EditorAttributes>();
public static Attributes<GraphValidatorAttributes> graphValidatorAttributes =
new Attributes<GraphValidatorAttributes>();
+ public static Attributes<RichJQueryAttributes> jQueryAttributes = new
Attributes<RichJQueryAttributes>();
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java 2011-09-23
13:27:03 UTC (rev 22745)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java 2011-09-23
13:27:31 UTC (rev 22746)
@@ -68,6 +68,10 @@
setProperty(attribute.toString(), js);
}
+ public void set(T attribute, JQueryLocator locator) {
+ setProperty(attribute.toString(), locator.getRawLocator());
+ }
+
public void set(T attribute, Enum<?> item) {
setProperty(attribute.toString(), item.toString());
}
@@ -76,6 +80,10 @@
setProperty(attribute.toString(), event.getEventName());
}
+ public void reset(T attribute) {
+ setProperty(attribute.toString(), "");
+ }
+
/**
* Retrieve current attribute value
* @param attribute
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 2011-09-23
13:27:03 UTC (rev 22745)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/RichJQueryAttributes.java 2011-09-23
13:27:31 UTC (rev 22746)
@@ -21,37 +21,19 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richJQuery;
-import org.jboss.test.selenium.encapsulated.JavaScript;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class RichJQueryAttributes extends AbstractComponentAttributes {
- public void setAttachType(String attachType) {
- setProperty("attachType", attachType);
- }
+public enum RichJQueryAttributes implements AttributeEnum {
+
+ attachType,
+ event,
+ query,
+ rendered,
+ selector,
+ timing
- public void setEvent(String event) {
- setProperty("event", event);
- }
-
- public void setQuery(JavaScript query) {
- setProperty("query", query);
- }
-
- public void setRendered(boolean rendered) {
- setProperty("rendered", rendered);
- }
-
- public void setSelector(JQueryLocator jQueryLocator) {
- String rawLocator = jQueryLocator == null ? null :
jQueryLocator.getRawLocator();
- setProperty("selector", rawLocator);
- }
-
- public void setTiming(String timing) {
- setProperty("timing", timing);
- }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestSimple.java 2011-09-23
13:27:03 UTC (rev 22745)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestSimple.java 2011-09-23
13:27:31 UTC (rev 22746)
@@ -25,6 +25,8 @@
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.richfaces.tests.metamer.ftest.attributes.AttributeList.jQueryAttributes;
+import static org.richfaces.tests.metamer.ftest.richJQuery.RichJQueryAttributes.*;
import java.awt.Color;
import java.net.URL;
@@ -45,8 +47,6 @@
JQueryLocator addLiveComponent = jq("input[id$=addComponentButton]");
JQueryLocator liveTestComponent = jq("div.liveTestComponent");
- RichJQueryAttributes attributes = new RichJQueryAttributes();
-
ColorRetriever buttonColorRetriver = new ColorRetriever().locator(button);
@Override
@@ -57,7 +57,7 @@
@Test
public void testDefaultTiming() {
setupDomReadyTypeAttributes();
- attributes.setTiming(null);
+ jQueryAttributes.reset(timing);
assertEquals(buttonColorRetriver.retrieve(), Color.RED);
}
@@ -78,8 +78,8 @@
@Test
public void testAttachTypeOne() {
setupImmediateTypeAttributes();
- attributes.setAttachType("one");
- attributes.setQuery(js("alert('first')"));
+ jQueryAttributes.set(attachType, "one");
+ jQueryAttributes.set(query, js("alert('first')"));
selenium.click(button);
waitGui.until(alertEquals.message("first"));
@@ -113,17 +113,17 @@
}
private void setupImmediateTypeAttributes() {
- attributes.setEvent("click");
- attributes.setQuery(js("$(this).css('color',
'red')"));
- attributes.setSelector(button);
- attributes.setTiming("immediate");
+ jQueryAttributes.set(event, "click");
+ jQueryAttributes.set(query, js("$(this).css('color',
'red')"));
+ jQueryAttributes.set(selector, button);
+ jQueryAttributes.set(timing, "immediate");
}
private void setupDomReadyTypeAttributes() {
- attributes.setEvent(null);
- attributes.setQuery(js("css('color', 'red')"));
- attributes.setSelector(button);
- attributes.setTiming("domready");
+ jQueryAttributes.reset(event);
+ jQueryAttributes.set(query, js("css('color',
'red')"));
+ jQueryAttributes.set(selector, button);
+ jQueryAttributes.set(timing, "domready");
}
}
\ No newline at end of file