Author: dsvyatobatsko
Date: 2008-05-16 11:48:06 -0400 (Fri, 16 May 2008)
New Revision: 8619
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/InplaceSelectTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/inplaceSelect/
trunk/test-applications/seleniumTest/src/main/webapp/pages/inplaceSelect/inplaceSelectTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/InplaceSelectTest.java
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
Log:
InplaceSelect component test
Added:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/InplaceSelectTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/InplaceSelectTestBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/InplaceSelectTestBean.java 2008-05-16
15:48:06 UTC (rev 8619)
@@ -0,0 +1,51 @@
+package org.ajax4jsf;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.faces.model.SelectItem;
+
+public class InplaceSelectTestBean {
+
+ private List<SelectItem> treeItems = new ArrayList<SelectItem>();
+
+ private List<String> treeNames = Arrays.asList("Pine",
"Birch", "Aspen", "Spruce", "Oak",
"Maple", "Ash", "Lime");
+
+ private String tree = "";
+
+ /**
+ * Gets value of tree field.
+ *
+ * @return value of tree field
+ */
+ public String getTree() {
+ return tree;
+ }
+
+ /**
+ * Set a new value for tree field.
+ *
+ * @param tree
+ * a new value for tree field
+ */
+ public void setTree(String tree) {
+ this.tree = tree;
+ }
+
+ public InplaceSelectTestBean() {
+ for (String treeName : treeNames) {
+ treeItems.add(new SelectItem(treeName, treeName));
+ }
+ }
+
+ /**
+ * Gets value of treeItems field.
+ *
+ * @return value of treeItems field
+ */
+ public List<SelectItem> getTreeItems() {
+ return treeItems;
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/InplaceSelectTestBean.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-05-16
15:35:48 UTC (rev 8618)
+++
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-05-16
15:48:06 UTC (rev 8619)
@@ -91,6 +91,11 @@
<managed-bean-name>pickListBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.PickListTestBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>inplaceSelectBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.InplaceSelectTestBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>orderingListBean</managed-bean-name>
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/inplaceSelect/inplaceSelectTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/src/main/webapp/pages/inplaceSelect/inplaceSelectTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/InplaceSelectTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/InplaceSelectTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/InplaceSelectTest.java 2008-05-16
15:48:06 UTC (rev 8619)
@@ -0,0 +1,115 @@
+package org.richfaces;
+
+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;
+
+public class InplaceSelectTest extends SeleniumTestBase {
+
+ public InplaceSelectTest() {
+ 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 testInplaceSelectComponent() throws Exception {
+ _testInplaceSelectComponent(Templates.SIMPLE);
+ _testInplaceSelectComponent(Templates.DATATABLE);
+ }
+
+ private void _testInplaceSelectComponent(Templates template) {
+ renderPage("/faces/pages/inplaceSelect/inplaceSelectTest.xhtml",
template);
+
+ String parentId = getParentId() + "_form:";
+ String inplaceSelectId = parentId + "inplaceSelect";
+ String okButton = parentId + "inplaceSelect" + "ok";
+ //String inplaceTmpValueElemId = parentId + "inplaceSelect" +
"inplaceTmpValue";
+ String cancelButton = parentId + "inplaceSelect" + "cancel";
+ String popupId = "list" + inplaceSelectId;
+
+ writeStatus("click the component");
+
+ clickById(inplaceSelectId);
+ Assert.assertFalse(isVisibleById(popupId), "Component pop-up should not show
up on solitary click");
+
+ writeStatus("double click the component");
+
+ selenium.doubleClick(inplaceSelectId);
+ Assert.assertTrue(isVisibleById(popupId), "Component pop-up should show up
on double click");
+
+ writeStatus("Check that controls buttons are present");
+
+ Assert.assertTrue(isPresentById(okButton));
+ Assert.assertTrue(isPresentById(cancelButton));
+
+ writeStatus("Select second element"); //Birch
+
+
selenium.mouseMove("dom=selenium.browserbot.getCurrentWindow().$('list" +
inplaceSelectId
+ + "').down('span', 1)");
+ selenium.fireEvent(okButton, "mousedown");
+
+ writeStatus("Check that a new element is selected");
+
+ Assert.assertEquals(getValue(inplaceSelectId), "Birch");
+
+ writeStatus("Select another element"); // Aspen
+
+ selenium.doubleClick(inplaceSelectId);
+
selenium.mouseMove("dom=selenium.browserbot.getCurrentWindow().$('list" +
inplaceSelectId
+ + "').down('span', 2)");
+ selenium.fireEvent(cancelButton, "mousedown");
+
+ writeStatus("Cancel selected value.");
+ Assert.assertEquals(getValue(inplaceSelectId), "Birch", "A value
has not to be changed");
+
+ writeStatus("Verify javascript event triggering");
+
+ runScript("theLatestEvent='undefined'");
+
+ writeStatus("Double click the component");
+ selenium.doubleClick(inplaceSelectId);
+
+ Assert.assertEquals(runScript("theLatestEvent"),
"editactivated", "editactivated event has not been triggered");
+
+ writeStatus("Stop editing with ok");
+ selenium.fireEvent(okButton, "mousedown");
+ Assert.assertEquals(runScript("theLatestEvent"),
"viewactivated", "viewactivated event has not been triggered");
+
+// viewactivated event is not fired ... almost sure bug
+// writeStatus("Stop editing with cancel");
+// selenium.fireEvent(cancelButton, "mousedown");
+// Assert.assertEquals(runScript("theLatestEvent"),
"viewactivated", "viewactivated event has not been triggered");
+
+ }
+
+ /**
+ * Gets component value.
+ * Note: JavaScript component API getValue() doesn't exit
+ * @param clientId
+ * @return
+ */
+ private String getValue(String clientId) {
+ return runScript("$('" + clientId +
"inplaceValue').value;");
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/InplaceSelectTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Show replies by date