Author: andrei_exadel
Date: 2008-04-29 08:23:11 -0400 (Tue, 29 Apr 2008)
New Revision: 8292
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TogglePanelTest.java
Log:
Toggle Panel Test refactoring
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelTest.xhtml 2008-04-29
12:22:58 UTC (rev 8291)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/togglePanel/togglePanelTest.xhtml 2008-04-29
12:23:11 UTC (rev 8292)
@@ -15,7 +15,8 @@
margin: 2px;
}
</ui:define>
- <ui:define name="component">
+ <ui:define name="component">
+ <h:form id="_form">
<h:panelGroup layout="block" styleClass="component_div" >
<rich:togglePanel id="panel_ajax" switchType="ajax"
initialState="one"
stateOrder="one,two">
@@ -92,15 +93,12 @@
</h:panelGroup>
<br/>
- <!--a4j:outputPanel ajaxRendered="true" id="outputPanel" >
+ <a4j:outputPanel ajaxRendered="true" id="outputPanel" >
<h:inputText value="#{panelBean.value}"
id="_value"></h:inputText>
<h:outputText value="#{panelBean.value2}"
id="_value2"></h:outputText>
- </a4j:outputPanel-->
- <a4j:log popup="false" />
+ </a4j:outputPanel>
<br/>
+ </h:form>
</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/richfaces/TogglePanelTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TogglePanelTest.java 2008-04-29
12:22:58 UTC (rev 8291)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/TogglePanelTest.java 2008-04-29
12:23:11 UTC (rev 8292)
@@ -1,191 +1,193 @@
-/**
- * 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.TemplateBean;
-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 TogglePanelTest extends SeleniumTestBase implements
- RichSeleniumTest {
- private static final String PAGE =
"/faces/pages/togglePanel/togglePanelTest.xhtml";
-
- 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 {
- _testTogglePanelComponent(Templates.SIMPLE);
- _testTogglePanelComponent(Templates.DATATABLE);
- }
-
- private void _testTogglePanelComponent(Templates template) {
- template.loadTemplate(this);
-
- String parentId = getParentId();
- renderPage(PAGE + "?" + TemplateBean.PARAM_NAME + "=" + template);
-
- 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);
- pause(60000, "");
- 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));
- }
-
- 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 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 {
+ _testTogglePanelComponent(Templates.SIMPLE);
+ _testTogglePanelComponent(Templates.DATATABLE);
+ }
+
+ private void _testTogglePanelComponent(Templates template) {
+ renderPage(getTestUrl(), template);
+ String parentId = getParentId() + "_form:";
+
+ 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";
+
+ writeStatus("Click on ajax controlNext");
+ clickById(controlNext);
+ waitForAjaxCompletion();
+ //pause(6000, "panel_ajax");
+ 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) {
+
+ }
+
+ writeStatus("Click on ajax controlOne");
+ 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) {
+
+ }
+
+ writeStatus("Click on ajax controlTwo");
+ 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";
+
+ writeStatus("Click on controlNext");
+ clickCommandAndWait(controlNext);
+ 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) {
+
+ }
+
+ writeStatus("Click on server controlOne");
+ clickCommandAndWait(controlOne);
+ 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) {
+
+ }
+
+ writeStatus("Click on server controlTwo");
+ clickCommandAndWait(controlTwo);
+ 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";
+
+ writeStatus("Click on client controlNext");
+ clickById(controlNext);
+ Assert.assertTrue(isVisibleById(twoFacet));
+ Assert.assertFalse(isVisibleById(oneFacet));
+
+ writeStatus("Click on client controlOne");
+ clickById(controlOne);
+ Assert.assertTrue(isVisibleById(oneFacet));
+ Assert.assertFalse(isVisibleById(twoFacet));
+
+ writeStatus("Click on client controlTwo");
+ clickById(controlTwo);
+ Assert.assertTrue(isVisibleById(twoFacet));
+ Assert.assertFalse(isVisibleById(oneFacet));
+ }
+
+ public String getTestUrl() {
+ return "/faces/pages/togglePanel/togglePanelTest.xhtml";
+ }
+
+}