Author: sergeyhalipov
Date: 2008-04-21 14:13:00 -0400 (Mon, 21 Apr 2008)
New Revision: 8044
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/panelMenu/
trunk/test-applications/seleniumTest/src/main/webapp/pages/panelMenu/panelMenuDescription.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/panelMenu/panelMenuTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/PanelMenuTest.java
Log:
Selenium tests for panel menu.
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/panelMenu/panelMenuDescription.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/panelMenu/panelMenuDescription.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/panelMenu/panelMenuDescription.xhtml 2008-04-21
18:13:00 UTC (rev 8044)
@@ -0,0 +1,5 @@
+<html>
+<table border="1" style="border-color: #F1EEE9"
cellpadding="5" cellspacing="0">
+
+</table>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/panelMenu/panelMenuTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/panelMenu/panelMenuTest.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/panelMenu/panelMenuTest.xhtml 2008-04-21
18:13:00 UTC (rev 8044)
@@ -0,0 +1,83 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="../../layout/template.xhtml">
+ <ui:define name="style">
+ .link {margin: 0px 5px}
+ </ui:define>
+ <ui:define name="component">
+ <rich:panelMenu id="pMenu" >
+ <rich:panelMenuGroup id="pGroup1" expandMode="ajax"
+ label="Ajax group"
+ action="#{panelBean.increment}"
+ actionListener="#{panelBean.actionListener}"
+ reRender="_value,_value2" >
+ <rich:panelMenuItem id="pItem1"
+ label="Item 1"
+ action="#{panelBean.action1}"
+ actionListener="#{panelBean.actionListener}" />
+ </rich:panelMenuGroup>
+ <rich:panelMenuGroup id="pGroup2" expandMode="server"
+ label="Server group"
+ action="#{panelBean.increment}"
+ actionListener="#{panelBean.actionListener}" >
+ <rich:panelMenuItem id="pItem2"
+ label="Item 2" />
+ </rich:panelMenuGroup>
+ <rich:panelMenuGroup id="pGroup3"
+ label="Client group">
+ <rich:panelMenuItem id="pItem3"
+ label="Item 3" />
+ </rich:panelMenuGroup>
+ <rich:panelMenuGroup id="pGroup4" disabled="true"
+ label="Disabled group" >
+ <rich:panelMenuItem id="pItem4"
+ label="Item 4" />
+ </rich:panelMenuGroup>
+ </rich:panelMenu>
+
+ <rich:panelMenu id="pMenu_single" expandSingle="true" >
+ <rich:panelMenuGroup id="pGroup1_single" expandMode="ajax"
+ label="Ajax group"
+ action="#{panelBean.increment}"
+ actionListener="#{panelBean.actionListener}"
+ reRender="_value,_value2" >
+ <rich:panelMenuItem id="pItem1_single"
+ label="Item 1"
+ action="#{panelBean.action2}"
+ actionListener="#{panelBean.actionListener}" />
+ </rich:panelMenuGroup>
+ <rich:panelMenuGroup id="pGroup2_single" expandMode="server"
+ label="Server group"
+ action="#{panelBean.increment}"
+ actionListener="#{panelBean.actionListener}" >
+ <rich:panelMenuItem id="pItem2_single"
+ label="Item 2" />
+ </rich:panelMenuGroup>
+ <rich:panelMenuGroup id="pGroup3_single"
+ label="Client group">
+ <rich:panelMenuItem id="pItem3_single"
+ label="Item 3" />
+ </rich:panelMenuGroup>
+ <rich:panelMenuGroup id="pGroup4_single" disabled="true"
+ label="Disabled group" >
+ <rich:panelMenuItem id="pItem4_single"
+ label="Item 4" />
+ </rich:panelMenuGroup>
+ </rich:panelMenu>
+
+ <br/>
+ <h:inputText value="#{panelBean.value}"
id="_value"></h:inputText>
+ <h:outputText value="#{panelBean.value2}"
id="_value2"></h:outputText>
+ <br/>
+ </ui:define>
+ <ui:define name="description">
+ <ui:include src="panelMenuDescription.xhtml" />
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/PanelMenuTest.java
===================================================================
--- trunk/test-applications/seleniumTest/src/test/java/org/richfaces/PanelMenuTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/PanelMenuTest.java 2008-04-21
18:13:00 UTC (rev 8044)
@@ -0,0 +1,198 @@
+package org.richfaces;
+
+import org.ajax4jsf.test.base.RichSeleniumTest;
+import org.ajax4jsf.test.base.SeleniumTestBase;
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+import com.thoughtworks.selenium.SeleniumException;
+
+public class PanelMenuTest extends SeleniumTestBase implements RichSeleniumTest {
+
+ public PanelMenuTest() {
+ super("http", "localhost", "8080");
+ }
+
+ /**
+ * This method are invoking before selenium tests started
+ */
+ @BeforeTest
+ @Parameters( { "browser" })
+ public void startSelenium(String browser) {
+ super.startSelenium(browser);
+ }
+
+ /**
+ * This method are invoking after selenium tests completed
+ */
+ @AfterTest
+ public void stopSelenium() {
+ super.stopSelenium();
+ }
+
+ @Test
+ public void testPanelMenuComponent() throws Exception {
+ renderPage("/faces/pages/panelMenu/panelMenuTest.xhtml");
+
+ _testPanelMenuComponent(COMPONENT_PREFIX_INSIDE_PANEL);
+ _testPanelMenuComponent(COMPONENT_PREFIX_INSIDE_TABLE);
+
+ _testPanelMenuComponentSingleMode(COMPONENT_PREFIX_INSIDE_PANEL);
+ _testPanelMenuComponentSingleMode(COMPONENT_PREFIX_INSIDE_TABLE);
+
+ _testPanelMenuItemAction(COMPONENT_PREFIX_INSIDE_PANEL);
+ _testPanelMenuItemAction(COMPONENT_PREFIX_INSIDE_TABLE);
+ }
+
+ private void _testPanelMenuComponent(String parentId) {
+ String inputId = parentId + "_value";
+ String outputId = parentId + "_value2";
+
+ String ajaxGroup = "tablehide" + parentId + "pGroup1";
+ String serverGroup = "tablehide" + parentId + "pGroup2";
+ String clientGroup = "tablehide" + parentId + "pGroup3";
+ String disabledGroup = "tablehide" + parentId + "pGroup4";
+
+ String ajaxItem = "tablehide" + parentId + "pItem1";
+ String serverItem = "tablehide" + parentId + "pItem2";
+ String clientItem = "tablehide" + parentId + "pItem3";
+ String disabledItem = "tablehide" + parentId + "pItem4";
+
+ clickById(ajaxGroup);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "pGroup1");
+ AssertTextEquals(outputId, "1");
+ Assert.assertTrue(isVisibleById(ajaxItem));
+ Assert.assertFalse(isVisibleById(serverItem));
+ Assert.assertFalse(isVisibleById(clientItem));
+
+ clickById(serverGroup);
+ waitForPageToLoad();
+ AssertValueEquals(inputId, "pGroup2");
+ AssertTextEquals(outputId, "2");
+ Assert.assertTrue(isVisibleById(ajaxItem));
+ Assert.assertTrue(isVisibleById(serverItem));
+ Assert.assertFalse(isVisibleById(clientItem));
+
+ clickById(ajaxGroup);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "pGroup1");
+ AssertTextEquals(outputId, "3");
+ Assert.assertFalse(isVisibleById(ajaxItem));
+ Assert.assertTrue(isVisibleById(serverItem));
+ Assert.assertFalse(isVisibleById(clientItem));
+
+ clickById(serverGroup);
+ waitForPageToLoad();
+ AssertValueEquals(inputId, "pGroup2");
+ AssertTextEquals(outputId, "4");
+ Assert.assertFalse(isVisibleById(ajaxItem));
+ Assert.assertFalse(isVisibleById(serverItem));
+ Assert.assertFalse(isVisibleById(clientItem));
+
+ clickById(clientGroup);
+ Assert.assertFalse(isVisibleById(ajaxItem));
+ Assert.assertFalse(isVisibleById(serverItem));
+ Assert.assertTrue(isVisibleById(clientItem));
+
+ clickById(clientGroup);
+ Assert.assertFalse(isVisibleById(ajaxItem));
+ Assert.assertFalse(isVisibleById(serverItem));
+ Assert.assertFalse(isVisibleById(clientItem));
+
+ clickById(disabledGroup);
+ Assert.assertFalse(isVisibleById(disabledItem));
+ }
+
+ private void _testPanelMenuComponentSingleMode(String parentId) {
+ String inputId = parentId + "_value";
+ String outputId = parentId + "_value2";
+
+ String ajaxGroup = "tablehide" + parentId +
"pGroup1_single";
+ String serverGroup = "tablehide" + parentId +
"pGroup2_single";
+ String clientGroup = "tablehide" + parentId +
"pGroup3_single";
+ String disabledGroup = "tablehide" + parentId +
"pGroup4_single";
+
+ String ajaxItem = "tablehide" + parentId + "pItem1_single";
+ String serverItem = "tablehide" + parentId +
"pItem2_single";
+ String clientItem = "tablehide" + parentId +
"pItem3_single";
+ String disabledItem = "tablehide" + parentId +
"pItem4_single";
+
+ clickById(ajaxGroup);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "pGroup1_single");
+ AssertTextEquals(outputId, "1");
+ Assert.assertTrue(isVisibleById(ajaxItem));
+ Assert.assertFalse(isVisibleById(serverItem));
+ Assert.assertFalse(isVisibleById(clientItem));
+
+ clickById(serverGroup);
+ waitForPageToLoad();
+ AssertValueEquals(inputId, "pGroup2_single");
+ AssertTextEquals(outputId, "2");
+ Assert.assertFalse(isVisibleById(ajaxItem));
+ Assert.assertTrue(isVisibleById(serverItem));
+ Assert.assertFalse(isVisibleById(clientItem));
+
+ clickById(ajaxGroup);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "pGroup1_single");
+ AssertTextEquals(outputId, "3");
+ Assert.assertTrue(isVisibleById(ajaxItem));
+ Assert.assertFalse(isVisibleById(serverItem));
+ Assert.assertFalse(isVisibleById(clientItem));
+
+ clickById(serverGroup);
+ waitForPageToLoad();
+ AssertValueEquals(inputId, "pGroup2_single");
+ AssertTextEquals(outputId, "4");
+ Assert.assertFalse(isVisibleById(ajaxItem));
+ Assert.assertTrue(isVisibleById(serverItem));
+ Assert.assertFalse(isVisibleById(clientItem));
+
+ clickById(clientGroup);
+ Assert.assertFalse(isVisibleById(ajaxItem));
+ Assert.assertFalse(isVisibleById(serverItem));
+ Assert.assertTrue(isVisibleById(clientItem));
+
+ clickById(clientGroup);
+ Assert.assertFalse(isVisibleById(ajaxItem));
+ Assert.assertFalse(isVisibleById(serverItem));
+ Assert.assertFalse(isVisibleById(clientItem));
+
+ clickById(disabledGroup);
+ Assert.assertFalse(isVisibleById(disabledItem));
+ }
+
+ private void _testPanelMenuItemAction(String parentId) {
+ String inputId = parentId + "_value";
+ String outputId = parentId + "_value2";
+
+ String group = "tablehide" + parentId + "pGroup1";
+ String groupSingle = "tablehide" + parentId + "pGroup1_single";
+
+ String item = "tablehide" + parentId + "pItem1";
+ String itemSingle = "tablehide" + parentId +
"pItem1_single";
+
+ clickById(group);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "pGroup1");
+
+ clickById(groupSingle);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "pGroup1_single");
+
+ clickById(item);
+ waitForPageToLoad();
+ AssertValueEquals(inputId, "pItem1");
+ AssertTextEquals(outputId, "1");
+
+ clickById(itemSingle);
+ waitForPageToLoad();
+ AssertValueEquals(inputId, "pItem1_single");
+ AssertTextEquals(outputId, "2");
+ }
+}