Author: vmolotkov
Date: 2008-10-28 09:28:49 -0400 (Tue, 28 Oct 2008)
New Revision: 10939
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/includes/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/includes/testBody.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/testRequiredAttributes.xhtml
Removed:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/ajaxSupport.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InplaceInputTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InplaceInputTest.java
trunk/test-applications/seleniumTest/richfaces/src/test/testng/win/local_testng.xml
Log:
tests for inplaceinput
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InplaceInputTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InplaceInputTestBean.java 2008-10-28
12:55:05 UTC (rev 10938)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InplaceInputTestBean.java 2008-10-28
13:28:49 UTC (rev 10939)
@@ -2,8 +2,12 @@
public class InplaceInputTestBean {
+ public final static class Messages {
+ public final static String ACTION_CALLED = "action called";
+ }
+
private String text ="";
-
+
/**
* Gets value of text field.
* @return value of text field
@@ -20,5 +24,7 @@
this.text = text;
}
-
+ public void action() {
+ setText(InplaceInputTestBean.Messages.ACTION_CALLED);
+ }
}
Deleted:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/ajaxSupport.xhtml
===================================================================
(Binary files differ)
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/includes/testBody.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/includes/testBody.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/includes/testBody.xhtml 2008-10-28
13:28:49 UTC (rev 10939)
@@ -0,0 +1,20 @@
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+ <h:form id="_form">
+ <rich:inplaceInput id="ii_#{test_prefix}"
required="#{required}"
+ requiredMessage="#{requiredMessage}"
+ value="#{value}"/>
+  
+ <h:commandButton id="bn_#{test_prefix}"
action="#{inplaceInputBean.action}"
value="Submit"></h:commandButton>
+ <div>
+ value: <h:outputText style="font-weight: bold; border: 1px solid green"
value="#{inplaceInputBean.text}" id="data1_#{test_prefix}"/>
+ </div>
+ <div id="text_#{test_prefix}">
+ text: <h:message for="ii_#{test_prefix}"/><h:outputText
value="#{inplaceInputBean.text}"></h:outputText>
+ </div>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/testRequiredAttributes.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/testRequiredAttributes.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/testRequiredAttributes.xhtml 2008-10-28
13:28:49 UTC (rev 10939)
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+ template="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testRequiredAttributes</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="tra"/>
+ <ui:param name="required" value="true"/>
+ <ui:param name="value" value=""/>
+ <ui:param name="requiredMessage" value="requiredMsg" />
+ </ui:include>
+ </ui:define>
+</ui:composition>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InplaceInputTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InplaceInputTest.java 2008-10-28
12:55:05 UTC (rev 10938)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InplaceInputTest.java 2008-10-28
13:28:49 UTC (rev 10939)
@@ -2,6 +2,7 @@
import org.ajax4jsf.template.Template;
import org.richfaces.SeleniumTestBase;
+import org.richfaces.testng.util.CommonUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -20,126 +21,188 @@
private final static String EVENT_TEST_RESULT_FAILED_TEXT = "No";
private final static String EVENT_TEST_RESULT_PASSED_TEXT = "Passed";
+
+ private static final String INPLACE_INPUT_PAGE = "inplaceInputTest.xhtml";
+
+ private static final String REQUIRED_ATTRIBUTES_PAGE =
"testRequiredAttributes.xhtml";
+
+ private static final String REQUIRED_ATTRIBUTES_ID_PREFIX = "_tra";
+
+ private String testUrl;
+
+ private String formId;
+
+ private String buttonId;
+
+ private String inplaceInputId;
+
+ private String messageId;
+// @Test
+// public void testInplaceInputComponentLayout(Template template) {
+// setTestUrl(INPLACE_INPUT_PAGE);
+// renderPage(template);
+// writeStatus("Check component layout");
+//
+// String inplaceInputS = getParentId() + "_form:" +
INPLACE_INPUT_SIMPLE;
+// String inplaceInputD = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED;
+//
+// Assert.assertTrue(isPresentById(inplaceInputS));
+// int count = selenium.getXpathCount("//*[@id='" + inplaceInputS +
"' and (name()='span' or name()='SPAN')]").intValue();
+// Assert.assertTrue(count == 1, "InplaceInput[" + inplaceInputS +
"] has layout=inline(default) and should be rendered as 'span'
element");
+//
+// Assert.assertTrue(isPresentById(inplaceInputD));
+// count = selenium.getXpathCount("//*[@id='" + inplaceInputD +
"' and (name()='DIV' or name()='div')]").intValue();
+// Assert.assertTrue(count == 1, "InplaceInput [" + inplaceInputD +
"] has layout=block and should be rendered as 'div' element");
+//
+// }
+//
+// @Test
+// public void testInplaceInputClientAPI(Template template) {
+// setTestUrl(INPLACE_INPUT_PAGE);
+// renderPage(template);
+// writeStatus("Check component client API");
+// }
+//
+// @Test
+// public void testInplaceInputEvents(Template template) {
+// setTestUrl(INPLACE_INPUT_PAGE);
+// renderPage(template);
+//
+// writeStatus("Check component event triggering");
+//
+// String inplaceInputS = getParentId() + "_form:" +
INPLACE_INPUT_SIMPLE;
+// String inplaceInputD = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED;
+// String inplaceInputDOk = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED_OK;
+// String inplaceInputDCancel = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED_CANCEL;
+//
+// writeStatus("Click first component being tested");
+//
+// clickById(inplaceInputS);
+// AssertTextEquals(inplaceInputS + "_edit",
EVENT_TEST_RESULT_PASSED_TEXT, "oneditactivated event is not fired");
+//
+// writeStatus("Stop editing first component being tested");
+//
+// String inplaceInputSInput = inplaceInputS + INPLACE_INPUT_FIELD_POSTFIX;
+// selenium.fireEvent(inplaceInputSInput, "blur");
+//
+// AssertTextEquals(inplaceInputS + "_view",
EVENT_TEST_RESULT_PASSED_TEXT, "onviewactivated event is not fired");
+//
+// writeStatus("Double-click second component being tested");
+//
+// selenium.doubleClick(inplaceInputD);
+// AssertTextEquals(inplaceInputD + "_edit",
EVENT_TEST_RESULT_PASSED_TEXT, "oneditactivated event is not fired");
+// type(inplaceInputSInput, "Hello");
+//
+// writeStatus("Stop editing second component being tested");
+//
+// selenium.mouseDown(inplaceInputDOk);
+//
+// AssertTextEquals(inplaceInputD + "_view",
EVENT_TEST_RESULT_PASSED_TEXT, "onviewactivated event is not fired");
+// }
+//
+// @Test
+// public void testInplaceInputKeyAttributes(Template template) {
+// setTestUrl(INPLACE_INPUT_PAGE);
+// renderPage(template);
+//
+// String inplaceInputS = getParentId() + "_form:" +
INPLACE_INPUT_SIMPLE;
+// String inplaceInputD = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED;
+//
+// String inplaceInputSInput = inplaceInputS + INPLACE_INPUT_FIELD_POSTFIX;
+// String inplaceInputDInput = inplaceInputD + INPLACE_INPUT_FIELD_POSTFIX;
+//
+// writeStatus("Check component's key attributes");
+//
+// writeStatus("test 'editEvent' attribute");
+//
+// writeStatus("The first component must change your state by single clicking
only");
+// clickById(inplaceInputS);
+// AssertVisible(inplaceInputSInput);
+//
+// writeStatus("The second component must change your state by double
clicking only");
+// selenium.doubleClick(inplaceInputD);
+// AssertVisible(inplaceInputDInput);
+// }
+//
+// @Test
+// public void testInplaceInputComponentCore(Template template) {
+// setTestUrl(INPLACE_INPUT_PAGE);
+// renderPage(template);
+//
+// String inplaceInputD = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED;
+// String inplaceInputDInput = inplaceInputD + INPLACE_INPUT_FIELD_POSTFIX;
+// String inplaceInputDOk = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED_OK;
+// String inplaceInputDCancel = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED_CANCEL;
+//
+// writeStatus("Check component's core functionality");
+//
+// writeStatus("Double-click the second component and type an initial
text");
+// selenium.doubleClick(inplaceInputD);
+// type(inplaceInputDInput, "Sun");
+//
+// writeStatus("Stop editing with ok. The input has to be saved");
+// selenium.mouseDown(inplaceInputDOk);
+// String sun = invokeFromComponent(inplaceInputD, "getValue", null);
+// Assert.assertEquals(sun, "Sun", "An inputted text has not been
saved with ok");
+// //AssertTextEquals(inplaceInputD, "Sun", "An inputted text has
not been saved with ok");
+//
+// writeStatus("Double-click the second component again and type a new
text");
+// selenium.doubleClick(inplaceInputD);
+// type(inplaceInputDInput, "Moon");
+//
+// writeStatus("Stop editing with cancel. The input has not to be
saved");
+// selenium.mouseDown(inplaceInputDCancel);
+//
+// sun = invokeFromComponent(inplaceInputD, "getValue", null);
+// Assert.assertEquals(sun, "Sun", "An inputted text has not to be
saved with cancel");
+// //AssertTextEquals(inplaceInputD, "Sun", "An inputted text has
not to be saved with cancel");
+//
+// }
+
+ /**
+ * 'required' and 'requiredMessage' attributes work
+ *
+ * @param template - current template
+ */
@Test
- public void testInplaceInputComponentLayout(Template template) {
- renderPage(template);
- writeStatus("Check component layout");
-
- String inplaceInputS = getParentId() + "_form:" +
INPLACE_INPUT_SIMPLE;
- String inplaceInputD = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED;
-
- Assert.assertTrue(isPresentById(inplaceInputS));
- int count = selenium.getXpathCount("//*[@id='" + inplaceInputS +
"' and (name()='span' or name()='SPAN')]").intValue();
- Assert.assertTrue(count == 1, "InplaceInput[" + inplaceInputS + "]
has layout=inline(default) and should be rendered as 'span' element");
-
- Assert.assertTrue(isPresentById(inplaceInputD));
- count = selenium.getXpathCount("//*[@id='" + inplaceInputD +
"' and (name()='DIV' or name()='div')]").intValue();
- Assert.assertTrue(count == 1, "InplaceInput [" + inplaceInputD +
"] has layout=block and should be rendered as 'div' element");
-
+ public void testRequiredAttributes(Template template) {
+ setTestUrl(REQUIRED_ATTRIBUTES_PAGE);
+ init(template);
+
+ selenium.click("id=" + buttonId + REQUIRED_ATTRIBUTES_ID_PREFIX);
+ waitForPageToLoad();
+ checkMessage(messageId + REQUIRED_ATTRIBUTES_ID_PREFIX, "requiredMsg",
CommonUtils.getSuccessfulTestMessage(inplaceInputId),
CommonUtils.getFailedTestMessage(inplaceInputId));
}
- @Test
- public void testInplaceInputClientAPI(Template template) {
- renderPage(template);
- writeStatus("Check component client API");
+ private void checkMessage(String elementId, String expectedValue, String okMsg,
String errMsg) {
+ String currentValue = getTextById(elementId);
+ if (("text:" + expectedValue).equals(currentValue)) {
+ writeStatus(okMsg, true);
+ } else {
+ writeStatus(errMsg, true);
+ Assert.fail(errMsg);
+ }
}
-
- @Test
- public void testInplaceInputEvents(Template template) {
- renderPage(template);
-
- writeStatus("Check component event triggering");
-
- String inplaceInputS = getParentId() + "_form:" +
INPLACE_INPUT_SIMPLE;
- String inplaceInputD = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED;
- String inplaceInputDOk = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED_OK;
- String inplaceInputDCancel = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED_CANCEL;
-
- writeStatus("Click first component being tested");
-
- clickById(inplaceInputS);
- AssertTextEquals(inplaceInputS + "_edit",
EVENT_TEST_RESULT_PASSED_TEXT, "oneditactivated event is not fired");
-
- writeStatus("Stop editing first component being tested");
-
- String inplaceInputSInput = inplaceInputS + INPLACE_INPUT_FIELD_POSTFIX;
- selenium.fireEvent(inplaceInputSInput, "blur");
-
- AssertTextEquals(inplaceInputS + "_view",
EVENT_TEST_RESULT_PASSED_TEXT, "onviewactivated event is not fired");
-
- writeStatus("Double-click second component being tested");
-
- selenium.doubleClick(inplaceInputD);
- AssertTextEquals(inplaceInputD + "_edit",
EVENT_TEST_RESULT_PASSED_TEXT, "oneditactivated event is not fired");
- type(inplaceInputSInput, "Hello");
-
- writeStatus("Stop editing second component being tested");
-
- selenium.mouseDown(inplaceInputDOk);
-
- AssertTextEquals(inplaceInputD + "_view",
EVENT_TEST_RESULT_PASSED_TEXT, "onviewactivated event is not fired");
+
+ private void init(Template template) {
+ renderPage(template);
+ initIds();
}
-
- @Test
- public void testInplaceInputKeyAttributes(Template template) {
- renderPage(template);
-
- String inplaceInputS = getParentId() + "_form:" +
INPLACE_INPUT_SIMPLE;
- String inplaceInputD = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED;
-
- String inplaceInputSInput = inplaceInputS + INPLACE_INPUT_FIELD_POSTFIX;
- String inplaceInputDInput = inplaceInputD + INPLACE_INPUT_FIELD_POSTFIX;
-
- writeStatus("Check component's key attributes");
-
- writeStatus("test 'editEvent' attribute");
-
- writeStatus("The first component must change your state by single clicking
only");
- clickById(inplaceInputS);
- AssertVisible(inplaceInputSInput);
-
- writeStatus("The second component must change your state by double clicking
only");
- selenium.doubleClick(inplaceInputD);
- AssertVisible(inplaceInputDInput);
+
+ private void initIds() {
+ formId = getParentId() + "_form:";
+ buttonId = formId + "bn";
+ inplaceInputId = formId + "ii";
+ messageId = "text";
}
-
- @Test
- public void testInplaceInputComponentCore(Template template) {
- renderPage(template);
-
- String inplaceInputD = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED;
- String inplaceInputDInput = inplaceInputD + INPLACE_INPUT_FIELD_POSTFIX;
- String inplaceInputDOk = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED_OK;
- String inplaceInputDCancel = getParentId() + "_form:" +
INPLACE_INPUT_DECORATED_CANCEL;
-
- writeStatus("Check component's core functionality");
-
- writeStatus("Double-click the second component and type an initial
text");
- selenium.doubleClick(inplaceInputD);
- type(inplaceInputDInput, "Sun");
-
- writeStatus("Stop editing with ok. The input has to be saved");
- selenium.mouseDown(inplaceInputDOk);
- String sun = invokeFromComponent(inplaceInputD, "getValue", null);
- Assert.assertEquals(sun, "Sun", "An inputted text has not been
saved with ok");
- //AssertTextEquals(inplaceInputD, "Sun", "An inputted text has not
been saved with ok");
-
- writeStatus("Double-click the second component again and type a new
text");
- selenium.doubleClick(inplaceInputD);
- type(inplaceInputDInput, "Moon");
-
- writeStatus("Stop editing with cancel. The input has not to be
saved");
- selenium.mouseDown(inplaceInputDCancel);
-
- sun = invokeFromComponent(inplaceInputD, "getValue", null);
- Assert.assertEquals(sun, "Sun", "An inputted text has not to be
saved with cancel");
- //AssertTextEquals(inplaceInputD, "Sun", "An inputted text has not
to be saved with cancel");
-
- }
-
+
@Override
public String getTestUrl() {
- return "pages/inplaceInput/inplaceInputTest.xhtml";
+ return testUrl;
}
+
+ public void setTestUrl(String testUrl) {
+ this.testUrl = "pages/inplaceInput/" + testUrl;
+ }
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/testng/win/local_testng.xml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/testng/win/local_testng.xml 2008-10-28
12:55:05 UTC (rev 10938)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/testng/win/local_testng.xml 2008-10-28
13:28:49 UTC (rev 10939)
@@ -7,7 +7,7 @@
<parameter name="loadScriptStrategy" value="DEFAULT" />
<parameter name="filterPrefix" value="/faces/NEKO/" />
<classes>
- <class name="org.richfaces.testng.AjaxSupportTest" />
+ <class name="org.richfaces.testng.InplaceInputTest" />
</classes>
</test>
</suite>