Author: lfryc(a)redhat.com
Date: 2011-01-20 14:04:55 -0500 (Thu, 20 Jan 2011)
New Revision: 21132
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/cheiron/retriever/ScriptEvaluationRetriever.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/JQuerySelectors.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/AbstractTreeNodeModel.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeExpansion.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeSimple.java
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml
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/AbstractMetamerTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/ModelIterable.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeModel.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeModel.java
modules/tests/metamer/trunk/ftest/src/test/resources/testng-iteration.xml
Log:
rich:tree - automated Simple sample (RFPL-935)
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml 2011-01-20
18:43:56 UTC (rev 21131)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml 2011-01-20
19:04:55 UTC (rev 21132)
@@ -54,6 +54,7 @@
dir="#{richTreeBean.attributes['dir'].value}"
lang="#{richTreeBean.attributes['lang'].value}"
+ data="#{richTreeBean.attributes['data'].value}"
onbeforedomupdate="#{richTreeBean.attributes['onbeforedomupdate'].value}"
onbeforenodetoggle="#{richTreeBean.attributes['onbeforenodetoggle'].value}"
onbeforeselectionchange="#{richTreeBean.attributes['onbeforeselectionchange'].value}"
@@ -90,10 +91,14 @@
render="#{richTreeBean.attributes['render'].value}"
execute="#{richTreeBean.attributes['execute'].value}"
toggleNodeEvent="#{richTreeBean.attributes['toggleNodeEvent'].value}"
+
limitRender="#{richTreeBean.attributes['limitRender'].value}"
+ status="#{richTreeBean.attributes['status'].value}"
+
immediate="#{richTreeBean.attributes['immediate'].value}"
<rich:treeNode type="country"
rendered="#{richTreeNodeBean.attributes[0]['rendered'].value}"
+ expanded="#{richTreeNodeBean.attributes[0]['expanded'].value}"
iconLeaf="#{richTreeNodeBean.attributes[0]['iconLeaf'].value}"
iconExpanded="#{richTreeNodeBean.attributes[0]['iconExpanded'].value}"
iconCollapsed="#{richTreeNodeBean.attributes[0]['iconCollapsed'].value}"
@@ -111,6 +116,7 @@
<rich:treeNode type="company"
icon="/images/tree/disc.gif"
rendered="#{richTreeNodeBean.attributes[1]['rendered'].value}"
+ expanded="#{richTreeNodeBean.attributes[1]['expanded'].value}"
iconLeaf="#{richTreeNodeBean.attributes[1]['iconLeaf'].value}"
iconExpanded="#{richTreeNodeBean.attributes[1]['iconExpanded'].value}"
iconCollapsed="#{richTreeNodeBean.attributes[1]['iconCollapsed'].value}"
@@ -129,6 +135,7 @@
<rich:treeNode type="cd"
icon="/images/tree/song.gif"
rendered="#{richTreeNodeBean.attributes[2]['rendered'].value}"
+ expanded="#{richTreeNodeBean.attributes[2]['expanded'].value}"
iconLeaf="#{richTreeNodeBean.attributes[2]['iconLeaf'].value}"
iconExpanded="#{richTreeNodeBean.attributes[2]['iconExpanded'].value}"
iconCollapsed="#{richTreeNodeBean.attributes[2]['iconCollapsed'].value}"
Modified: modules/tests/metamer/trunk/ftest/src/test/resources/testng-iteration.xml
===================================================================
--- modules/tests/metamer/trunk/ftest/src/test/resources/testng-iteration.xml 2011-01-20
18:43:56 UTC (rev 21131)
+++ modules/tests/metamer/trunk/ftest/src/test/resources/testng-iteration.xml 2011-01-20
19:04:55 UTC (rev 21132)
@@ -11,6 +11,7 @@
<package name="org.richfaces.tests.metamer.ftest.richDataTable"
/>
<package
name="org.richfaces.tests.metamer.ftest.richDataScroller" />
<package
name="org.richfaces.tests.metamer.ftest.richExtendedDataTable" />
+ <package name="org.richfaces.tests.metamer.ftest.richTree"
/>
</packages>
</test>
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/cheiron/retriever/ScriptEvaluationRetriever.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/cheiron/retriever/ScriptEvaluationRetriever.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/cheiron/retriever/ScriptEvaluationRetriever.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.cheiron.retriever;
+
+import static org.jboss.test.selenium.encapsulated.JavaScript.js;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+
+import org.apache.commons.lang.Validate;
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.waiting.conversion.Convertor;
+import org.jboss.test.selenium.waiting.conversion.PassOnConvertor;
+import org.jboss.test.selenium.waiting.retrievers.AbstractRetriever;
+import org.jboss.test.selenium.waiting.retrievers.Retriever;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class ScriptEvaluationRetriever extends AbstractRetriever<String> implements
Retriever<String> {
+
+ private AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ private JavaScript javaScript;
+
+ public ScriptEvaluationRetriever() {
+ }
+
+ public String retrieve() {
+ Validate.notNull(javaScript);
+
+ return selenium.getEval(javaScript);
+ }
+
+ public JavaScript getJavaScriptRetrieve() {
+ return js(format("selenium.getEval('{0}')",
javaScript.getAsString()));
+ }
+
+ public static ScriptEvaluationRetriever getInstance() {
+ return new ScriptEvaluationRetriever();
+ }
+
+ public ScriptEvaluationRetriever script(JavaScript javaScript) {
+ Validate.notNull(javaScript);
+
+ ScriptEvaluationRetriever copy = copy();
+ copy.javaScript = javaScript;
+
+ return copy;
+ }
+
+ /**
+ * Returns a copy of this textRetriever with exactly same settings.
+ *
+ * Keeps the immutability of this class.
+ *
+ * @return the exact copy of this textRetriever
+ */
+ private ScriptEvaluationRetriever copy() {
+ ScriptEvaluationRetriever copy = new ScriptEvaluationRetriever();
+ copy.javaScript = javaScript;
+ return copy;
+ }
+
+ /**
+ * Uses {@link PassOnConvertor} to pass the JavaScript result to result value.
+ */
+ public Convertor<String, String> getConvertor() {
+ return new PassOnConvertor<String>();
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/JQuerySelectors.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/JQuerySelectors.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/JQuerySelectors.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -0,0 +1,17 @@
+package org.jboss.test.selenium;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+
+import org.jboss.test.selenium.locator.ExtendedLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.utils.text.SimplifiedFormat;
+
+public class JQuerySelectors {
+ public static JQueryLocator not(ExtendedLocator<JQueryLocator> locator, String
expression) {
+ return jq(SimplifiedFormat.format("{0}:not({1})",
locator.getRawLocator(), expression));
+ }
+
+ public static JQueryLocator append(ExtendedLocator<JQueryLocator> locator,
String expression) {
+ return jq(SimplifiedFormat.format("{0}{1}", locator.getRawLocator(),
expression));
+ }
+}
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 2011-01-20
18:43:56 UTC (rev 21131)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -139,4 +139,8 @@
OptionValueLocator optionLocator = new OptionValueLocator(value);
guard(selenium, requestType).select(locator, optionLocator);
}
+
+ public void setOncomplete(String oncomplete) {
+ setProperty("oncomplete", oncomplete);
+ }
}
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-20
18:43:56 UTC (rev 21131)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -25,7 +25,9 @@
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
import static org.jboss.test.selenium.locator.LocatorFactory.id;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.encapsulated.JavaScript.js;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@@ -36,6 +38,7 @@
import javax.faces.event.PhaseId;
import org.apache.commons.lang.LocaleUtils;
+import org.jboss.cheiron.retriever.ScriptEvaluationRetriever;
import org.jboss.test.selenium.AbstractTestCase;
import org.jboss.test.selenium.SystemProperties;
import org.jboss.test.selenium.browser.BrowserType;
@@ -44,8 +47,11 @@
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.ExtendedLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.EventFiredCondition;
+import org.jboss.test.selenium.waiting.retrievers.Retriever;
+import org.jboss.test.selenium.waiting.retrievers.TextRetriever;
import org.richfaces.tests.metamer.Phase;
import org.richfaces.tests.metamer.TemplatesList;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
@@ -63,6 +69,12 @@
public abstract class AbstractMetamerTest extends AbstractTestCase {
protected JQueryLocator time = jq("span[id$=requestTime]");
+ protected TextRetriever retrieveRequestTime = retrieveText.locator(time);
+ protected Retriever<String> retrieveWindowData = new
ScriptEvaluationRetriever().script(js("window.data"));
+ protected TextRetriever retrieveRenderChecker =
retrieveText.locator(jq("#renderChecker"));
+ protected TextRetriever retrieveStatusChecker =
retrieveText.locator(jq("#statusCheckerOutput"));
+ protected PhaseInfo phaseInfo = new PhaseInfo();
+
/**
* timeout in miliseconds
*/
@@ -220,16 +232,36 @@
* @param attribute
* name of the attribute that will be set (e.g. styleClass, headerClass,
itemContentClass)
*/
- protected void testStyleClass(ElementLocator<?> element, String attribute) {
+ protected void testStyleClass(ExtendedLocator<JQueryLocator> element, String
attribute) {
ElementLocator<?> classInput = pjq("input[id$=" + attribute +
"Input]");
- final String value = "metamer-ftest-class";
+ final String styleClass = "metamer-ftest-class";
- selenium.type(classInput, value);
+ selenium.type(classInput, styleClass);
selenium.waitForPageToLoad();
- assertTrue(selenium.belongsClass(element, value), attribute + " does not
work");
+ JQueryLocator elementWhichHasntThatClass = jq(element.getRawLocator() +
":not(.{0})").format(styleClass);
+ assertTrue(selenium.isElementPresent(element));
+ assertFalse(selenium.isElementPresent(elementWhichHasntThatClass));
}
+
+ public void testRequestEventsBefore(String... events) {
+ for (String event : events) {
+ selenium.type(pjq(format("input[type=text][id$=on{0}Input]",
event)), format("metamerEvents += \"{0} \"", event));
+ selenium.waitForPageToLoad();
+ }
+ selenium.getEval(new JavaScript("window.metamerEvents =
\"\";"));
+
+ retrieveRequestTime.initializeValue();
+ }
+
+ public void testRequestEventsAfter(String... events) {
+ waitGui.failWith("Page was not
updated").waitForChange(retrieveRequestTime);
+
+ String[] actualEvents = selenium.getEval(new
JavaScript("window.metamerEvents")).split(" ");
+ assertEquals(actualEvents, events, "The events don't came in right
order");
+ }
+
/**
* A helper method for testing attribute "dir". It tries null, ltr and
rtl.
*
@@ -237,8 +269,8 @@
* locator of tested element
*/
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]");
+ JQueryLocator ltrInput =
pjq("input[type=radio][name$=dirInput][value=ltr],input[type=radio][name$=dirInput][value=LTR]");
+ JQueryLocator rtlInput =
pjq("input[type=radio][name$=dirInput][value=rtl],input[type=radio][name$=dirInput][value=RTL]");
AttributeLocator<?> dirAttribute = element.getAttribute(new
Attribute("dir"));
// dir = null
@@ -249,14 +281,14 @@
selenium.waitForPageToLoad();
assertTrue(selenium.isAttributePresent(dirAttribute), "Attribute dir should
be present.");
String value = selenium.getAttribute(dirAttribute);
- assertEquals(value, "ltr", "Attribute dir");
+ assertEquals(value.toLowerCase(), "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");
+ assertEquals(value.toLowerCase(), "rtl", "Attribute dir");
}
/**
@@ -343,20 +375,8 @@
* Verifies that only given phases were executed. It uses the list of phases in the
header of the page.
* @param phases phases that are expected to have been executed
*/
+ @Deprecated
protected void assertPhases(PhaseId... phases) {
- JQueryLocator phasesItems = jq("div#phasesPanel li");
- int count = selenium.getCount(phasesItems);
-
- String phase;
- int phaseNumber = 1;
-
- for (int i = 0; i < count; i++) {
- phase = selenium.getText(jq("div#phasesPanel li:eq(" + i +
")"));
- // check that it is really name of a phase
- if (!phase.startsWith("* ")) {
- assertEquals(phase, new Phase(phases[phaseNumber - 1]).toString(),
"Phase nr. " + phaseNumber);
- phaseNumber++;
- }
- }
+ phaseInfo.assertPhases(phases);
}
}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * 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;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.testng.Assert.assertEquals;
+
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.event.PhaseId;
+
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.waiting.retrievers.RetrieverFactory;
+import org.jboss.test.selenium.waiting.retrievers.TextRetriever;
+
+/**
+ * Retrieves and asserts the info about life-cycle.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class PhaseInfo {
+
+ private AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ private TextRetriever retrieveRequestTime =
RetrieverFactory.RETRIEVE_TEXT.locator(jq("span[id$=requestTime]"));
+ private JQueryLocator phasesItems = jq("div#phasesPanel li");
+
+ private Map<PhaseId, Set<String>> map = new LinkedHashMap<PhaseId,
Set<String>>();
+
+ /**
+ * Asserts that the phases has occurred in last request by the specified list.
+ */
+ public void assertPhases(PhaseId... expectedPhases) {
+ initialize();
+ PhaseId[] actualPhases = map.keySet().toArray(new PhaseId[map.size()]);
+ assertEquals(actualPhases, expectedPhases);
+ }
+
+ /**
+ * Asserts that in the given phase has occurred the listener or order producer
writing the log message to phases
+ * list.
+ *
+ * @param phaseId
+ * the phase where the listener occurred
+ * @param message
+ * the part of the message which it should be looked up
+ */
+ public void assertListener(PhaseId phaseId, String message) {
+ initialize();
+ Set<String> set = map.get(phaseId);
+ if (set != null && set.size() > 0) {
+ for (String description : set) {
+ if (description.contains(message)) {
+ return;
+ }
+ }
+ }
+ throw new AssertionError("The '" + message + "' wasn't
found across messages in phase " + phaseId);
+ }
+
+ private void initialize() {
+ if (retrieveRequestTime.isValueChanged()) {
+ retrieveRequestTime.initializeValue();
+
+ int count = selenium.getCount(phasesItems);
+
+ Set<String> set;
+ for (int i = 0; i < count; i++) {
+ String description =
selenium.getText(phasesItems.getNthChildElement(i));
+
+ set = new LinkedHashSet<String>();
+ if (!description.startsWith("* ")) {
+ map.put(getPhaseId(description), set);
+ } else {
+ set.add(description.substring(2));
+ }
+ }
+ }
+ }
+
+ private PhaseId getPhaseId(String phaseIdentifier) {
+ for (PhaseId phaseId : PhaseId.VALUES) {
+ if (phaseIdentifier.startsWith(phaseId.toString())) {
+ return phaseId;
+ }
+ }
+ throw new IllegalStateException("no such phase '" + phaseIdentifier
+ "'");
+ }
+
+}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/ModelIterable.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/ModelIterable.java 2011-01-20
18:43:56 UTC (rev 21131)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/ModelIterable.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -34,13 +34,16 @@
ExtendedLocator<E> locator = iterator.next();
try {
- Constructor<T> constructor =
classT.getConstructor(ExtendedLocator.class);
- T newInstance = constructor.newInstance(locator);
- return newInstance;
+ for (Constructor<?> constructor : classT.getConstructors()) {
+ if
(ExtendedLocator.class.isAssignableFrom(constructor.getParameterTypes()[0])) {
+ T newInstance = (T) constructor.newInstance(locator);
+ return newInstance;
+ }
+ }
} catch (Exception e) {
throw new IllegalStateException(e);
}
-
+ throw new NoSuchMethodError("There is no constructor for
ExtendedLocator");
}
@Override
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/AbstractTreeNodeModel.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/AbstractTreeNodeModel.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/AbstractTreeNodeModel.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * 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.richTree;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
+
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.reference.ReferencedLocator;
+import org.richfaces.tests.metamer.ftest.model.AbstractModel;
+import org.richfaces.tests.metamer.ftest.model.ModelIterable;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class AbstractTreeNodeModel extends AbstractModel<JQueryLocator> {
+
+ public AbstractTreeNodeModel(JQueryLocator root) {
+ super(root);
+ }
+
+ public void setTree(TreeModel tree) {
+ this.tree = tree;
+ }
+
+ private AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+ protected TreeModel tree;
+
+ static JQueryLocator treeNode = jq("div.rf-tr-nd");
+ static JQueryLocator treeNodeExpanded = jq("div.rf-tr-nd-exp");
+ static JQueryLocator treeNodeCollapsed = jq("div.rf-tr-nd-colps");
+
+ ReferencedLocator<JQueryLocator> nodes = ref(root, "> " +
treeNode.getRawLocator());
+ ReferencedLocator<JQueryLocator> nodesCollapsed = ref(root, "> " +
treeNodeCollapsed.getRawLocator());
+ ReferencedLocator<JQueryLocator> nodesExpanded = ref(root, "> " +
treeNodeExpanded.getRawLocator());
+
+ public Iterable<TreeNodeModel> getNodes() {
+ Iterable<TreeNodeModel> result = new ModelIterable<JQueryLocator,
TreeNodeModel>(nodes.getAllOccurrences(), TreeNodeModel.class);
+ for (TreeNodeModel trn : result) {
+ trn.setTree(tree);
+ }
+ return result;
+ }
+
+ public TreeNodeModel getNode(int index) {
+ TreeNodeModel trn = new TreeNodeModel(nodes.getNthOccurence(index));
+ trn.setTree(tree);
+ return trn;
+ }
+
+ public Iterable<TreeNodeModel> getExpandedNodes() {
+ Iterable<TreeNodeModel> result = new ModelIterable<JQueryLocator,
TreeNodeModel>(nodesExpanded.getAllOccurrences(), TreeNodeModel.class);
+ for (TreeNodeModel trn : result) {
+ trn.setTree(tree);
+ }
+ return result;
+ }
+
+ public Iterable<TreeNodeModel> getCollapsedNodes() {
+ Iterable<TreeNodeModel> result = new ModelIterable<JQueryLocator,
TreeNodeModel>(nodesCollapsed.getAllOccurrences(), TreeNodeModel.class);
+ for (TreeNodeModel trn : result) {
+ trn.setTree(tree);
+ }
+ return result;
+ }
+
+ public int getExpandedNodesCount() {
+ return selenium.getCount(nodesExpanded);
+ }
+
+ public int getCollapsedNodesCount() {
+ return selenium.getCount(nodesCollapsed);
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeExpansion.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeExpansion.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeExpansion.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * 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.richTree;
+
+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 java.util.Deque;
+import java.util.LinkedList;
+
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestTreeExpansion extends AbstractMetamerTest {
+
+ private static final int TOP_LEVEL_NODES = 4;
+ private static final int DEPTH = 3;
+
+ int[][] PATHS = new int[][] { { 3, 2, 1 }, { 2, 4, 1 } };
+
+ private TreeModel tree = new TreeModel(pjq("div.rf-tr[id$=richTree]"));
+ private TreeNodeModel treeNode;
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richTree/simple.xhtml");
+ }
+
+ @BeforeMethod
+ public void verifyInitialState() {
+ assertEquals(tree.getCollapsedNodesCount(), TOP_LEVEL_NODES);
+ assertEquals(tree.getExpandedNodesCount(), 0);
+ }
+
+ @Test
+ public void testTopLevelNodesExpansion() {
+ for (int i = 1; i <= TOP_LEVEL_NODES; i++) {
+ treeNode = tree.getNode(i);
+ treeNode.expand();
+ assertEquals(tree.getCollapsedNodesCount(), TOP_LEVEL_NODES - i);
+ assertEquals(tree.getExpandedNodesCount(), i);
+ assertTrue(treeNode.isExpanded());
+ }
+ }
+
+ @Test
+ public void testTopLevelNodesCollapsion() {
+ testTopLevelNodesExpansion();
+ for (int i = 1; i <= TOP_LEVEL_NODES; i++) {
+ treeNode = tree.getNode(i);
+ treeNode.expand();
+ assertEquals(tree.getCollapsedNodesCount(), i);
+ assertEquals(tree.getExpandedNodesCount(), TOP_LEVEL_NODES - i);
+ assertTrue(treeNode.isCollapsed());
+ }
+ }
+
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10264")
+ public void testDeepExpansion() {
+ for (int[] path : PATHS) {
+ for (int d = 1; d <= path.length; d++) {
+ int number = path[d - 1];
+ treeNode = (d == 1) ? tree.getNode(number) : treeNode.getNode(number);
+
+ if (d < DEPTH) {
+ assertNodeState(NodeState.COLLAPSED);
+ treeNode.expand();
+ assertNodeState(NodeState.EXPANDED);
+ } else {
+ assertNodeState(NodeState.LEAF);
+ }
+ }
+ }
+ }
+
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10264")
+ public void testDeepCollapsion() {
+ Deque<TreeNodeModel> stack = new LinkedList<TreeNodeModel>();
+
+ testDeepExpansion();
+
+ for (TreeNodeModel treeNode1 : tree.getExpandedNodes()) {
+ stack.push(treeNode1);
+ for (TreeNodeModel treeNode2 : treeNode1.getExpandedNodes()) {
+ stack.push(treeNode2);
+ }
+ }
+
+ while ((treeNode = stack.poll()) != null) {
+ treeNode.expand();
+ }
+ }
+
+ public void assertNodeState(NodeState state) {
+ assertEquals(treeNode.isLeaf() && treeNode.getIcon().isLeaf() &&
treeNode.getHandle().isLeaf(),
+ state == NodeState.LEAF);
+ assertEquals(treeNode.isCollapsed() && treeNode.getIcon().isCollapsed()
&& treeNode.getHandle().isCollapsed(),
+ state == NodeState.COLLAPSED);
+ assertEquals(treeNode.isExpanded() && treeNode.getIcon().isExpanded()
&& treeNode.getHandle().isExpanded(),
+ state == NodeState.EXPANDED);
+ }
+
+ public enum NodeState {
+ LEAF, COLLAPSED, EXPANDED;
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeSimple.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeSimple.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -0,0 +1,319 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * 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.richTree;
+
+import static org.jboss.test.selenium.JQuerySelectors.append;
+import static org.jboss.test.selenium.JQuerySelectors.not;
+import static org.jboss.test.selenium.dom.Event.CLICK;
+import static org.jboss.test.selenium.dom.Event.DBLCLICK;
+import static org.jboss.test.selenium.dom.Event.KEYDOWN;
+import static org.jboss.test.selenium.dom.Event.KEYPRESS;
+import static org.jboss.test.selenium.dom.Event.KEYUP;
+import static org.jboss.test.selenium.dom.Event.MOUSEDOWN;
+import static org.jboss.test.selenium.dom.Event.MOUSEMOVE;
+import static org.jboss.test.selenium.dom.Event.MOUSEOUT;
+import static org.jboss.test.selenium.dom.Event.MOUSEOVER;
+import static org.jboss.test.selenium.dom.Event.MOUSEUP;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guard;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.ExtendedLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.request.RequestType;
+import org.richfaces.component.SwitchType;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestTreeSimple extends AbstractMetamerTest {
+
+ private final static String IMAGE_URL = "/resources/images/loading.gif";
+
+ @Inject
+ @Use(empty = true)
+ Event eventToFire;
+ Event[] eventsToFire = new Event[] { MOUSEDOWN, MOUSEUP, MOUSEOVER, MOUSEOUT };
+
+ @Inject
+ @Use(empty = true)
+ Event domEvent;
+ Event[] domEvents = { CLICK, DBLCLICK, KEYDOWN, KEYPRESS, KEYUP, MOUSEDOWN,
MOUSEMOVE, MOUSEOUT, MOUSEOVER, MOUSEUP };
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richTree/simple.xhtml");
+ }
+
+ TreeModel tree = new TreeModel(pjq("div.rf-tr[id$=richTree]"));
+ TreeNodeModel treeNode;
+
+ TreeAttributes attributes = new
TreeAttributes(pjq("span[id*=attributes]"));
+ TreeNodeAttributes[] nodeAttributes = new TreeNodeAttributes[] {
+ new TreeNodeAttributes(pjq("span[id*=treeNode1Attributes]")),
+ new TreeNodeAttributes(pjq("span[id*=treeNode2Attributes]")),
+ new TreeNodeAttributes(pjq("span[id*=treeNode3Attributes]")) };
+
+ @Test
+ public void testData() {
+ attributes.setData("RichFaces 4");
+ attributes.setOncomplete("data = event.data");
+
+ retrieveRequestTime.initializeValue();
+ tree.getNode(1).select();
+ waitGui.waitForChange(retrieveRequestTime);
+
+ assertEquals(retrieveWindowData.retrieve(), "RichFaces 4");
+ }
+
+ @Test
+ public void testDir() {
+ super.testDir(tree);
+ }
+
+ @Test
+ public void testExecute() {
+ attributes.setExecute("executeChecker @this");
+ tree.getNode(1).select();
+ assertTrue(selenium.isTextPresent("* executeChecker"));
+ }
+
+ @Test
+ public void testHandleClass() {
+ expandAll();
+ super.testStyleClass(tree.getAnyNode().getHandle(), "handleClass");
+ }
+
+ @Test
+ public void testIconClass() {
+ expandAll();
+ super.testStyleClass(tree.getAnyNode().getIcon(), "iconClass");
+ }
+
+ @Test
+ public void testLabelClass() {
+ expandAll();
+ super.testStyleClass(tree.getAnyNode().getLabel(), "labelClass");
+ }
+
+ @Test
+ public void testNodeClass() {
+ expandAll();
+ super.testStyleClass(tree.getAnyNode().getTreeNode(), "nodeClass");
+ }
+
+ @Test
+ public void testIconCollapsed() {
+ attributes.setIconCollapsed(IMAGE_URL);
+
+ for (int i = 0; i < 3; i++) {
+ ExtendedLocator<JQueryLocator> icons = tree.getAnyNode().getIcon();
+ JQueryLocator iconsWithTheGivenUrl = append(icons,
format("[src$={0}]", IMAGE_URL));
+ JQueryLocator iconsWithoutTheGivenUrl = not(icons,
format("[src$={0}]", IMAGE_URL));
+
+ int with = selenium.getCount(iconsWithTheGivenUrl);
+ int without = selenium.getCount(iconsWithoutTheGivenUrl);
+
+ assertEquals(with > 0, i < 2);
+ assertEquals(without > 0, i > 0);
+
+ nodeAttributes[i].setExpanded(true);
+ }
+ }
+
+ @Test
+ public void testIconExpanded() {
+ attributes.setIconExpanded(IMAGE_URL);
+
+ for (int i = 0; i < 3; i++) {
+ ExtendedLocator<JQueryLocator> icons = tree.getAnyNode().getIcon();
+ JQueryLocator iconsWithTheGivenUrl = append(icons,
format("[src$={0}]", IMAGE_URL));
+ JQueryLocator iconsWithoutTheGivenUrl = not(not(icons,
".rf-trn-ico-lf"), format("[src$={0}]", IMAGE_URL));
+
+ int with = selenium.getCount(iconsWithTheGivenUrl);
+ int without = selenium.getCount(iconsWithoutTheGivenUrl);
+
+ assertEquals(with > 0, i > 0);
+ assertEquals(without > 0, i < 2);
+
+ nodeAttributes[i].setExpanded(true);
+ }
+ }
+
+ @Test
+ public void testIconLeaf() {
+ attributes.setIconLeaf(IMAGE_URL);
+
+ for (int i = 0; i < 3; i++) {
+ ExtendedLocator<JQueryLocator> icons = tree.getAnyNode().getIcon();
+ JQueryLocator iconsWithTheGivenUrl = append(icons,
format("[src$={0}]", IMAGE_URL));
+ JQueryLocator iconsWithoutTheGivenUrl = not(not(icons,
".rf-trn-ico-exp"), format("[src$={0}]", IMAGE_URL));
+
+ int with = selenium.getCount(iconsWithTheGivenUrl);
+ int without = selenium.getCount(iconsWithoutTheGivenUrl);
+
+ assertEquals(with > 0, i > 1);
+ assertEquals(without > 0, i < 2);
+
+ nodeAttributes[i].setExpanded(true);
+ }
+ }
+
+ @Test
+ public void testLang() {
+ super.testLang(tree);
+ }
+
+ @Test
+ public void testLimitRender() {
+ attributes.setRender("@this renderChecker");
+ attributes.setLimitRender(true);
+ retrieveRenderChecker.initializeValue();
+ String requestTime = retrieveRequestTime.retrieve();
+ tree.getNode(1).select();
+ waitGui.waitForChange(retrieveRenderChecker);
+ assertEquals(retrieveRequestTime.retrieve(), requestTime);
+ }
+
+ @Test
+ public void testSelectionClientSideEvents() {
+ String[] events = new String[] { "beforeselectionchange",
"begin", "beforedomupdate", "complete",
+ "selectionchange" };
+ testRequestEventsBefore(events);
+ tree.getNode(1).select();
+ testRequestEventsAfter(events);
+ }
+
+ @Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10265")
+ public void testToggleClientSideEvents() {
+ String[] events = new String[] { "beforenodetoggle", "begin",
"beforedomupdate", "complete", "nodetoggle" };
+ testRequestEventsBefore(events);
+ tree.getNode(1).expand();
+ testRequestEventsAfter(events);
+ }
+
+ @Test
+ @Use(field = "domEvent", value = "domEvents")
+ public void testDomEvents() {
+ testFireEvent(domEvent, tree);
+ }
+
+ @Test
+ public void testRender() {
+ attributes.setRender("@this renderChecker");
+ retrieveRenderChecker.initializeValue();
+ tree.getNode(1).select();
+ waitGui.waitForChange(retrieveRenderChecker);
+ }
+
+ @Test
+ public void testRendered() {
+ assertTrue(selenium.isElementPresent(tree) && selenium.isVisible(tree));
+ attributes.setRendered(false);
+ assertFalse(selenium.isElementPresent(tree));
+ }
+
+ @Test
+ public void testStatus() {
+ retrieveStatusChecker.initializeValue();
+ tree.getNode(1).select();
+ assertFalse(retrieveStatusChecker.isValueChanged());
+
+ attributes.setStatus("statusChecker");
+ retrieveStatusChecker.initializeValue();
+ tree.getNode(1).select();
+ assertTrue(retrieveStatusChecker.isValueChanged());
+ }
+
+ @Test
+ public void testStyle() {
+ this.testStyle(tree, "style");
+ }
+
+ @Test
+ public void testStyleClass() {
+ this.testStyleClass(tree, "styleClass");
+ }
+
+ @Test
+ public void testTitle() {
+ this.testTitle(tree);
+ }
+
+ @Test
+ @Use(field = "eventToFire", value = "eventsToFire")
+ public void testToggleNodeEvent() {
+ treeNode = tree.getNode(2);
+ attributes.setSelectionType(SwitchType.client);
+ ExtendedLocator<JQueryLocator> target = treeNode.getLabel();
+
+ for (Event eventToSetup : eventsToFire) {
+ assertTrue(treeNode.isCollapsed());
+ attributes.setToggleNodeEvent(eventToSetup.getEventName());
+
+ fireEvent(target, eventToFire, eventToSetup);
+
+ if (eventToFire == eventToSetup) {
+ assertTrue(treeNode.isExpanded());
+ fireEvent(target, eventToFire, eventToSetup);
+ assertTrue(treeNode.isCollapsed());
+ } else {
+ assertTrue(treeNode.isCollapsed());
+ }
+ }
+ }
+
+ private void fireEvent(ElementLocator<?> target, Event eventToFire, Event
eventToSetup) {
+ RequestType requestType = (eventToFire == eventToSetup) ? RequestType.XHR :
RequestType.NONE;
+ if (eventToFire == MOUSEDOWN) {
+ guard(selenium, requestType).mouseDown(target);
+ }
+ if (eventToFire == MOUSEUP) {
+ guard(selenium, requestType).mouseUp(target);
+ }
+ if (eventToFire == MOUSEOVER) {
+ guard(selenium, requestType).mouseOver(target);
+ }
+ if (eventToFire == MOUSEOUT) {
+ guard(selenium, requestType).mouseOut(target);
+ }
+ }
+
+ private void expandAll() {
+ nodeAttributes[0].setExpanded(true);
+ nodeAttributes[1].setExpanded(true);
+ }
+}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeAttributes.java 2011-01-20
18:43:56 UTC (rev 21131)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeAttributes.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -21,6 +21,8 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richTree;
+import org.jboss.test.selenium.locator.ExtendedLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.component.SwitchType;
import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
@@ -29,66 +31,75 @@
* @version $Revision$
*/
public class TreeAttributes extends AbstractComponentAttributes {
+
+ public TreeAttributes() {
+ super();
+ }
+
+ public <T extends ExtendedLocator<JQueryLocator>> TreeAttributes(T root)
{
+ super(root);
+ }
+
public void setData(String data) {
setProperty("data", data);
}
-
+
public void setExecute(String execute) {
setProperty("execute", execute);
}
-
+
public void setIconCollapsed(String iconCollapsed) {
setProperty("iconCollapsed", iconCollapsed);
}
-
+
public void setIconExpanded(String iconExpanded) {
setProperty("iconExpanded", iconExpanded);
}
-
+
public void setIconLeaf(String iconLeaf) {
setProperty("iconLeaf", iconLeaf);
}
-
+
public void setImmediate(Boolean immediate) {
setProperty("immediate", immediate);
}
-
+
public void setKeepSaved(Boolean keepSaved) {
setProperty("keepSaved", keepSaved);
}
-
+
public void setLang(String lang) {
setProperty("lang", lang);
}
-
- public void setLimitRender(String limitRender) {
+
+ public void setLimitRender(Boolean limitRender) {
setProperty("limitRender", limitRender);
}
-
+
public void setRender(String render) {
setProperty("render", render);
}
-
+
public void setRendered(Boolean rendered) {
setProperty("rendered", rendered);
}
-
+
public void setSelectionType(SwitchType selectionType) {
setProperty("selectionType", selectionType);
}
-
+
public void setStatus(String status) {
setProperty("status", status);
}
-
+
public void setTitle(String title) {
setProperty("title", title);
}
-
+
public void setToggleNodeEvent(String toggleNodeEvent) {
setProperty("toggleNodeEvent", toggleNodeEvent);
}
-
+
public void setToggleType(SwitchType toggleType) {
setProperty("toggleType", toggleType);
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeModel.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeModel.java 2011-01-20
18:43:56 UTC (rev 21131)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeModel.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -21,37 +21,40 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richTree;
-import static org.jboss.test.selenium.locator.LocatorFactory.jq;
-import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
-
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.locator.reference.ReferencedLocator;
-import org.richfaces.tests.metamer.ftest.model.AbstractModel;
-import org.richfaces.tests.metamer.ftest.model.ModelIterable;
+import org.richfaces.component.SwitchType;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class TreeModel extends AbstractModel<JQueryLocator> {
+public class TreeModel extends AbstractTreeNodeModel {
- static JQueryLocator treeNode = jq("> div.rf-td-nd");
+ SwitchType toggleType;
+ SwitchType selectionType;
public TreeModel(JQueryLocator root) {
super(root);
+ this.setTree(this);
}
- public TreeModel(String name, JQueryLocator root) {
- super(name, root);
+ public void setToggleType(SwitchType toggleType) {
+ this.toggleType = toggleType;
}
- ReferencedLocator<JQueryLocator> node = ref(root, treeNode.getRawLocator());
+ public SwitchType getToggleType() {
+ return toggleType;
+ }
- public Iterable<TreeNodeModel> getNodes() {
- return new ModelIterable<JQueryLocator,
TreeNodeModel>(node.getAllOccurrences(), TreeNodeModel.class);
+ public void setSelectionType(SwitchType selectionType) {
+ this.selectionType = selectionType;
}
- public JQueryLocator getNode(int index) {
- return node.getNthOccurence(index);
+ public SwitchType getSelectionType() {
+ return selectionType;
}
+
+ public TreeNodeModel getAnyNode() {
+ return new TreeNodeModel(root.getLocator().getDescendant(treeNode));
+ }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeAttributes.java 2011-01-20
18:43:56 UTC (rev 21131)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeAttributes.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -21,6 +21,8 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richTree;
+import org.jboss.test.selenium.locator.ExtendedLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
/**
@@ -28,38 +30,46 @@
* @version $Revision$
*/
public class TreeNodeAttributes extends AbstractComponentAttributes {
+
+ public TreeNodeAttributes() {
+ }
+
+ public <T extends ExtendedLocator<JQueryLocator>> TreeNodeAttributes(T
root) {
+ super(root);
+ }
+
public void setDir(String dir) {
setProperty("dir", dir);
}
-
+
public void setExpanded(Boolean expanded) {
setProperty("expanded", expanded);
}
-
+
public void setIconCollapsed(String iconCollapsed) {
setProperty("iconCollapsed", iconCollapsed);
}
-
+
public void setIconExpanded(String iconExpanded) {
setProperty("iconExpanded", iconExpanded);
}
-
+
public void setIconLeaf(String iconLeaf) {
setProperty("iconLeaf", iconLeaf);
}
-
+
public void setImmediate(Boolean immediate) {
setProperty("immediate", immediate);
}
-
+
public void setLang(String lang) {
setProperty("lang", lang);
}
-
+
public void setRendered(Boolean rendered) {
setProperty("rendered", rendered);
}
-
+
public void setTitle(String title) {
setProperty("title", title);
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeModel.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeModel.java 2011-01-20
18:43:56 UTC (rev 21131)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TreeNodeModel.java 2011-01-20
19:04:55 UTC (rev 21132)
@@ -21,13 +21,17 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richTree;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
+import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.geometry.Point;
import org.jboss.test.selenium.locator.ExtendedLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.locator.reference.ReferencedLocator;
+import org.junit.Assert;
import org.richfaces.tests.metamer.ftest.model.AbstractModel;
import org.richfaces.tests.metamer.ftest.model.ModelIterable;
@@ -35,35 +39,31 @@
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class TreeNodeModel extends AbstractModel<JQueryLocator> {
+public class TreeNodeModel extends AbstractTreeNodeModel {
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+ private AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- ReferencedLocator<JQueryLocator> subnodes = ref(root,
TreeModel.treeNode.getRawLocator());
+ private ReferencedLocator<JQueryLocator> subnodes = ref(root,
TreeModel.treeNode.getRawLocator());
- String classNodeExpanded = "rf-tr-nd-exp";
- String classNodeLeaf = "rf-tr-nd-lf";
- String classNodeCollapsed = "rf-tr-nd-lf";
- String classSelected = "rf-trn-sel";
+ private String classNodeExpanded = "rf-tr-nd-exp";
+ private String classNodeLeaf = "rf-tr-nd-lf";
+ private String classNodeCollapsed = "rf-tr-nd-colps";
+ private String classSelected = "rf-trn-sel";
- ReferencedLocator<JQueryLocator> treeNode = ref(root, ">
div.rf-trn");
- ReferencedLocator<JQueryLocator> handle = ref(treeNode, ">
span.rf-trn-hnd");
- ReferencedLocator<JQueryLocator> content = ref(treeNode, ">
span.rf-trn-cnt");
- ReferencedLocator<JQueryLocator> icon = ref(content, ">
span.rf-trn-ico");
- ReferencedLocator<JQueryLocator> label = ref(content, ">
span.rf-trn-lbl");
+ private ReferencedLocator<JQueryLocator> treeNode = ref(root, ">
div.rf-trn");
+ private ReferencedLocator<JQueryLocator> handle = ref(treeNode, ">
span.rf-trn-hnd");
+ private ReferencedLocator<JQueryLocator> content = ref(treeNode, ">
span.rf-trn-cnt");
+ private ReferencedLocator<JQueryLocator> icon = ref(content, ">
.rf-trn-ico");
+ private ReferencedLocator<JQueryLocator> label = ref(content, ">
.rf-trn-lbl");
public TreeNodeModel(JQueryLocator root) {
super(root);
}
-
- public Iterable<TreeNodeModel> getNodes() {
- return new ModelIterable<JQueryLocator,
TreeNodeModel>(subnodes.getAllOccurrences(), TreeNodeModel.class);
+
+ public ExtendedLocator<JQueryLocator> getTreeNode() {
+ return treeNode;
}
- public JQueryLocator getNode(int index) {
- return subnodes.getNthOccurence(index);
- }
-
public TreeNodeHandle getHandle() {
return new TreeNodeHandle(handle.getReferenced());
}
@@ -95,4 +95,12 @@
public String getLabelText() {
return selenium.getText(label);
}
+
+ public void expand() {
+ guardXhr(selenium).click(getHandle());
+ }
+
+ public void select() {
+ guardXhr(selenium).clickAt(getLabel(), new Point(0,0));
+ }
}