| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.test.wysiwyg; |
| 21 |
|
|
| 22 |
|
import java.util.Date; |
| 23 |
|
|
| 24 |
|
import org.junit.Test; |
| 25 |
|
import org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase; |
| 26 |
|
|
| 27 |
|
import static org.junit.Assert.*; |
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
@version |
| 33 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (69) |
Complexity: 5 |
Complexity Density: 0.08 |
|
| 34 |
|
public class EditInlineTest extends AbstractWysiwygTestCase |
| 35 |
|
{ |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
@see |
| 40 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 41 |
1 |
@Test... |
| 42 |
|
public void testEditPropertyWithUnderscore() |
| 43 |
|
{ |
| 44 |
1 |
StringBuffer spaceName = new StringBuffer(this.getClass().getSimpleName()); |
| 45 |
1 |
spaceName.insert(spaceName.length() / 2, "_0_"); |
| 46 |
|
|
| 47 |
1 |
StringBuffer pageName = new StringBuffer(getTestMethodName()); |
| 48 |
1 |
pageName.insert(pageName.length() / 2, "_17_"); |
| 49 |
|
|
| 50 |
|
|
| 51 |
1 |
open(spaceName.toString(), pageName.toString(), "edit", "editor=class"); |
| 52 |
1 |
String propertyName = "my_1_property"; |
| 53 |
1 |
addWysiwygProperty(propertyName); |
| 54 |
1 |
clickEditSaveAndContinue(); |
| 55 |
|
|
| 56 |
|
|
| 57 |
1 |
open(spaceName.toString(), pageName.toString(), "edit", "editor=object"); |
| 58 |
1 |
addObject(pageName.toString()); |
| 59 |
1 |
String propertyValue = String.valueOf(new Date().getTime()); |
| 60 |
1 |
setFieldValue(spaceName + "." + pageName + "_0_" + propertyName, propertyValue); |
| 61 |
1 |
clickEditSaveAndContinue(); |
| 62 |
|
|
| 63 |
|
|
| 64 |
1 |
open(spaceName.toString(), pageName.toString(), "edit", "editor=wiki"); |
| 65 |
1 |
setFieldValue("content", display(pageName.toString(), propertyName)); |
| 66 |
1 |
clickEditSaveAndView(); |
| 67 |
1 |
assertTextPresent(propertyValue); |
| 68 |
|
|
| 69 |
|
|
| 70 |
1 |
open(spaceName.toString(), pageName.toString(), "edit", "editor=inline"); |
| 71 |
1 |
waitForEditorToLoad(); |
| 72 |
1 |
assertEquals(propertyValue, getRichTextArea().getText()); |
| 73 |
|
|
| 74 |
|
|
| 75 |
1 |
propertyValue = new StringBuffer(propertyValue).reverse().toString(); |
| 76 |
1 |
setContent(propertyValue); |
| 77 |
1 |
clickEditSaveAndView(); |
| 78 |
1 |
assertTextPresent(propertyValue); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
@see |
| 86 |
|
|
| 87 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 88 |
1 |
@Test... |
| 89 |
|
public void testEditorInitialContentWhenCreatingDocumentFromTemplate() |
| 90 |
|
{ |
| 91 |
1 |
String spaceName = this.getClass().getSimpleName(); |
| 92 |
1 |
String pageName = getTestMethodName(); |
| 93 |
1 |
String className = pageName + "Class"; |
| 94 |
1 |
String templateName = pageName + "Template"; |
| 95 |
1 |
String sheetName = pageName + "Sheet"; |
| 96 |
1 |
String propertyName = "myproperty"; |
| 97 |
|
|
| 98 |
|
|
| 99 |
1 |
deletePage(spaceName, className); |
| 100 |
1 |
open(spaceName, className, "edit", "editor=class"); |
| 101 |
1 |
addWysiwygProperty(propertyName); |
| 102 |
1 |
clickEditSaveAndContinue(); |
| 103 |
|
|
| 104 |
|
|
| 105 |
1 |
deletePage(spaceName, sheetName); |
| 106 |
1 |
open(spaceName, sheetName, "edit", "editor=wiki"); |
| 107 |
1 |
setFieldValue("content", display(className, propertyName)); |
| 108 |
1 |
clickEditSaveAndContinue(); |
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
1 |
deletePage(spaceName, templateName); |
| 113 |
1 |
open(spaceName, templateName, "edit", "editor=object"); |
| 114 |
1 |
addObject(className); |
| 115 |
1 |
String propertyValue = String.valueOf(new Date().getTime()); |
| 116 |
1 |
setFieldValue(spaceName + "." + className + "_0_" + propertyName, propertyValue); |
| 117 |
1 |
clickEditSaveAndContinue(); |
| 118 |
|
|
| 119 |
1 |
open(spaceName, templateName, "edit", "editor=wiki"); |
| 120 |
1 |
setFieldValue("content", "{{include document=\"" + sheetName + "\"/}}"); |
| 121 |
1 |
clickEditSaveAndView(); |
| 122 |
1 |
assertTextPresent(propertyValue); |
| 123 |
|
|
| 124 |
|
|
| 125 |
1 |
open(spaceName, pageName, "edit", "editor=inline&template=" + templateName); |
| 126 |
1 |
waitForEditorToLoad(); |
| 127 |
1 |
assertEquals(propertyValue, getRichTextArea().getText()); |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
@param |
| 134 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 135 |
2 |
private void addWysiwygProperty(String propertyName)... |
| 136 |
|
{ |
| 137 |
2 |
setFieldValue("propname", propertyName); |
| 138 |
2 |
getSelenium().select("proptype", "TextArea"); |
| 139 |
2 |
clickEditAddProperty(); |
| 140 |
|
|
| 141 |
2 |
getSelenium().click("xproperty_" + propertyName); |
| 142 |
2 |
getSelenium().select(propertyName + "_editor", "Wysiwyg"); |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
@param |
| 149 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 150 |
2 |
private void addObject(String className)... |
| 151 |
|
{ |
| 152 |
2 |
getSelenium().select("classname", className); |
| 153 |
2 |
clickEditAddObject(); |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
|
| 157 |
|
@param |
| 158 |
|
@param |
| 159 |
|
@return |
| 160 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 161 |
2 |
private String display(String className, String propertyName)... |
| 162 |
|
{ |
| 163 |
2 |
StringBuffer code = new StringBuffer(); |
| 164 |
2 |
code.append("{{velocity}}\n"); |
| 165 |
2 |
code.append("$doc.use(\"" + className + "\")\n"); |
| 166 |
2 |
code.append("$doc.display(\"" + propertyName + "\")\n"); |
| 167 |
2 |
code.append("{{/velocity}}"); |
| 168 |
2 |
return code.toString(); |
| 169 |
|
} |
| 170 |
|
} |