Author: sergeyhalipov
Date: 2008-05-12 14:48:29 -0400 (Mon, 12 May 2008)
New Revision: 8533
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/ContextMenuTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/contextMenu/
trunk/test-applications/seleniumTest/src/main/webapp/pages/contextMenu/contextMenu.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/contextMenu/contextMenuDescription.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ContextMenuTest.java
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
Log:
Selenium tests for context menu.
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/ContextMenuTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/ContextMenuTestBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/ContextMenuTestBean.java 2008-05-12
18:48:29 UTC (rev 8533)
@@ -0,0 +1,56 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf;
+
+import javax.faces.event.ActionEvent;
+
+public class ContextMenuTestBean {
+
+ private String value;
+ private int value2 = 0;
+
+ public void actionListener(ActionEvent event) {
+ this.value = event.getComponent().getId();
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String action() {
+ value2++;
+ return null;
+ }
+
+ public int getValue2() {
+ return value2;
+ }
+
+ public void setValue2(int value2) {
+ this.value2 = value2;
+ }
+
+}
Modified: trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-05-12
17:28:36 UTC (rev 8532)
+++
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-05-12
18:48:29 UTC (rev 8533)
@@ -77,4 +77,9 @@
<managed-bean-class>org.ajax4jsf.ComboBoxTestBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>contextMenuBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.ContextMenuTestBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
</faces-config>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/contextMenu/contextMenu.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/contextMenu/contextMenu.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/contextMenu/contextMenu.xhtml 2008-05-12
18:48:29 UTC (rev 8533)
@@ -0,0 +1,62 @@
+<!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="#{templateBean.template}">
+ <ui:define name="component">
+ <h:form id="_form">
+ <rich:contextMenu submitMode="server" id="menu_input"
attached="false" >
+ <rich:menuItem action="#{contextMenuBean.action}"
+ value="One" submitMode="ajax"
+ actionListener="#{contextMenuBean.actionListener}"
+ id="menu1_item1"
+ reRender="input,input2" >
+ </rich:menuItem>
+ <rich:menuSeparator />
+ <rich:menuItem action="#{contextMenuBean.action}"
+ value="Two"
+ actionListener="#{contextMenuBean.actionListener}"
+ id="menu1_item2" >
+ </rich:menuItem>
+ <rich:menuItem action="#{contextMenuBean.action}"
+ value="Three"
+ actionListener="#{contextMenuBean.actionListener}" >
+ </rich:menuItem>
+ </rich:contextMenu>
+
+ <h:inputText id="input" value="#{contextMenuBean.value}" />
+ <h:inputText id="input2" value="#{contextMenuBean.value2}"
>
+ <rich:contextMenu submitMode="server" id="menu_input2"
event="onclick" >
+ <rich:menuItem action="#{contextMenuBean.action}"
+ value="One" submitMode="ajax"
+ actionListener="#{contextMenuBean.actionListener}"
+ id="menu2_item1"
+ reRender="input,input2" >
+ </rich:menuItem>
+ <rich:menuSeparator />
+ <rich:menuItem action="#{contextMenuBean.action}"
+ value="Two"
+ actionListener="#{contextMenuBean.actionListener}"
+ id="menu2_item2" >
+ </rich:menuItem>
+ <rich:menuItem action="#{contextMenuBean.action}"
+ value="Three"
+ actionListener="#{contextMenuBean.actionListener}" >
+ </rich:menuItem>
+ </rich:contextMenu>
+ </h:inputText>
+
+ <rich:componentControl event="onclick" attachTo="input"
for=":_form:menu_input"
+ operation="doShow">
+ </rich:componentControl>
+ </h:form>
+ </ui:define>
+ <ui:define name="description">
+ <ui:include src="contextMenuDescription.xhtml" />
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/contextMenu/contextMenuDescription.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/contextMenu/contextMenuDescription.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/contextMenu/contextMenuDescription.xhtml 2008-05-12
18:48:29 UTC (rev 8533)
@@ -0,0 +1,9 @@
+<html>
+<table border="1" style="border-color: #F1EEE9"
cellpadding="5" cellspacing="0">
+ <tr>
+ <th></th>
+ <th>Action</th>
+ <th>Result</th>
+ </tr>
+</table>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ContextMenuTest.java
===================================================================
--- trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ContextMenuTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/ContextMenuTest.java 2008-05-12
18:48:29 UTC (rev 8533)
@@ -0,0 +1,88 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces;
+
+import org.ajax4jsf.test.base.RichSeleniumTest;
+import org.ajax4jsf.test.base.SeleniumTestBase;
+import org.ajax4jsf.test.base.Templates;
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+public class ContextMenuTest extends SeleniumTestBase implements RichSeleniumTest {
+
+ public ContextMenuTest() {
+ 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 testContextMenuComponent() throws Exception {
+ _testContextMenuComponent(Templates.SIMPLE);
+ _testContextMenuComponent(Templates.DATATABLE);
+ }
+
+ private void _testContextMenuComponent(Templates template) {
+ renderPage(getTestUrl(), template);
+
+ String parentId = getParentId() + "_form:";
+ String inputId = parentId + "input";
+ String input2Id = parentId + "input2";
+ String menuId = parentId + "menu_input_menu";
+ String menu2Id = parentId + "menu_input2_menu";
+
+ writeStatus("Click on first input");
+ clickById(inputId);
+ Assert.assertTrue(isVisibleById(menuId));
+
+ writeStatus("Click on second input");
+ clickById(input2Id);
+ Assert.assertTrue(isVisibleById(menu2Id));
+ Assert.assertFalse(isVisibleById(menuId));
+
+
+ }
+
+ public String getTestUrl() {
+ return "/faces/pages/contextMenu/contextMenu.xhtml";
+ }
+
+}
+