Author: lfryc(a)redhat.com
Date: 2011-01-23 15:31:19 -0500 (Sun, 23 Jan 2011)
New Revision: 21162
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreePhases.java
Modified:
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/TestTreeToggling.java
Log:
rich:tree - automated Simple sample - phases capabilities (RFPL-935)
Modified:
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 2011-01-23
20:30:31 UTC (rev 21161)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java 2011-01-23
20:31:19 UTC (rev 21162)
@@ -26,11 +26,13 @@
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import javax.faces.event.PhaseId;
+import org.apache.commons.lang.ArrayUtils;
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
import org.jboss.test.selenium.locator.JQueryLocator;
@@ -55,6 +57,9 @@
*/
public void assertPhases(PhaseId... expectedPhases) {
initialize();
+ if (ArrayUtils.contains(expectedPhases, PhaseId.ANY_PHASE)) {
+ expectedPhases = new LinkedList<PhaseId>(PhaseId.VALUES).subList(1,
7).toArray(new PhaseId[6]);
+ }
PhaseId[] actualPhases = map.keySet().toArray(new PhaseId[map.size()]);
assertEquals(actualPhases, expectedPhases);
}
@@ -88,12 +93,12 @@
int count = selenium.getCount(phasesItems);
- Set<String> set;
+ Set<String> set = null;
for (int i = 1; i <= count; i++) {
String description =
selenium.getText(phasesItems.getNthChildElement(i));
- set = new LinkedHashSet<String>();
if (!description.startsWith("* ")) {
+ set = new LinkedHashSet<String>();
map.put(getPhaseId(description), set);
} else {
set.add(description.substring(2));
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreePhases.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreePhases.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreePhases.java 2011-01-23
20:31:19 UTC (rev 21162)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import javax.faces.event.PhaseId;
+
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestTreePhases extends AbstractMetamerTest {
+ @Inject
+ @Use(booleans = { true, false })
+ Boolean immediate;
+
+ private TreeAttributes treeAttributes = new
TreeAttributes(jq("span[id*=attributes]"));
+ private TreeModel tree = new TreeModel(pjq("div.rf-tr[id$=richTree]"));
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richTree/simple.xhtml");
+ }
+
+ @BeforeMethod
+ public void initialize() {
+ treeAttributes.setImmediate(immediate);
+ }
+
+ @Test
+ public void testPhasesSelection() {
+ tree.getNode(2).expand();
+ tree.getNode(2).getNode(3).select();
+ phaseInfo.assertPhases(PhaseId.ANY_PHASE);
+ phaseInfo.assertListener(PhaseId.APPLY_REQUEST_VALUES, "selection change
listener invoked");
+ }
+
+ @Test
+ public void testPhasesToggling() {
+ tree.getNode(2).expand();
+ PhaseId phaseId = (immediate) ? PhaseId.APPLY_REQUEST_VALUES :
PhaseId.PROCESS_VALIDATIONS;
+ phaseInfo.assertListener(phaseId, "tree toggle listener invoked");
+ }
+}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeToggling.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeToggling.java 2011-01-23
20:30:31 UTC (rev 21161)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTree/TestTreeToggling.java 2011-01-23
20:31:19 UTC (rev 21162)
@@ -33,7 +33,6 @@
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.BeforeMethod;
import org.testng.annotations.Test;