[richfaces-svn-commits] JBoss Rich Faces SVN: r9002 - in trunk/test-applications/seleniumTest/src: main/webapp/WEB-INF and 4 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Jun 11 12:41:48 EDT 2008


Author: alevkovsky
Date: 2008-06-11 12:41:48 -0400 (Wed, 11 Jun 2008)
New Revision: 9002

Added:
   trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JOutputPanelTestBean.java
   trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxOutputPanel/
   trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxOutputPanel/ajaxOutputPanelTest.xhtml
   trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxOutputPanelTest.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 selenium test for a4j:outputPannel component

Added: trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JOutputPanelTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JOutputPanelTestBean.java	                        (rev 0)
+++ trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JOutputPanelTestBean.java	2008-06-11 16:41:48 UTC (rev 9002)
@@ -0,0 +1,101 @@
+/*
+ * A4JOutputPanelTestBean.java		Date created: 11.06.2008
+ * Last modified by: $Author$
+ * $Revision$	$Date$
+ */
+
+package org.ajax4jsf.bean;
+
+/**
+ * A4JOutputPanel Test Bean
+ * @author Alexandr Levkovsky
+ *
+ */
+public class A4JOutputPanelTestBean {
+    
+    private Boolean panel1VisibleFlag = true;
+    private Boolean panel2VisibleFlag = true;
+    private Boolean panel3VisibleFlag = true;
+    private Boolean panel4VisibleFlag = true;
+    
+    /**
+     * @return the panel1VisibleFlag
+     */
+    public Boolean getPanel1VisibleFlag() {
+        return panel1VisibleFlag;
+    }
+    /**
+     * @param panel1VisibleFlag the panel1VisibleFlag to set
+     */
+    public void setPanel1VisibleFlag(Boolean panel1VisibleFlag) {
+        this.panel1VisibleFlag = panel1VisibleFlag;
+    }
+    /**
+     * @return the panel2VisibleFlag
+     */
+    public Boolean getPanel2VisibleFlag() {
+        return panel2VisibleFlag;
+    }
+    /**
+     * @param panel2VisibleFlag the panel2VisibleFlag to set
+     */
+    public void setPanel2VisibleFlag(Boolean panel2VisibleFlag) {
+        this.panel2VisibleFlag = panel2VisibleFlag;
+    }
+    
+    /**
+     * @return the panel3VisibleFlag
+     */
+    public Boolean getPanel3VisibleFlag() {
+        return panel3VisibleFlag;
+    }
+    
+    /**
+     * @param panel3VisibleFlag the panel3VisibleFlag to set
+     */
+    public void setPanel3VisibleFlag(Boolean panel3VisibleFlag) {
+        this.panel3VisibleFlag = panel3VisibleFlag;
+    }
+         
+    /**
+     * @return the panel4VisibleFlag
+     */
+    public Boolean getPanel4VisibleFlag() {
+        return panel4VisibleFlag;
+    }
+    
+    /**
+     * @param panel4VisibleFlag the panel4VisibleFlag to set
+     */
+    public void setPanel4VisibleFlag(Boolean panel4VisibleFlag) {
+        this.panel4VisibleFlag = panel4VisibleFlag;
+    }
+    
+    public String b1Action(){
+	return null;
+    }
+    
+    public String b2Action(){
+	setPanel1VisibleFlag(false);
+	setPanel2VisibleFlag(false);
+	return null;
+    }
+    
+    public String b3Action(){
+	setPanel3VisibleFlag(false);
+	return null;
+    }
+    
+    public String b4Action(){
+	setPanel4VisibleFlag(false);
+	return null;
+    }
+    
+    public String reset(){
+	setPanel1VisibleFlag(true);
+	setPanel2VisibleFlag(true);
+	setPanel3VisibleFlag(true);
+	setPanel4VisibleFlag(true);
+	return null;
+    }
+}


Property changes on: trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JOutputPanelTestBean.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-06-11 16:26:13 UTC (rev 9001)
+++ trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml	2008-06-11 16:41:48 UTC (rev 9002)
@@ -126,6 +126,11 @@
 		<managed-bean-scope>session</managed-bean-scope>
 	</managed-bean>
 	<managed-bean>
+		<managed-bean-name>a4jOutputPanelBean</managed-bean-name>
+		<managed-bean-class>org.ajax4jsf.bean.A4JOutputPanelTestBean</managed-bean-class>
+		<managed-bean-scope>session</managed-bean-scope>
+	</managed-bean>
+	<managed-bean>
 		<managed-bean-name>calendarBean</managed-bean-name>
 		<managed-bean-class>org.ajax4jsf.bean.CalendarTestBean</managed-bean-class>
 		<managed-bean-scope>session</managed-bean-scope>

Added: trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxOutputPanel/ajaxOutputPanelTest.xhtml
===================================================================
(Binary files differ)


Property changes on: trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxOutputPanel/ajaxOutputPanelTest.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-06-11 16:26:13 UTC (rev 9001)
+++ trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java	2008-06-11 16:41:48 UTC (rev 9002)
@@ -419,6 +419,26 @@
     public void AssertNotVisible(String id) {
         Assert.assertFalse(isVisibleById(id));
     }
+    
+    /**
+     * Asserts DOM node is present
+     * @param id - DOM element id
+     */
+    public void AssertRendered(String id) {
+	if (!isPresentById(id)) {
+	    Assert.fail("Component " + id + " should be rendered on page");
+	}
+    }
+    
+    /**
+     * Asserts DOM node is not present
+     * @param id - DOM element id
+     */
+    public void AssertNotRendered(String id) {
+	if (isPresentById(id)) {
+	    Assert.fail("Component " + id + " should not be rendered on page");
+	}
+    }
 
     /**
      * Returns element's text

Added: trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxOutputPanelTest.java
===================================================================
--- trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxOutputPanelTest.java	                        (rev 0)
+++ trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxOutputPanelTest.java	2008-06-11 16:41:48 UTC (rev 9002)
@@ -0,0 +1,247 @@
+/*
+ * AjaxOutputPanel.java		Date created: 10.06.2008
+ * Last modified by: $Author$
+ * $Revision$	$Date$
+ */
+
+package org.richfaces.testng;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.RichSeleniumTest;
+import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+/**
+ * Ajax Output Panel selenium test
+ * @author Alexandr Levkovsky
+ * 
+ */
+public class AjaxOutputPanelTest extends SeleniumTestBase implements RichSeleniumTest {
+
+    public AjaxOutputPanelTest() {
+	super("http", "localhost", serverPort);
+    }
+
+    /**
+     * This method are invoking before selenium tests started
+     */
+    @BeforeMethod
+    @Parameters( { "browser", "filterPrefix" })
+    public void startSelenium(String browser, String filterPrefix) {
+	super.startSelenium(browser, filterPrefix);
+	
+	//TODO should pass as parameter 
+	renderPage(Template.SIMPLE);
+    }
+
+    @BeforeMethod
+    @Parameters( { "loadStyleStrategy", "loadScriptStrategy" })
+    protected void loadConfiguration(String loadStyleStrategy, String loadScriptStrategy) throws Exception {
+	super.loadConfiguration(loadStyleStrategy, loadScriptStrategy);
+    }
+
+    /**
+     * This method are invoking after selenium tests completed
+     */
+    @AfterMethod(alwaysRun = true)
+    public void stopSelenium() {
+	super.stopSelenium();
+    }
+
+    public String getTestUrl() {
+	return "pages/ajaxOutputPanel/ajaxOutputPanelTest.xhtml";
+    }
+
+    @Test
+    public void testLayoutAttribute() throws Exception {
+	// panel_1 has layout=inline(default)
+	// panel_2 has layout=block
+	// panel_3 has layout=none
+	writeStatus("Testing layout attribute...");
+
+	String panelId = "form:panel_1";
+	String panel2Id = "form:panel_2";
+	String panel3Id = getParentId() + "form:panel_3";
+
+	String type = runScript("getElementType('" + panelId + "')");
+	Assert.assertEquals(type.toLowerCase(), "span", "panel_1 has layout=inline(default) and should be 'span' element");
+
+	type = runScript("getElementType('" + panel2Id + "')");
+	Assert.assertEquals(type.toLowerCase(), "div", "panel_2 has layout=block and should be 'div' element");
+
+	// panel_3 has layout=none and should not present if a child component
+	// is rendered
+	if (isPresentById(panel3Id)) {
+	    Assert.fail("panel_3 has layout=none and should not peresent if a child component is rendered ");
+	}
+
+	// remove child component rendering
+	writeStatus("Click button 3");
+	String buttonId = getParentId() + "form:b3";
+	clickById(buttonId);
+	waitForAjaxCompletion();
+	// panel_3 has layout=none and should present if no child component is
+	// rendered with id of a child component and display:none style
+	if (!isPresentById(panel3Id + "_text")) {
+	    Assert.fail("panel_3 has layout=none and should peresent if no child component is rendered with id of a child component");
+	}
+	if (isVisibleById(panel3Id + "_text")) {
+	    Assert.fail("panel_3 has layout=none and should peresent if no child component is rendered with display:none style");
+	}
+    }
+
+    @Test
+    public void testRenderedAttribute() throws Exception {
+	writeStatus("Testing rendered attribute...");
+
+	String panelId = getParentId() + "form:panel_4";
+
+	// panel_4 has rendered=true and should present on page
+	AssertRendered(panelId);
+
+	// change rendered attribute to false
+	writeStatus("Click button 4");
+	String buttonId = getParentId() + "form:b4";
+	clickCommandAndWait(buttonId);
+
+	// panel_4 has rendered=false and should not present on page
+	AssertNotRendered(panelId);
+    }
+
+    @Test
+    public void testAjaxRenderedAttribute() throws Exception {
+	// panel_1 has ajaxRendered=false and is reRender by b1
+	// panel_2 has ajaxRendered=true
+	writeStatus("Testing ajaxRendered attribute...");
+
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_1_text";
+	String panelId2 = parentId + "panel_2_text";
+	String buttonId = parentId + "b2";
+	writeStatus("Click button 2");
+	// set panel_1 text visible flag to false
+	clickById(buttonId);
+	waitForAjaxCompletion();
+	// panel_1 text should be visible as it reRendered only by b1
+	if (!isPresentById(panelId)) {
+	    Assert.fail("panel_1 text should be visible as it reRendered only by b1");
+	}
+	// panel_2 text should not be visible as it has ajaxRendered=true
+	if (isPresentById(panelId2)) {
+	    Assert.fail("panel_2 text should not be visible as it has ajaxRendered=true");
+	}
+
+	buttonId = parentId + "b1";
+	writeStatus("Click button 1");
+	clickById(buttonId);
+	waitForAjaxCompletion();
+	// panel text should NOT be visible as it reRendered by b1
+	if (isPresentById(panelId)) {
+	    Assert.fail("panel_1 text should not be visible as it reRendered by b1");
+	}
+    }
+
+    @Test
+    public void testOnDoubleClickEvent() throws Exception {
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_5";
+	writeStatus("Check ondoubleclick event");
+	selenium.doubleClick(panelId);
+	String panelResultId = panelId + "_result";
+	AssertTextEquals(panelResultId, "Yes");
+    }
+
+    @Test
+    public void testOnKeyDownEvent() throws Exception {
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_6";
+	writeStatus("Check onkeydown event");
+	selenium.keyDown(panelId, "1");
+	String panelResultId = panelId + "_result";
+	AssertTextEquals(panelResultId, "Yes");
+    }
+
+    @Test
+    public void testOnKeyPressEvent() throws Exception {
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_7";
+	writeStatus("Check onkeypress event");
+	selenium.keyPress(panelId, "1");
+	String panelResultId = panelId + "_result";
+	AssertTextEquals(panelResultId, "Yes");
+    }
+
+    @Test
+    public void testOnKeyUpEvent() throws Exception {
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_8";
+	writeStatus("Check onkeyup event");
+	selenium.keyUp(panelId, "1");
+	String panelResultId = panelId + "_result";
+	AssertTextEquals(panelResultId, "Yes");
+    }
+
+    @Test
+    public void testOnMouseDownEvent() throws Exception {
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_9";
+	writeStatus("Check onmousedown event");
+	selenium.mouseDown(panelId);
+	String panelResultId = panelId + "_result";
+	AssertTextEquals(panelResultId, "Yes");
+    }
+
+    @Test
+    public void testOnMouseMoveEvent() throws Exception {
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_10";
+	writeStatus("Check onmousemove event");
+	selenium.mouseMove(panelId);
+	String panelResultId = panelId + "_result";
+	AssertTextEquals(panelResultId, "Yes");
+    }
+
+    @Test
+    public void testOnMouseOutEvent() throws Exception {
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_11";
+	writeStatus("Check onmouseout event");
+	selenium.mouseOut(panelId);
+	String panelResultId = panelId + "_result";
+	AssertTextEquals(panelResultId, "Yes");
+    }
+
+    @Test
+    public void testOnMouseOverEvent() throws Exception {
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_12";
+	writeStatus("Check onmouseover event");
+	selenium.mouseOver(panelId);
+	String panelResultId = panelId + "_result";
+	AssertTextEquals(panelResultId, "Yes");
+    }
+
+    @Test
+    public void testOnMouseUpEvent() throws Exception {
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_13";
+	writeStatus("Check onmouseup event");
+	selenium.mouseUp(panelId);
+	String panelResultId = panelId + "_result";
+	AssertTextEquals(panelResultId, "Yes");
+    }
+
+    @Test
+    public void testOnClickEvent() throws Exception {
+	String parentId = getParentId() + "form:";
+	String panelId = parentId + "panel_14";
+	writeStatus("Check onclick event");
+	selenium.click(panelId);
+	String panelResultId = panelId + "_result";
+	AssertTextEquals(panelResultId, "Yes");
+    }
+}


Property changes on: trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxOutputPanelTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Id Revision Date
Name: svn:eol-style
   + native




More information about the richfaces-svn-commits mailing list