Author: andrei_exadel
Date: 2008-04-29 08:00:30 -0400 (Tue, 29 Apr 2008)
New Revision: 8283
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TabPanelTest.java
Log:
Tab panel test refactoring
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelTest.xhtml 2008-04-29
11:52:10 UTC (rev 8282)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/tabPanel/tabPanelTest.xhtml 2008-04-29
12:00:30 UTC (rev 8283)
@@ -6,11 +6,12 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
-<ui:composition template="../../layout/template.xhtml">
+<ui:composition template="#{templateBean.template}">
<ui:define name="style">
.link {margin: 0px 5px}
</ui:define>
<ui:define name="component">
+ <h:form id="_form">
<rich:tabPanel id="panel1" switchType="ajax" >
<rich:tab label="tab1"
id="tab1"
@@ -46,9 +47,7 @@
<h:inputText value="#{panelBean.value}"
id="_value"></h:inputText>
<h:outputText value="#{panelBean.value2}"
id="_value2"></h:outputText>
<br/>
+ </h:form>
</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/richfaces/TabPanelTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TabPanelTest.java 2008-04-29
11:52:10 UTC (rev 8282)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TabPanelTest.java 2008-04-29
12:00:30 UTC (rev 8283)
@@ -1,128 +1,131 @@
-/**
- * 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 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_SIMPLE);
-// _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");
- AssertTextEquals(outputId, "2");
- Assert.assertTrue(isVisibleById(tabId2));
- Assert.assertFalse(isVisibleById(tabId4));
- try {
- getTextById(tabId1);
- Assert.fail("Both of 'tab1' and 'tab2' tabs were rendered
for tab panel.");
- } catch (SeleniumException se) {
-
- }
-
-
- linkId = parentId + "tab1_lbl";
- clickById(linkId);
- waitForPageToLoad();
- AssertValueEquals(inputId, "tab1");
- AssertTextEquals(outputId, "1");
- Assert.assertTrue(isVisibleById(tabId1));
- Assert.assertFalse(isVisibleById(tabId4));
- try {
- getTextById(tabId2);
- Assert.fail("Both of 'tab1' and 'tab2' tabs were rendered
for tab panel.");
- } catch (SeleniumException se) {
-
- }
-
- linkId = parentId + "tab3_lbl";
- clickById(linkId);
- AssertValueEquals(inputId, "tab1");
- Assert.assertTrue(isVisibleById(tabId1));
-
- linkId = parentId + "tab4_lbl";
- clickById(linkId);
- Assert.assertTrue(isVisibleById(tabId4));
- Assert.assertFalse(isVisibleById(tabId1));
- try {
- getTextById(tabId2);
- Assert.fail("Both of 'tab1' and 'tab2' tabs were rendered
for tab panel.");
- } catch (SeleniumException se) {
-
- }
- }
-
- public String getTestUrl() {
- return null;
- }
-
-
-}
+/**
+ * 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;
+
+import com.thoughtworks.selenium.SeleniumException;
+
+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 {
+ _testRichTabPanelComponent(Templates.SIMPLE);
+ _testRichTabPanelComponent(Templates.DATATABLE);
+ }
+
+ private void _testRichTabPanelComponent(Templates template) {
+ renderPage(getTestUrl(), template);
+ String parentId = getParentId() + "_form:";
+ 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";
+
+ writeStatus("Click on tab1");
+ clickById(linkId);
+ waitForAjaxCompletion();
+ AssertValueEquals(inputId, "tab2");
+ AssertTextEquals(outputId, "2");
+ Assert.assertTrue(isVisibleById(tabId2));
+ Assert.assertFalse(isVisibleById(tabId4));
+ try {
+ getTextById(tabId1);
+ Assert.fail("Both of 'tab1' and 'tab2' tabs were rendered
for tab panel.");
+ } catch (SeleniumException se) {
+
+ }
+
+ writeStatus("Click on tab2");
+ linkId = parentId + "tab1_lbl";
+ clickCommandAndWait(linkId);
+ AssertValueEquals(inputId, "tab1");
+ AssertTextEquals(outputId, "1");
+ Assert.assertTrue(isVisibleById(tabId1));
+ Assert.assertFalse(isVisibleById(tabId4));
+ try {
+ getTextById(tabId2);
+ Assert.fail("Both of 'tab1' and 'tab2' tabs were rendered
for tab panel.");
+ } catch (SeleniumException se) {
+
+ }
+
+ writeStatus("Click on tab3");
+ linkId = parentId + "tab3_lbl";
+ clickById(linkId);
+ AssertValueEquals(inputId, "tab1");
+ Assert.assertTrue(isVisibleById(tabId1));
+
+ writeStatus("Click on tab4");
+ linkId = parentId + "tab4_lbl";
+ clickById(linkId);
+ Assert.assertTrue(isVisibleById(tabId4));
+ Assert.assertFalse(isVisibleById(tabId1));
+ try {
+ getTextById(tabId2);
+ Assert.fail("Both of 'tab1' and 'tab2' tabs were rendered
for tab panel.");
+ } catch (SeleniumException se) {
+
+ }
+ }
+
+ public String getTestUrl() {
+ return "/faces/pages/tabPanel/tabPanelTest.xhtml";
+ }
+
+
+}