Author: sergeyhalipov
Date: 2008-04-17 14:10:44 -0400 (Thu, 17 Apr 2008)
New Revision: 7906
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/TabPanelTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelDescription.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TabPanelTest.java
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java
Log:
Selenium tests for tab panel.
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/TabPanelTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/TabPanelTestBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/TabPanelTestBean.java 2008-04-17
18:10:44 UTC (rev 7906)
@@ -0,0 +1,44 @@
+package org.ajax4jsf;
+
+import javax.faces.event.ActionEvent;
+
+public class TabPanelTestBean {
+ private String value;
+ private String value2;
+
+ public TabPanelTestBean() {
+ value = "";
+ value2 = "";
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public void actionListener(ActionEvent event) {
+ this.value = event.getComponent().getId();
+ }
+
+ public String action1() {
+ this.value2 = "1";
+ return null;
+ }
+
+ public String action2() {
+ this.value2 = "2";
+ return null;
+ }
+
+ public String getValue2() {
+ return value2;
+ }
+
+ public void setValue2(String 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-04-17
17:02:40 UTC (rev 7905)
+++
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-04-17
18:10:44 UTC (rev 7906)
@@ -26,5 +26,10 @@
<managed-bean-class>org.ajax4jsf.A4JCommandTestBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>tabPanelBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.TabPanelTestBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
</faces-config>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelDescription.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelDescription.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelDescription.xhtml 2008-04-17
18:10:44 UTC (rev 7906)
@@ -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/tabPanel/tabPanelTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelTest.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelTest.xhtml 2008-04-17
18:10:44 UTC (rev 7906)
@@ -0,0 +1,50 @@
+<!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:tabPanel id="panel1" switchType="ajax" >
+ <rich:tab label="tab1"
+ id="tab1"
+ action="#{tabPanelBean.action1}"
+ actionListener="#{tabPanelBean.actionListener}"
+ switchType="server"
+ >
+ </rich:tab>
+ <rich:tab label="tab2"
+ id="tab2"
+ action="#{tabPanelBean.action2}"
+ actionListener="#{tabPanelBean.actionListener}"
+ reRender="_value,_value2"
+ >
+ </rich:tab>
+ <rich:tab label="tab3"
+ id="tab3"
+ disabled="true"
+ >
+ </rich:tab>
+ <rich:tab label="tab4"
+ id="tab4"
+ switchType="client"
+ >
+ </rich:tab>
+ </rich:tabPanel>
+
+ <br/>
+ <h:inputText value="#{tabPanelBean.value}"
id="_value"></h:inputText>
+ <h:outputText value="#{tabPanelBean.value2}"
id="_value2"></h:outputText>
+ <br/>
+ </ui:define>
+ <ui:define name="description">
+ <ui:include src="tabPanelDescription.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-17
17:02:40 UTC (rev 7905)
+++
trunk/test-applications/seleniumTest/src/test/java/org/ajax4jsf/test/base/SeleniumTestBase.java 2008-04-17
18:10:44 UTC (rev 7906)
@@ -154,12 +154,28 @@
/**
* Waits while AJAX request will be completed
*
- * @param miliseconds -
- * time to wait
*/
public void waitForAjaxCompletion() {
selenium.waitForCondition("selenium.browserbot.getCurrentWindow().done==true",
String.valueOf(ajaxCompletionTime));
}
+
+ /**
+ * Waits while simple request will be completed
+ *
+ * @param miliseconds -
+ * time to wait
+ */
+ public void waitForPageToLoad(int miliseconds) {
+ selenium.waitForPageToLoad(String.valueOf(miliseconds));
+ }
+
+ /**
+ * Waits while simple request will be completed
+ *
+ */
+ public void waitForPageToLoad() {
+ selenium.waitForPageToLoad(String.valueOf(pageRenderTime));
+ }
/**
* Asserts DOM node value equals to value defined
Added: trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TabPanelTest.java
===================================================================
--- trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TabPanelTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TabPanelTest.java 2008-04-17
18:10:44 UTC (rev 7906)
@@ -0,0 +1,79 @@
+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;
+
+public class TabPanelTest extends SeleniumTestBase implements RichSeleniumTest {
+
+ public TabPanelTest() {
+ super("http", "localhost", "8080");
+ }
+
+ public TabPanelTest(String protocol, String host, String port) {
+ super(protocol, host, port);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * 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 testTabPanelComponent() throws Exception {
+ renderPage("/faces/pages/tabPanel/tabPanelTest.xhtml");
+
+ _testRichTabPanelComponent(COMPONENT_PREFIX_INSIDE_PANEL);
+ _testRichTabPanelComponent(COMPONENT_PREFIX_INSIDE_TABLE);
+ }
+
+ private void _testRichTabPanelComponent(String parentId) {
+ String linkId = parentId + "tab2_lbl";
+ String tabId1 = parentId + "tab1";
+ String tabId2 = parentId + "tab2";
+ String tabId4 = parentId + "tab4";
+ String inputId = parentId + "_value";
+ String outputId = parentId + "_value2";
+
+ clickById(linkId);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "tab2");
+ Assert.assertTrue(isVisibleById(tabId2));
+ AssertTextEquals(outputId, "2");
+
+
+ linkId = parentId + "tab1_lbl";
+ clickById(linkId);
+ waitForPageToLoad();
+ AssertValueEquals(inputId, "tab1");
+ Assert.assertTrue(isVisibleById(tabId1));
+ AssertTextEquals(outputId, "1");
+
+ linkId = parentId + "tab3_lbl";
+ clickById(linkId);
+ AssertValueEquals(inputId, "tab1");
+ Assert.assertTrue(isVisibleById(tabId1));
+
+ linkId = parentId + "tab4_lbl";
+ clickById(linkId);
+ Assert.assertTrue(isVisibleById(tabId4));
+ }
+
+}