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 org.junit.Test; |
23 |
|
import org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
@version |
29 |
|
|
|
|
| 98.7% |
Uncovered Elements: 1 (77) |
Complexity: 12 |
Complexity Density: 0.19 |
|
30 |
|
public class ColorTest extends AbstractWysiwygTestCase |
31 |
|
{ |
32 |
|
|
33 |
|
|
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
35 |
1 |
@Test... |
36 |
|
public void testChangeTextColor() |
37 |
|
{ |
38 |
1 |
typeText("abc"); |
39 |
|
|
40 |
|
|
41 |
1 |
select("document.body.firstChild", 1, "document.body.firstChild", 2); |
42 |
|
|
43 |
|
|
44 |
1 |
clickForegroundColorButton(); |
45 |
1 |
selectColor("rgb(255, 0, 0)"); |
46 |
|
|
47 |
|
|
48 |
1 |
switchToSource(); |
49 |
1 |
assertSourceText("a(% style=\"color: rgb(255, 0, 0);\" %)b(%%)c"); |
50 |
1 |
switchToWysiwyg(); |
51 |
|
|
52 |
|
|
53 |
1 |
moveCaret("document.body.getElementsByTagName('span')[0].firstChild", 1); |
54 |
|
|
55 |
|
|
56 |
1 |
clickForegroundColorButton(); |
57 |
1 |
assertSelectedColor("rgb(255, 0, 0)", true); |
58 |
1 |
hideColorPicker(); |
59 |
|
} |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
64 |
1 |
@Test... |
65 |
|
public void testChangeBackgroundColor() |
66 |
|
{ |
67 |
1 |
typeText("abc"); |
68 |
|
|
69 |
|
|
70 |
1 |
select("document.body.firstChild", 1, "document.body.firstChild", 2); |
71 |
|
|
72 |
|
|
73 |
1 |
clickBackgroundColorButton(); |
74 |
1 |
selectColor("rgb(255, 0, 0)"); |
75 |
|
|
76 |
|
|
77 |
1 |
switchToSource(); |
78 |
1 |
assertSourceText("a(% style=\"background-color: rgb(255, 0, 0);\" %)b(%%)c"); |
79 |
1 |
switchToWysiwyg(); |
80 |
|
|
81 |
|
|
82 |
1 |
moveCaret("document.body.getElementsByTagName('span')[0].firstChild", 1); |
83 |
|
|
84 |
|
|
85 |
1 |
clickBackgroundColorButton(); |
86 |
1 |
assertSelectedColor("rgb(255, 0, 0)", true); |
87 |
1 |
hideColorPicker(); |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
93 |
1 |
@Test... |
94 |
|
public void testChangeTextAndBackgroudColor() |
95 |
|
{ |
96 |
1 |
switchToSource(); |
97 |
1 |
setSourceText("(% style=\"color: red; background-color:#777;\" %)foo"); |
98 |
1 |
switchToWysiwyg(); |
99 |
|
|
100 |
|
|
101 |
1 |
selectNodeContents("document.body.firstChild"); |
102 |
|
|
103 |
|
|
104 |
1 |
clickForegroundColorButton(); |
105 |
1 |
selectColor("rgb(0, 255, 0)"); |
106 |
|
|
107 |
|
|
108 |
1 |
clickBackgroundColorButton(); |
109 |
1 |
selectColor("rgb(252, 229, 205)"); |
110 |
|
|
111 |
1 |
switchToSource(); |
112 |
1 |
assertSourceText("(% style=\"color: rgb(0, 255, 0); background-color: rgb(252, 229, 205);\" %)foo"); |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
118 |
1 |
@Test... |
119 |
|
public void testRemoveBoldStyleFromAColoredText() |
120 |
|
{ |
121 |
|
|
122 |
1 |
typeText("bar"); |
123 |
1 |
selectAllContent(); |
124 |
1 |
clickBoldButton(); |
125 |
|
|
126 |
|
|
127 |
1 |
clickForegroundColorButton(); |
128 |
1 |
selectColor("rgb(0, 0, 255)"); |
129 |
|
|
130 |
|
|
131 |
1 |
clickBoldButton(); |
132 |
|
|
133 |
|
|
134 |
1 |
switchToSource(); |
135 |
1 |
assertSourceText("(% style=\"color: rgb(0, 0, 255);\" %)bar"); |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
@see |
142 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
143 |
1 |
@Test... |
144 |
|
public void testChangeTextColorAfterSelectingTextWithDifferentColors() |
145 |
|
{ |
146 |
|
|
147 |
1 |
typeText("a z"); |
148 |
|
|
149 |
|
|
150 |
1 |
select("document.body.firstChild", 0, "document.body.firstChild", 1); |
151 |
1 |
clickForegroundColorButton(); |
152 |
1 |
selectColor("rgb(255, 0, 0)"); |
153 |
|
|
154 |
|
|
155 |
1 |
select("document.body.childNodes[1]", 1, "document.body.childNodes[1]", 2); |
156 |
1 |
clickForegroundColorButton(); |
157 |
1 |
selectColor("rgb(0, 0, 255)"); |
158 |
|
|
159 |
|
|
160 |
1 |
selectAllContent(); |
161 |
1 |
clickForegroundColorButton(); |
162 |
1 |
selectColor("rgb(0, 255, 0)"); |
163 |
|
|
164 |
|
|
165 |
1 |
switchToSource(); |
166 |
1 |
assertSourceText("(% style=\"color: rgb(0, 255, 0);\" %)a z"); |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
173 |
1 |
@Test... |
174 |
|
public void testDetectNestedBackgroundColor() |
175 |
|
{ |
176 |
1 |
switchToSource(); |
177 |
1 |
setSourceText("12 (% style=\"background-color:red\" %)34 " |
178 |
|
+ "(% style=\"background-color:red;color:yellow\" %)56 **78** 90"); |
179 |
1 |
switchToWysiwyg(); |
180 |
|
|
181 |
1 |
moveCaret("document.body.getElementsByTagName('strong')[0].firstChild", 1); |
182 |
|
|
183 |
1 |
clickBackgroundColorButton(); |
184 |
1 |
assertSelectedColor("rgb(255, 0, 0)", true); |
185 |
1 |
hideColorPicker(); |
186 |
|
} |
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
191 |
7 |
protected void clickForegroundColorButton()... |
192 |
|
{ |
193 |
7 |
pushToolBarButton("Font Color"); |
194 |
|
} |
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
199 |
4 |
protected void clickBackgroundColorButton()... |
200 |
|
{ |
201 |
4 |
pushToolBarButton("Highlight Color"); |
202 |
|
} |
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
@param |
208 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
209 |
8 |
protected void selectColor(String rgbColor)... |
210 |
|
{ |
211 |
8 |
getSelenium().click("//div[@class = 'colorCell' and @style = 'background-color: " + rgbColor + ";']"); |
212 |
|
} |
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
@param |
218 |
|
@param |
219 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
220 |
3 |
protected void assertSelectedColor(String rgbColor, boolean dark)... |
221 |
|
{ |
222 |
3 |
assertElementPresent(String.format( |
223 |
3 |
"//div[contains(@class, 'colorCell-selected-%s') and @style = 'background-color: %s;']", dark ? "dark" |
224 |
|
: "light", rgbColor)); |
225 |
|
} |
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
230 |
3 |
protected void hideColorPicker()... |
231 |
|
{ |
232 |
3 |
getRichTextArea().click(); |
233 |
|
} |
234 |
|
} |