Author: alevkovsky
Date: 2008-08-01 09:28:16 -0400 (Fri, 01 Aug 2008)
New Revision: 9861
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/ModalPanelTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/modalPanel/
trunk/test-applications/seleniumTest/src/main/webapp/pages/modalPanel/modalPanelTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ModalPanelTest.java
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java
Log:
Add rich:modalPanel selenium test
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/ModalPanelTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/ModalPanelTestBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/ModalPanelTestBean.java 2008-08-01
13:28:16 UTC (rev 9861)
@@ -0,0 +1,89 @@
+/*
+ * ModalPanelTestBean.java Date created: 30.07.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.ajax4jsf.bean;
+
+/**
+ * rich:modalPannel component test bean
+ * @author Alexandr Levkovsky
+ *
+ */
+public class ModalPanelTestBean {
+
+ private Boolean rendered = true;
+ private Boolean showWhenRendered = false;
+ private Boolean moveable = true;
+ private Boolean resizeable = true;
+ /**
+ * @return the rendered
+ */
+ public Boolean getRendered() {
+ return rendered;
+ }
+ /**
+ * @param rendered the rendered to set
+ */
+ public void setRendered(Boolean rendered) {
+ this.rendered = rendered;
+ }
+ /**
+ * @return the showWhenRendered
+ */
+ public Boolean getShowWhenRendered() {
+ return showWhenRendered;
+ }
+ /**
+ * @param showWhenRendered the showWhenRendered to set
+ */
+ public void setShowWhenRendered(Boolean showWhenRendered) {
+ this.showWhenRendered = showWhenRendered;
+ }
+ /**
+ * @return the moveable
+ */
+ public Boolean getMoveable() {
+ return moveable;
+ }
+ /**
+ * @param moveable the moveable to set
+ */
+ public void setMoveable(Boolean moveable) {
+ this.moveable = moveable;
+ }
+ /**
+ * @return the resizeable
+ */
+ public Boolean getResizeable() {
+ return resizeable;
+ }
+ /**
+ * @param resizeable the resizeable to set
+ */
+ public void setResizeable(Boolean resizeable) {
+ this.resizeable = resizeable;
+ }
+
+ public String changeAttributes(){
+ showWhenRendered = true;
+ moveable = false;
+ resizeable = false;
+ return null;
+ }
+
+ public String changeRendered(){
+ rendered = false;
+ return null;
+ }
+
+ public String reset(){
+ rendered = true;
+ showWhenRendered = false;
+ moveable = true;
+ resizeable = true;
+ return null;
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/ModalPanelTestBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
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-08-01
12:48:40 UTC (rev 9860)
+++
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-08-01
13:28:16 UTC (rev 9861)
@@ -205,6 +205,11 @@
<managed-bean-name>toolBarBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.ToolBarTestBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>modalPanelBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.ModalPanelTestBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/ajaxInclude/step1.xhtml</from-view-id>
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/modalPanel/modalPanelTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/src/main/webapp/pages/modalPanel/modalPanelTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java 2008-08-01
12:48:40 UTC (rev 9860)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java 2008-08-01
13:28:16 UTC (rev 9861)
@@ -777,6 +777,18 @@
selenium.mouseUp(testElementId);
AssertTextEquals(testElementResultId, afterResult);
}
+
+ /**
+ * Method to assert element style attribute with expected
+ * @param elementId - tested element id
+ * @param expectedExpression - expected style attribute
+ */
+ public void assertStyleAttribute(String elementId, String expectedExpression) {
+ String styleAttribute = selenium.getAttribute("//*[@id='" + elementId +
"']/@style");
+ if (!styleAttribute.toLowerCase().contains(expectedExpression.toLowerCase())) {
+ Assert.fail("Element '" + elementId + "' with style
'" + styleAttribute + "' doesn't contain '" +
expectedExpression + "'");
+ }
+ }
/**
* Checks whether client is FireFox
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ModalPanelTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ModalPanelTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ModalPanelTest.java 2008-08-01
13:28:16 UTC (rev 9861)
@@ -0,0 +1,157 @@
+/*
+ * ModalPanelTest.java Date created: 30.07.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.richfaces.testng;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.SeleniumTestBase;
+import org.testng.annotations.Test;
+
+/**
+ * rich:modalPannel component selenium test
+ * @author Alexandr Levkovsky
+ *
+ */
+public class ModalPanelTest extends SeleniumTestBase {
+
+ private final static String PANEL_ID="test_panel";
+ private final static String FORM_ID="form:";
+ private final static String RESET_ID="reset";
+ private final static String CHANGE_RENDERED_ID="change_rendered";
+ private final static String CHANGE_ATTRIBUTES_ID="change_attributes";
+ private final static String HIDE_ID="hide";
+ private final static String SHOW_ID="show";
+ private final static String PANEL_C_DIV_ID = PANEL_ID + "CDiv";
+ private final static String PANEL_CONTENT_DIV_ID = PANEL_ID +
"ContentDiv";
+ private final static String PANEL_CONTAINER_DIV_ID = PANEL_ID +
"Container";
+
+
+ /**
+ * @see org.richfaces.SeleniumTestBase#getTestUrl()
+ */
+ @Override
+ public String getTestUrl() {
+ return "pages/modalPanel/modalPanelTest.xhtml";
+ }
+
+ @Test
+ public void testModalPanel(Template template) throws Exception {
+ renderPage(template);
+ writeStatus("Testing modal panel");
+
+ String panelId = getParentId() + FORM_ID + PANEL_CONTAINER_DIV_ID;
+
+ AssertPresent(panelId);
+ AssertNotVisible(panelId);
+
+ clickShow();
+
+ AssertPresent(panelId);
+ AssertVisible(panelId);
+
+ clickHide();
+
+ AssertPresent(panelId);
+ AssertNotVisible(panelId);
+
+ }
+
+ @Test
+ public void testRenderedAttribute(Template template) throws Exception {
+ renderPage(template);
+ writeStatus("Testing rendered attribute");
+
+ String panelId = getParentId() + FORM_ID + PANEL_CONTAINER_DIV_ID;
+
+ AssertPresent(panelId);
+
+ clickChangeRendered();
+
+ AssertNotPresent(panelId);
+ clickReset();
+ }
+
+ @Test
+ public void testShowWhenRenderedAttribute(Template template) throws Exception {
+ renderPage(template);
+ writeStatus("Testing showWhenRendered attribute");
+
+ String panelId = getParentId() + FORM_ID + PANEL_CONTAINER_DIV_ID;
+
+ AssertPresent(panelId);
+ AssertNotVisible(panelId);
+
+ clickChangeAttributes();
+
+ AssertPresent(panelId);
+ AssertVisible(panelId);
+ clickReset();
+ }
+
+ @Test
+ public void testLayoutAttributes(Template template) throws Exception {
+ renderPage(template);
+ writeStatus("Testing layout attribute");
+
+ clickShow();
+
+ String panelContainerId = getParentId() + FORM_ID + PANEL_CONTAINER_DIV_ID;
+ String panelContentId = getParentId() + FORM_ID + PANEL_CONTENT_DIV_ID;
+ String panelCDivId = getParentId() + FORM_ID + PANEL_C_DIV_ID;
+
+ AssertPresent(panelContainerId);
+ AssertPresent(panelContentId);
+ AssertPresent(panelCDivId);
+
+ // test zindex attribute - should be 12
+ assertStyleAttribute(panelContainerId, "z-index: 12");
+
+ if (isFF()) {
+ // test top attribute - should be 101
+ assertStyleAttribute(panelCDivId, "top: 101");
+
+ // test left attribute - should be 102
+ assertStyleAttribute(panelCDivId, "left: 102");
+ }
+
+ // test width attribute - should be 103
+ assertStyleAttribute(panelContentId, "width: 103");
+
+ // test height attribute - should be 104
+ assertStyleAttribute(panelContentId, "height: 104");
+ }
+
+ private void clickReset() {
+ String buttonId = getParentId() + FORM_ID + RESET_ID;
+ writeStatus("Click reset button");
+ clickCommandAndWait(buttonId);
+ }
+
+ private void clickChangeRendered() {
+ String buttonId = getParentId() + FORM_ID + CHANGE_RENDERED_ID;
+ writeStatus("Click change rendered button");
+ clickCommandAndWait(buttonId);
+ }
+
+ private void clickChangeAttributes() {
+ String buttonId = getParentId() + FORM_ID + CHANGE_ATTRIBUTES_ID;
+ writeStatus("Click change attributes button");
+ clickCommandAndWait(buttonId);
+ }
+
+ private void clickShow() {
+ String buttonId = getParentId() + FORM_ID + SHOW_ID;
+ writeStatus("Click show button");
+ clickById(buttonId);
+ }
+
+ private void clickHide() {
+ String buttonId = getParentId() + FORM_ID + HIDE_ID;
+ writeStatus("Click hide button");
+ clickById(buttonId);
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ModalPanelTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native