Author: sergeyhalipov
Date: 2008-04-18 15:14:08 -0400 (Fri, 18 Apr 2008)
New Revision: 7950
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelDescription.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TogglePanelTest.java
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SimpleTogglePanelTest.java
Log:
Selenium tests for toggle panel.
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelDescription.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelDescription.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelDescription.xhtml 2008-04-18
19:14:08 UTC (rev 7950)
@@ -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/togglePanel/togglePanelTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelTest.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelTest.xhtml 2008-04-18
19:14:08 UTC (rev 7950)
@@ -0,0 +1,88 @@
+<!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:togglePanel id="panel_ajax" switchType="ajax"
initialState="one"
+ stateOrder="one,two">
+ <f:facet name="one">
+ <h:outputText id="ajax_state_one" value="State One" />
+ </f:facet>
+ <f:facet name="two">
+ <h:outputText id="ajax_state_two" value="State Two" />
+ </f:facet>
+ </rich:togglePanel>
+ <rich:toggleControl id="ajax_next" for="panel_ajax"
+ action="#{panelBean.increment}"
actionListener="#{panelBean.actionListener}" >
+ <h:outputText value="Next" />
+ </rich:toggleControl>
+ <rich:toggleControl id="ajax_one" for="panel_ajax"
switchToState="one"
+ action="#{panelBean.increment}"
actionListener="#{panelBean.actionListener}" >
+ <h:outputText value="One" />
+ </rich:toggleControl>
+ <rich:toggleControl id="ajax_two" for="panel_ajax"
switchToState="two"
+ action="#{panelBean.action1}"
actionListener="#{panelBean.actionListener}" >
+ <h:outputText value="Two" />
+ </rich:toggleControl>
+
+ <rich:togglePanel id="panel_server" switchType="server"
initialState="one"
+ stateOrder="one,two">
+ <f:facet name="one">
+ <h:outputText id="server_state_one" value="State One" />
+ </f:facet>
+ <f:facet name="two">
+ <h:outputText id="server_state_two" value="State Two" />
+ </f:facet>
+ </rich:togglePanel>
+ <rich:toggleControl id="server_next" for="panel_server"
+ action="#{panelBean.increment}"
actionListener="#{panelBean.actionListener}" >
+ <h:outputText value="Next" />
+ </rich:toggleControl>
+ <rich:toggleControl id="server_one" for="panel_server"
switchToState="one"
+ action="#{panelBean.increment}"
actionListener="#{panelBean.actionListener}" >
+ <h:outputText value="One" />
+ </rich:toggleControl>
+ <rich:toggleControl id="server_two" for="panel_server"
switchToState="two"
+ action="#{panelBean.increment}"
actionListener="#{panelBean.actionListener}" >
+ <h:outputText value="Two" />
+ </rich:toggleControl>
+
+ <rich:togglePanel id="panel_client" switchType="client"
initialState="one"
+ stateOrder="one,two">
+ <f:facet name="one">
+ <h:outputText id="client_state_one" value="State One" />
+ </f:facet>
+ <f:facet name="two">
+ <h:outputText id="client_state_two" value="State Two" />
+ </f:facet>
+ </rich:togglePanel>
+ <rich:toggleControl id="client_next" for="panel_client" >
+ <h:outputText value="Next" />
+ </rich:toggleControl>
+ <rich:toggleControl id="client_one" for="panel_client"
switchToState="one" >
+ <h:outputText value="One" />
+ </rich:toggleControl>
+ <rich:toggleControl id="client_two" for="panel_client"
switchToState="two" >
+ <h:outputText value="Two" />
+ </rich:toggleControl>
+
+ <br/>
+ <a4j:outputPanel ajaxRendered="true" >
+ <h:inputText value="#{panelBean.value}"
id="_value"></h:inputText>
+ <h:outputText value="#{panelBean.value2}"
id="_value2"></h:outputText>
+ </a4j:outputPanel>
+ <br/>
+ </ui:define>
+ <ui:define name="description">
+ <ui:include src="togglePanelDescription.xhtml" />
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java 2008-04-18
17:37:39 UTC (rev 7949)
+++
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java 2008-04-18
19:14:08 UTC (rev 7950)
@@ -152,7 +152,7 @@
Assert.fail("The page has been not rendered properlly");
}
}catch (Exception e) {
- Assert.fail("The page has been not rendered properlly by the following error:
" + e);
+ Assert.fail("The page has not been rendered properly due the following error:
" + e);
}
}
/**
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SimpleTogglePanelTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SimpleTogglePanelTest.java 2008-04-18
17:37:39 UTC (rev 7949)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SimpleTogglePanelTest.java 2008-04-18
19:14:08 UTC (rev 7950)
@@ -53,7 +53,7 @@
}
@Test
- public void testTabPanelComponent() throws Exception {
+ public void testSimpleTogglePanelComponent() throws Exception {
renderPage("/faces/pages/simpleTogglePanel/simpleTogglePanel.xhtml");
_testSimpleTogglePanelComponent(COMPONENT_PREFIX_INSIDE_PANEL);
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TogglePanelTest.java
===================================================================
--- trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TogglePanelTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TogglePanelTest.java 2008-04-18
19:14:08 UTC (rev 7950)
@@ -0,0 +1,172 @@
+/**
+ * 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.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 TogglePanelTest extends SeleniumTestBase implements RichSeleniumTest {
+
+ public TogglePanelTest() {
+ 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 testTogglePanelComponent() throws Exception {
+ renderPage("/faces/pages/togglePanel/togglePanelTest.xhtml");
+
+ _testTogglePanelComponent(COMPONENT_PREFIX_INSIDE_PANEL);
+ _testTogglePanelComponent(COMPONENT_PREFIX_INSIDE_TABLE);
+ }
+
+ private void _testTogglePanelComponent(String parentId) {
+ String inputId = parentId + "_value";
+ String outputId = parentId + "_value2";
+
+ String controlNext = parentId + "ajax_next";
+ String controlOne = parentId + "ajax_one";
+ String controlTwo = parentId + "ajax_two";
+
+ String oneFacet = parentId + "ajax_state_one";
+ String twoFacet = parentId + "ajax_state_two";
+
+ clickById(controlNext);
+ waitForAjaxCompletion(5000);
+ AssertValueEquals(inputId, "ajax_next");
+ AssertTextEquals(outputId, "1");
+ Assert.assertTrue(isVisibleById(twoFacet));
+ try {
+ getTextById(oneFacet);
+ Assert.fail("Both of 'one' and 'two' states were rendered
for ajax toggle panel.");
+ } catch (SeleniumException se) {
+
+ }
+
+ clickById(controlOne);
+ waitForAjaxCompletion(5000);
+ AssertValueEquals(inputId, "ajax_one");
+ AssertTextEquals(outputId, "2");
+ Assert.assertTrue(isVisibleById(oneFacet));
+ try {
+ getTextById(twoFacet);
+ Assert.fail("Both of 'one' and 'two' states were rendered
for ajax toggle panel.");
+ } catch (SeleniumException se) {
+
+ }
+
+ clickById(controlTwo);
+ waitForAjaxCompletion(5000);
+ AssertValueEquals(inputId, "ajax_two");
+ AssertTextEquals(outputId, "1");
+ Assert.assertTrue(isVisibleById(twoFacet));
+ try {
+ getTextById(oneFacet);
+ Assert.fail("Both of 'one' and 'two' states were rendered
for ajax toggle panel.");
+ } catch (SeleniumException se) {
+
+ }
+
+ controlNext = parentId + "server_next";
+ controlOne = parentId + "server_one";
+ controlTwo = parentId + "server_two";
+ oneFacet = parentId + "server_state_one";
+ twoFacet = parentId + "server_state_two";
+
+ clickById(controlNext);
+ waitForPageToLoad();
+ AssertValueEquals(inputId, "server_next");
+ AssertTextEquals(outputId, "2");
+ Assert.assertTrue(isVisibleById(twoFacet));
+ try {
+ getTextById(oneFacet);
+ Assert.fail("Both of 'one' and 'two' states were rendered
for server toggle panel.");
+ } catch (SeleniumException se) {
+
+ }
+
+ clickById(controlOne);
+ waitForPageToLoad();
+ AssertValueEquals(inputId, "server_one");
+ AssertTextEquals(outputId, "3");
+ Assert.assertTrue(isVisibleById(oneFacet));
+ try {
+ getTextById(twoFacet);
+ Assert.fail("Both of 'one' and 'two' states were rendered
for server toggle panel.");
+ } catch (SeleniumException se) {
+
+ }
+
+ clickById(controlTwo);
+ waitForPageToLoad();
+ AssertValueEquals(inputId, "server_two");
+ AssertTextEquals(outputId, "4");
+ Assert.assertTrue(isVisibleById(twoFacet));
+ try {
+ getTextById(oneFacet);
+ Assert.fail("Both of 'one' and 'two' states were rendered
for server toggle panel.");
+ } catch (SeleniumException se) {
+
+ }
+
+ controlNext = parentId + "client_next";
+ controlOne = parentId + "client_one";
+ controlTwo = parentId + "client_two";
+ oneFacet = parentId + "client_state_one";
+ twoFacet = parentId + "client_state_two";
+
+ clickById(controlNext);
+ Assert.assertTrue(isVisibleById(twoFacet));
+ Assert.assertFalse(isVisibleById(oneFacet));
+
+ clickById(controlOne);
+ Assert.assertTrue(isVisibleById(oneFacet));
+ Assert.assertFalse(isVisibleById(twoFacet));
+
+ clickById(controlTwo);
+ Assert.assertTrue(isVisibleById(twoFacet));
+ Assert.assertFalse(isVisibleById(oneFacet));
+ }
+}