Author: jjamrich
Date: 2011-08-08 18:52:43 -0400 (Mon, 08 Aug 2011)
New Revision: 22606
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/RichEditorComponentAttribute.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/TestRichEditor.java
Log:
Fix rich:editor tests implementation for width, height, readonly and onInit attribute
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/RichEditorComponentAttribute.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/RichEditorComponentAttribute.java 2011-08-08
11:49:24 UTC (rev 22605)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/RichEditorComponentAttribute.java 2011-08-08
22:52:43 UTC (rev 22606)
@@ -67,6 +67,10 @@
public void setToolbar(String toolbar) {
setProperty("toolbar", toolbar);
}
+
+ public void setTitle(String title) {
+ setProperty("title", title);
+ }
public void setValue(String value) {
setProperty("value", value);
@@ -75,5 +79,9 @@
public void setWidth(String width) {
setProperty("width", width);
}
+
+ public void setOnInit(String onInit) {
+ setProperty("oninit", onInit);
+ }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/TestRichEditor.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/TestRichEditor.java 2011-08-08
11:49:24 UTC (rev 22605)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richEditor/TestRichEditor.java 2011-08-08
22:52:43 UTC (rev 22606)
@@ -4,6 +4,7 @@
package org.richfaces.tests.metamer.ftest.richEditor;
import static java.text.MessageFormat.format;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -15,8 +16,10 @@
import org.jboss.test.selenium.encapsulated.FrameLocator;
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.AttributeLocator;
+import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.utils.URLUtils;
+import org.jboss.test.selenium.waiting.EventFiredCondition;
import org.jboss.test.selenium.waiting.selenium.SeleniumCondition;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.slf4j.Logger;
@@ -47,6 +50,8 @@
private JQueryLocator editorToolbarContainer = jq("td.cke_toolgroup");
+ private Attribute styleAttribute = new Attribute("style");
+
public enum toolbarGroup {
FILE_SAVE(7),
CLIPBOARD(14),
@@ -137,7 +142,15 @@
@Test
public void testHeight() {
- // TODO jjamrich 2011-08-03: implement test when fixed problem with height
+
+ String height = "250px";
+ attributes.setHeight(height);
+
+ // height style is set for area used as editor canvas (not for whole editor
component)
+ String style = selenium.getAttribute(
+ editor.getDescendant(jq("table.cke_editor tr:eq(1)
td")).getAttribute(styleAttribute));
+
+ assertTrue(style != null && style.contains(height));
}
@Test
@@ -179,14 +192,31 @@
@Test
public void testOnInit() {
-
+ testFireEvent(new Event("init"), editorTextArea);
}
@Test
public void testReadonly() {
+
+ typeTextToEditor(text1);
+ assertTrue(text1.contains(selenium.getText(editorTextArea)));
+
attributes.setReadonly(Boolean.TRUE);
+ // waitModel.until(elementPresent.locator(editor));
typeTextToEditor("test");
+ // assert that there is no "test" present in editor text area
+ assertFalse(text1.contains(selenium.getText(editorTextArea)));
+
+ // now set read-only back to false
+ attributes.setReadonly(Boolean.FALSE);
+ // waitModel.until(elementPresent.locator(editor));
+
+ // and type another text
+ typeTextToEditor(text2);
+
+ // now we should assert that only expected text are present
+ assertTrue(text2.contains(selenium.getText(editorTextArea)));
}
@Test
@@ -251,7 +281,20 @@
@Test
public void testTitle() {
- testTitle(editor);
+
+ String title = "RichFaces 4";
+ AttributeLocator<?> attribute = editor.getAttribute(new
Attribute("title"));
+
+ // title = null
+ assertFalse(selenium.isAttributePresent(attribute), "Attribute title should
not be present.");
+
+ // set title
+ attributes.setTitle(title);
+
+ // wait until attribute present
+ assertTrue(selenium.isAttributePresent(attribute), "Attribute title should
be present.");
+ // assert correct attribute value: title
+ waitModel.until(attributeEquals.locator(attribute).text(title));
}
@Test
@@ -289,7 +332,12 @@
@Test
public void testWidth() {
- // TODO jjamrich 2011-08-03: implement test when fixed problem with width
+
+ String STYLE_WIDTH = "345px";
+ attributes.setWidth(STYLE_WIDTH);
+
+ String styleAttr = selenium.getAttribute(editor.getAttribute(styleAttribute));
+ assertTrue(styleAttr != null && styleAttr.contains(STYLE_WIDTH),
"Style attribute should contain width value");
}
}
Show replies by thread