Author: alevkovsky
Date: 2008-11-28 11:50:17 -0500 (Fri, 28 Nov 2008)
New Revision: 11444
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/EditorBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorCustomPluginsConfiguration.properties
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorFullConfiguration.properties
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editor.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editorAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/tesAjaxaAndBindingRerender.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConfigurationAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConverterAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testPluginsAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testRequiredAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testSkinAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testThemeAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testValidatorAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testWidthAndHeightAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/EditorTest.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/web.xml
Log:
Add selenium test for Editor
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/EditorBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/EditorBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/EditorBean.java 2008-11-28
16:50:17 UTC (rev 11444)
@@ -0,0 +1,311 @@
+/**
+ *
+ */
+package org.ajax4jsf.bean;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.validator.ValidatorException;
+
+import org.richfaces.component.UIEditor;
+
+/**
+ * @author Alexandr Levkovsky
+ *
+ */
+public class EditorBean {
+
+ private Object value = "Some value....";
+ private UIEditor editor;
+ private boolean rendered = true;
+ private String theme = "advanced";
+ private String skin = "richfaces";
+ private String language = "en";
+ private boolean readonly = false;
+ private String viewMode = "vision";
+ private int width = 600;
+ private int height = 600;
+ private boolean required = false;
+ private boolean invokeFlage = false;
+ private boolean convertToObjectFail = false;
+
+ public void reset() {
+ value = "Some value....";
+ rendered = true;
+ theme = "advanced";
+ skin = "richfaces";
+ language = "en";
+ readonly = false;
+ viewMode = "vision";
+ width = 600;
+ height = 600;
+ required = false;
+ invokeFlage = false;
+ convertToObjectFail = false;
+ }
+
+ public String changeTheme(){
+ if("advanced".equals(theme)){
+ theme = "simple";
+ }else{
+ theme = "advanced";
+ }
+ return null;
+ }
+
+ public String changeSkin(){
+ if("richfaces".equals(skin)){
+ skin = "o2k7";
+ }else{
+ skin = "richfaces";
+ }
+ return null;
+ }
+
+ public String changeSize(){
+ width = 650;
+ height = 650;
+ return null;
+ }
+
+ public String changeValue(){
+ setValue("Ajax value");
+ return null;
+ }
+
+ public String submit(){
+ invokeFlage = true;
+ convertToObjectFail = true;
+ return null;
+ }
+
+ public Converter getConvert() {
+ return new Converter() {
+ public Object getAsObject(FacesContext context,
+ UIComponent component, String newValue)
+ throws ConverterException {
+
+ if (convertToObjectFail){
+ throw new ConverterException(new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, "Converter error",
+ "Error while convert to Object"));
+ }else{
+ newValue = "Converter Value";
+ }
+
+ return newValue;
+ }
+
+ public String getAsString(FacesContext context,
+ UIComponent component, Object value)
+ throws ConverterException {
+ String result = (value == null) ? "" : value.toString();
+ return result;
+ }
+ };
+ }
+
+ public void validate(FacesContext context, UIComponent component,
+ Object value) throws ValidatorException {
+
+ if (value != null) {
+ throw new ValidatorException(new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, "Validation error",
+ "Incorrect input"));
+ }
+ }
+
+ /**
+ * @return the editor
+ */
+ public UIEditor getEditor() {
+ return editor;
+ }
+
+ /**
+ * @param editor the editor to set
+ */
+ public void setEditor(UIEditor editor) {
+ this.editor = editor;
+ }
+
+ /**
+ * @return the value
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * @return the value
+ */
+ public Object getValueFromBinding() {
+ return editor.getValue();
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the rendered
+ */
+ public boolean isRendered() {
+ return rendered;
+ }
+
+ /**
+ * @param rendered the rendered to set
+ */
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
+
+ /**
+ * @return the theme
+ */
+ public String getTheme() {
+ return theme;
+ }
+
+ /**
+ * @param theme the theme to set
+ */
+ public void setTheme(String theme) {
+ this.theme = theme;
+ }
+
+ /**
+ * @return the skin
+ */
+ public String getSkin() {
+ return skin;
+ }
+
+ /**
+ * @param skin the skin to set
+ */
+ public void setSkin(String skin) {
+ this.skin = skin;
+ }
+
+ /**
+ * @return the language
+ */
+ public String getLanguage() {
+ return language;
+ }
+
+ /**
+ * @param language the language to set
+ */
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ /**
+ * @return the readonly
+ */
+ public boolean isReadonly() {
+ return readonly;
+ }
+
+ /**
+ * @param readonly the readonly to set
+ */
+ public void setReadonly(boolean readonly) {
+ this.readonly = readonly;
+ }
+
+ /**
+ * @return the viewMode
+ */
+ public String getViewMode() {
+ return viewMode;
+ }
+
+ /**
+ * @param viewMode the viewMode to set
+ */
+ public void setViewMode(String viewMode) {
+ this.viewMode = viewMode;
+ }
+
+ /**
+ * @return the width
+ */
+ public int getWidth() {
+ return width;
+ }
+
+ /**
+ * @param width the width to set
+ */
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ /**
+ * @return the height
+ */
+ public int getHeight() {
+ return height;
+ }
+
+ /**
+ * @param height the height to set
+ */
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ /**
+ * @return the required
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * @param required the required to set
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ /**
+ * @return the invokeFlage
+ */
+ public boolean isInvokeFlage() {
+ return invokeFlage;
+ }
+
+ /**
+ * @param invokeFlage the invokeFlage to set
+ */
+ public void setInvokeFlage(boolean invokeFlage) {
+ this.invokeFlage = invokeFlage;
+ }
+
+ /**
+ * @return the convertToObjectFail
+ */
+ public boolean isConvertToObjectFail() {
+ return convertToObjectFail;
+ }
+
+ /**
+ * @param convertToObjectFail the convertToObjectFail to set
+ */
+ public void setConvertToObjectFail(boolean convertToObjectFail) {
+ this.convertToObjectFail = convertToObjectFail;
+ }
+
+
+}
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/EditorBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorCustomPluginsConfiguration.properties
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorCustomPluginsConfiguration.properties
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorCustomPluginsConfiguration.properties 2008-11-28
16:50:17 UTC (rev 11444)
@@ -0,0 +1 @@
+myemotions=/tiny-custom-plugins/myemotions/editor_plugin.js
\ No newline at end of file
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorCustomPluginsConfiguration.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorFullConfiguration.properties
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorFullConfiguration.properties
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorFullConfiguration.properties 2008-11-28
16:50:17 UTC (rev 11444)
@@ -0,0 +1,10 @@
+plugins =
"safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template"
+theme_advanced_buttons1 =
"save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect"
+theme_advanced_buttons2 =
"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor"
+theme_advanced_buttons3 =
"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen"
+theme_advanced_buttons4 =
"insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak"
+theme_advanced_buttons5 = "|,myemotions,|"
+theme_advanced_toolbar_location = "top"
+theme_advanced_toolbar_align = "left"
+theme_advanced_statusbar_location = "bottom"
+theme_advanced_resizing = true
\ No newline at end of file
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorFullConfiguration.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-11-28
16:40:05 UTC (rev 11443)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-11-28
16:50:17 UTC (rev 11444)
@@ -276,6 +276,11 @@
<managed-bean-name>effectBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.EffectBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>editorBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.EditorBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/ajaxInclude/step1.xhtml</from-view-id>
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/web.xml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/web.xml 2008-11-28
16:40:05 UTC (rev 11443)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/web.xml 2008-11-28
16:50:17 UTC (rev 11444)
@@ -105,7 +105,13 @@
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/NEKO/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/TIDY/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/NONE/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editor.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editor.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editorAutoTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editorAutoTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/tesAjaxaAndBindingRerender.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/tesAjaxaAndBindingRerender.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConfigurationAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConfigurationAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConverterAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConverterAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testPluginsAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testPluginsAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testRequiredAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testRequiredAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testSkinAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testSkinAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testThemeAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testThemeAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testValidatorAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testValidatorAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testWidthAndHeightAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testWidthAndHeightAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/EditorTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/EditorTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/EditorTest.java 2008-11-28
16:50:17 UTC (rev 11444)
@@ -0,0 +1,382 @@
+/**
+ *
+ */
+package org.richfaces.testng;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.AutoTester;
+import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * @author Alexandr Levkovsky
+ *
+ */
+public class EditorTest extends SeleniumTestBase {
+
+ private static String TEST_URL = "pages/editor/editor.xhtml";
+ private static String AUTO_TEST_URL = "pages/editor/editorAutoTest.xhtml";
+ private static String THEME_TEST_URL =
"pages/editor/testThemeAttribute.xhtml";
+ private static String SKIN_TEST_URL = "pages/editor/testSkinAttribute.xhtml";
+ private static String REQUIRED_TEST_URL =
"pages/editor/testRequiredAttribute.xhtml";
+ private static String WIDTH_HEIGHT_TEST_URL =
"pages/editor/testWidthAndHeightAttribute.xhtml";
+ private static String PLUGINS_TEST_URL =
"pages/editor/testPluginsAttribute.xhtml";
+ private static String CONFIGURATION_AND_FPARAMS_TEST_URL =
"pages/editor/testConfigurationAttribute.xhtml";
+ private static String VALIDATOR_TEST_URL =
"pages/editor/testValidatorAttribute.xhtml";
+ private static String CONVERTER_TEST_URL =
"pages/editor/testConverterAttribute.xhtml";
+ private static String AJAX_TEST_URL =
"pages/editor/tesAjaxaAndBindingRerender.xhtml";
+
+ private static String FORM_ID = "formId:";
+ private static String EDITOR_DIV_ID = FORM_ID + "editorId";
+ private static String EDITOR_TEXAREA_DIV_ID = FORM_ID + "editorIdTextArea";
+ private static String EDITOR_TABLE_ID = EDITOR_TEXAREA_DIV_ID + "_tbl";
+ private static String EDITOR_IFRAME_ID = EDITOR_TEXAREA_DIV_ID + "_ifr";
+ private static String EDITOR_HMESSAGE_ID = FORM_ID + "editorMessageId";
+
+ private static String XPATH_ADVANCED_THEME_STYLES =
"//link[contains(@href,'themes/advanced')]";
+ private static String XPATH_SIMPLE_THEME_STYLES =
"//link[contains(@href,'themes/simple')]";
+
+ private static String XPATH_O2K7_SKIN_STYLES =
"//link[contains(@href,'skins/o2k7')]";
+ private static String XPATH_RICHFACES_SKIN_STYLES =
"//link[contains(@href,'skins/richfaces')]";
+
+ private static String ACTION_BUTTON_ID = FORM_ID + "submitId";
+ private static String EDITOR_VALUE_OUTPUT_ID = FORM_ID + "editorValueId";
+ private static String EDITOR_VALUE_OUTPUT_ID2 = FORM_ID + "actualValueId";
+
+ private static String REQUIRED_HMESSAGE = "Value is required";
+
+ private static String CONFIGURATION_NAME = "editorFullConfiguration";
+ private static String FPARAM_NAME = "paramName";
+ private static String FPARAM_VALUE = "paramValue";
+
+ private static List<String> PLUGINS = new ArrayList<String>();
+ static {
+ PLUGINS.add("Spellchecker");
+ PLUGINS.add("PageBreak");
+ PLUGINS.add("Style");
+ PLUGINS.add("Layer");
+ PLUGINS.add("Tables");
+ PLUGINS.add("Save");
+ PLUGINS.add("Advanced HR");
+ PLUGINS.add("Advanced image");
+ PLUGINS.add("Advanced link");
+ PLUGINS.add("Emotions");
+ PLUGINS.add("IESpell (IE Only)");
+ PLUGINS.add("InlinePopups");
+ PLUGINS.add("Insert date/time");
+ PLUGINS.add("Preview");
+ PLUGINS.add("Media");
+ PLUGINS.add("Search/Replace");
+ PLUGINS.add("Print");
+ PLUGINS.add("Contextmenu");
+ PLUGINS.add("Paste text/word");
+ PLUGINS.add("Directionality");
+ PLUGINS.add("Fullscreen");
+ PLUGINS.add("Non editable elements");
+ PLUGINS.add("Visual characters");
+ PLUGINS.add("Nonbreaking space");
+ PLUGINS.add("XHTML Xtras Plugin");
+ PLUGINS.add("Template plugin");
+ };
+
+ static Map<String, String> STYLE_ATTR;
+ static String[] CLASSES = new String[] { "myClass" };
+
+ static {
+ STYLE_ATTR = new HashMap<String, String>();
+ STYLE_ATTR.put("width", "100%");
+ STYLE_ATTR.put("color", "blue");
+ }
+
+ static final String RESET_METHOD_ME = "#{editorBean.reset}";
+
+ @Test
+ public void testRenderedAttribute(Template template) {
+ AutoTester autoTester = getAutoTester(this);
+ autoTester.renderPage(template, RESET_METHOD_ME);
+ autoTester.testRendered();
+ }
+
+ @Test
+ public void testAutoStyleAndClassesAttributes(Template template) {
+ AutoTester autoTester = getAutoTester(this);
+ autoTester.renderPage(template, RESET_METHOD_ME);
+ autoTester.testStyleAndClasses(CLASSES, STYLE_ATTR);
+ }
+
+ @Test
+ public void testRequiredAndRequiredMessageAttributes(Template template) {
+ renderPage(REQUIRED_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+ String messageId = getParentId() + EDITOR_HMESSAGE_ID;
+
+ AssertNotPresent(messageId);
+ //setValueInEditor("");
+ clickTestButton();
+
+ AssertPresent(messageId);
+ String message = getTextById(messageId);
+ Assert.assertEquals(message, REQUIRED_HMESSAGE,
+ "Required message not correct");
+ //String checked = selenium.getAttribute(XPATH_CHECKBOX_VALUE);
+
+ setValueInEditor("<span> Some value </span>");
+
+ clickTestButton();
+
+ AssertNotPresent(messageId);
+ //checked = selenium.getAttribute(XPATH_CHECKBOX_VALUE);
+
+ }
+
+ @Test
+ public void testValidatorAttribute(Template template) {
+ renderPage(VALIDATOR_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+ String messageId = getParentId() + EDITOR_HMESSAGE_ID;
+
+ AssertNotPresent(messageId);
+ clickTestButton();
+
+ AssertPresent(messageId);
+ String message = getTextById(messageId);
+ Assert.assertEquals(message, "Incorrect input",
+ "Validator message not correct");
+ }
+
+ @Test
+ public void testConvertorAttribute(Template template) {
+ renderPage(CONVERTER_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+ String messageId = getParentId() + EDITOR_HMESSAGE_ID;
+
+ AssertNotPresent(messageId);
+
+ clickTestButton();
+
+ AssertNotPresent(messageId);
+ String value = getTextById(getParentId() + EDITOR_VALUE_OUTPUT_ID);
+ Assert.assertEquals(value, "Converter Value", "Value is not
valid");
+
+ clickTestButton();
+
+ AssertPresent(messageId);
+ String message = getTextById(messageId);
+ Assert.assertEquals(message, "Error while convert to Object",
+ "Converter message not correct");
+ }
+
+ @Test
+ public void testAjaxRerenderingAndBinding(Template template) {
+ renderPage(AJAX_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+ String valueOutputId = getParentId() + EDITOR_VALUE_OUTPUT_ID;
+ String actualOutputId = getParentId() + EDITOR_VALUE_OUTPUT_ID2;
+
+ AssertTextEquals(valueOutputId, "Some value....",
+ "Editor Value is invalid");
+
+ clickAjaxCommandAndWait(getParentId() + ACTION_BUTTON_ID);
+ checkJSError();
+
+ AssertTextEquals(valueOutputId, "Some value....",
+ "This output should have old Value");
+ AssertTextEquals(actualOutputId, "Ajax value",
+ "This output should have new rerendered Value");
+ }
+
+ @Test
+ public void testThemeAttribute(Template template) {
+ renderPage(THEME_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+
+ int advancedThemeStylesCount = selenium.getXpathCount(
+ XPATH_ADVANCED_THEME_STYLES).intValue();
+
+ if (advancedThemeStylesCount < 1) {
+ Assert.fail("Advanced theme styles in not loaded");
+ }
+
+ clickTestButton();
+ int simpleThemeStylesCount = selenium.getXpathCount(
+ XPATH_SIMPLE_THEME_STYLES).intValue();
+
+ if (simpleThemeStylesCount < 1) {
+ Assert.fail("Simple theme styles in not loaded");
+ }
+
+ }
+
+ @Test
+ public void testSkinAttribute(Template template) {
+ renderPage(SKIN_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+
+ int richfacesSkinStylesCount = selenium.getXpathCount(
+ XPATH_RICHFACES_SKIN_STYLES).intValue();
+
+ if (richfacesSkinStylesCount < 1) {
+ Assert.fail("richfaces skins styles in not loaded");
+ }
+
+ clickTestButton();
+
+ int o2k7SkinStylesCount = selenium
+ .getXpathCount(XPATH_O2K7_SKIN_STYLES).intValue();
+
+ if (o2k7SkinStylesCount < 1) {
+ Assert.fail("o2k7 skins styles in not loaded");
+ }
+ }
+
+ @Test
+ public void testWidthAndHeightAttributes(Template template) {
+ renderPage(WIDTH_HEIGHT_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+
+ String editorTableId = getParentId() + EDITOR_TABLE_ID;
+ String width = getStyleAttributeString(editorTableId, "width");
+ String height = getStyleAttributeString(editorTableId, "height");
+ Assert.assertEquals(width, "600px", "width is invalid");
+ Assert.assertEquals(height, "600px", "height is invalid");
+
+ clickTestButton();
+
+ width = getStyleAttributeString(editorTableId, "width");
+ height = getStyleAttributeString(editorTableId, "height");
+ Assert.assertEquals(width, "650px", "width is invalid");
+ Assert.assertEquals(height, "650px", "height is invalid");
+ }
+
+ @Test
+ public void testPlugingAttribute(Template template) {
+ renderPage(PLUGINS_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+
+ clickById(getParentId() + ACTION_BUTTON_ID);
+ String text = getTextById("pluginsId");
+ if (text == null || text.length() == 0) {
+ Assert.fail("can't get loaded plugins");
+ }
+ String[] plugins = text.split(",");
+ if (plugins.length != PLUGINS.size()) {
+ Assert.fail("count of loaded plugins is not equlas required");
+ }
+ for (String plugin : plugins) {
+ if (!PLUGINS.contains(plugin)) {
+ Assert.fail("Invalid plugin was loaded: " + plugin);
+ }
+ }
+
+ }
+
+ @Test
+ public void testConfigurationAttribute(Template template) {
+ renderPage(CONFIGURATION_AND_FPARAMS_TEST_URL, template,
+ RESET_METHOD_ME);
+ assertEditorPresent();
+
+ Properties properties = loadProperties(CONFIGURATION_NAME);
+
+ clickById(getParentId() + ACTION_BUTTON_ID);
+ String text = getTextById("parametersId");
+
+ if (text == null || text.length() == 0) {
+ Assert.fail("can't get loaded parameters");
+ }
+ String[] parameters = text.split(";;");
+ List<String> paramsList = Arrays.asList(parameters);
+
+ for (Object key : properties.keySet()) {
+ String keyString = key.toString();
+ String valueString = properties.get(key).toString();
+ if (valueString.indexOf("\"") != -1) {
+ valueString = valueString.replaceAll("\"", "");
+ }
+ String param = keyString + ':' + valueString;
+ if (!paramsList.contains(param)) {
+ Assert.fail("Configuration parameters not contains " + param);
+ }
+ }
+
+ }
+
+ @Test
+ public void testFPramsPassingToEditor(Template template) {
+ renderPage(CONFIGURATION_AND_FPARAMS_TEST_URL, template,
+ RESET_METHOD_ME);
+ assertEditorPresent();
+
+ clickById(getParentId() + ACTION_BUTTON_ID);
+ String text = getTextById("parametersId");
+
+ if (text == null || text.length() == 0) {
+ Assert.fail("can't get loaded parameters");
+ }
+ String[] parameters = text.split(";;");
+ List<String> paramsList = Arrays.asList(parameters);
+
+ String param = FPARAM_NAME + ':' + FPARAM_VALUE;
+ if (!paramsList.contains(param)) {
+ Assert.fail("f:param not passed to configuration");
+ }
+
+ }
+
+ private void assertEditorPresent() {
+ AssertPresent(getParentId() + EDITOR_DIV_ID);
+ AssertPresent(getParentId() + EDITOR_TEXAREA_DIV_ID);
+ AssertPresent(getParentId() + EDITOR_IFRAME_ID);
+ }
+
+ private void clickTestButton() {
+ clickCommandAndWait(getParentId() + ACTION_BUTTON_ID);
+ }
+
+ private void setValueInEditor(String value) {
+ String script = "tinyMCE.activeEditor.setContent(" + value + ");";
+ runScript(script, true);
+ }
+
+ @Override
+ public String getAutoTestUrl() {
+ return AUTO_TEST_URL;
+ }
+
+ @Override
+ public String getTestUrl() {
+ return TEST_URL;
+ }
+
+ /**
+ * Method to load properties from property file
+ *
+ * @param name - properties file name
+ * @return Properties
+ */
+ private Properties loadProperties(String name) {
+ Properties properties = new Properties();
+
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ InputStream is = loader.getResourceAsStream(name + ".properties");
+ if (is == null) {
+ Assert.fail("Can't load propertioes file for test");
+ }
+ try {
+ properties.load(is);
+ } catch (IOException e) {
+ Assert.fail("Can't load propertioes file for test");
+ }
+ return properties;
+ }
+}
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/EditorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native