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.openqa.selenium.Keys; |
24 |
|
import org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase; |
25 |
|
|
26 |
|
import static org.junit.Assert.*; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
@version |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (235) |
Complexity: 17 |
Complexity Density: 0.08 |
|
33 |
|
public class LineTest extends AbstractWysiwygTestCase |
34 |
|
{ |
35 |
|
|
36 |
|
|
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (39) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
38 |
1 |
@Test... |
39 |
|
public void testInsertLineBreak() |
40 |
|
{ |
41 |
|
|
42 |
1 |
typeText("a"); |
43 |
1 |
typeShiftEnter(); |
44 |
1 |
typeText("b"); |
45 |
1 |
switchToSource(); |
46 |
1 |
assertSourceText("a\nb"); |
47 |
|
|
48 |
1 |
setSourceText(""); |
49 |
1 |
switchToWysiwyg(); |
50 |
|
|
51 |
|
|
52 |
1 |
typeText("c"); |
53 |
1 |
applyStyleTitle1(); |
54 |
1 |
typeShiftEnter(); |
55 |
1 |
typeText("d"); |
56 |
1 |
switchToSource(); |
57 |
1 |
assertSourceText("= c\nd ="); |
58 |
|
|
59 |
1 |
setSourceText(""); |
60 |
1 |
switchToWysiwyg(); |
61 |
|
|
62 |
|
|
63 |
1 |
typeText("e"); |
64 |
1 |
clickUnorderedListButton(); |
65 |
1 |
typeShiftEnter(); |
66 |
1 |
typeText("f"); |
67 |
1 |
switchToSource(); |
68 |
1 |
assertSourceText("* e\nf"); |
69 |
|
|
70 |
|
|
71 |
1 |
setSourceText("|h"); |
72 |
1 |
switchToWysiwyg(); |
73 |
1 |
typeText("g"); |
74 |
1 |
typeShiftEnter(); |
75 |
1 |
switchToSource(); |
76 |
1 |
assertSourceText("|g\nh"); |
77 |
|
|
78 |
|
|
79 |
1 |
setSourceText("|=j"); |
80 |
1 |
switchToWysiwyg(); |
81 |
1 |
typeText("i"); |
82 |
1 |
typeShiftEnter(); |
83 |
1 |
switchToSource(); |
84 |
1 |
assertSourceText("|=i\nj"); |
85 |
|
|
86 |
|
|
87 |
1 |
setSourceText("l"); |
88 |
1 |
switchToWysiwyg(); |
89 |
1 |
typeText("k"); |
90 |
1 |
typeShiftEnter(); |
91 |
1 |
switchToSource(); |
92 |
1 |
assertSourceText("k\nl"); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
98 |
1 |
@Test... |
99 |
|
public void testSplitLine() |
100 |
|
{ |
101 |
|
|
102 |
1 |
typeTextThenEnter("a"); |
103 |
1 |
typeText("b"); |
104 |
1 |
switchToSource(); |
105 |
1 |
assertSourceText("a\n\nb"); |
106 |
|
|
107 |
|
|
108 |
1 |
setSourceText("d"); |
109 |
1 |
switchToWysiwyg(); |
110 |
1 |
typeTextThenEnter("c"); |
111 |
1 |
switchToSource(); |
112 |
1 |
assertSourceText("c\n\nd"); |
113 |
|
|
114 |
|
|
115 |
1 |
setSourceText(""); |
116 |
1 |
switchToWysiwyg(); |
117 |
1 |
applyStyleTitle2(); |
118 |
1 |
typeTextThenEnter("e"); |
119 |
1 |
typeText("f"); |
120 |
1 |
switchToSource(); |
121 |
1 |
assertSourceText("== e ==\n\nf"); |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
127 |
1 |
@Test... |
128 |
|
public void testSplitLineAfterLineBreak() |
129 |
|
{ |
130 |
|
|
131 |
1 |
typeText("a"); |
132 |
1 |
typeShiftEnter(); |
133 |
1 |
typeEnter(); |
134 |
1 |
typeText("b"); |
135 |
1 |
switchToSource(); |
136 |
1 |
assertSourceText("a\n\nb"); |
137 |
|
|
138 |
|
|
139 |
1 |
setSourceText("d"); |
140 |
1 |
switchToWysiwyg(); |
141 |
1 |
typeText("c"); |
142 |
1 |
typeShiftEnter(); |
143 |
1 |
typeEnter(); |
144 |
1 |
switchToSource(); |
145 |
1 |
assertSourceText("c\n\nd"); |
146 |
|
|
147 |
|
|
148 |
1 |
setSourceText(""); |
149 |
1 |
switchToWysiwyg(); |
150 |
1 |
typeText("e"); |
151 |
1 |
applyStyleTitle3(); |
152 |
1 |
typeShiftEnter(); |
153 |
1 |
typeEnter(); |
154 |
1 |
typeText("f"); |
155 |
1 |
switchToSource(); |
156 |
1 |
assertSourceText("=== e ===\n\nf"); |
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
@see |
163 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
164 |
1 |
@Test... |
165 |
|
public void testInsertEmptyLine() |
166 |
|
{ |
167 |
|
|
168 |
1 |
typeText("a"); |
169 |
1 |
typeEnter(2); |
170 |
1 |
typeText("b"); |
171 |
1 |
switchToSource(); |
172 |
1 |
assertSourceText("a\n\n\nb"); |
173 |
|
|
174 |
|
|
175 |
1 |
setSourceText(""); |
176 |
1 |
switchToWysiwyg(); |
177 |
1 |
typeTextThenEnter("c"); |
178 |
1 |
applyStyleTitle4(); |
179 |
1 |
typeEnter(); |
180 |
1 |
typeText("d"); |
181 |
1 |
switchToSource(); |
182 |
1 |
assertSourceText("c\n\n\n==== d ===="); |
183 |
|
} |
184 |
|
|
185 |
|
|
186 |
|
@see |
187 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
188 |
1 |
@Test... |
189 |
|
public void testRemoveEmptyLineBefore() |
190 |
|
{ |
191 |
|
|
192 |
|
|
193 |
1 |
typeText("x"); |
194 |
1 |
applyStyleTitle5(); |
195 |
|
|
196 |
1 |
moveCaret("document.body.firstChild.firstChild", 0); |
197 |
|
|
198 |
1 |
typeEnter(2); |
199 |
|
|
200 |
1 |
typeBackspace(2); |
201 |
|
|
202 |
1 |
switchToSource(); |
203 |
1 |
assertSourceText("===== x ====="); |
204 |
1 |
switchToWysiwyg(); |
205 |
|
|
206 |
|
|
207 |
|
|
208 |
1 |
triggerToolbarUpdate(); |
209 |
1 |
applyStylePlainText(); |
210 |
|
|
211 |
1 |
typeEnter(2); |
212 |
|
|
213 |
1 |
typeBackspace(2); |
214 |
|
|
215 |
1 |
switchToSource(); |
216 |
1 |
assertSourceText("x"); |
217 |
|
} |
218 |
|
|
219 |
|
|
220 |
|
@see |
221 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
222 |
1 |
@Test... |
223 |
|
public void testEnterOnEmptyLine() |
224 |
|
{ |
225 |
1 |
typeEnter(); |
226 |
1 |
typeText("foobar"); |
227 |
1 |
applyStyleTitle1(); |
228 |
1 |
typeEnter(); |
229 |
1 |
typeText("x"); |
230 |
1 |
switchToSource(); |
231 |
1 |
assertSourceText("\n= foobar =\n\nx"); |
232 |
|
} |
233 |
|
|
234 |
|
|
235 |
|
@see |
236 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
237 |
1 |
@Test... |
238 |
|
public void testParagraphs() |
239 |
|
{ |
240 |
1 |
typeTextThenEnter("a"); |
241 |
1 |
typeTextThenEnter("b"); |
242 |
1 |
typeText("c"); |
243 |
1 |
switchToSource(); |
244 |
1 |
assertSourceText("a\n\nb\n\nc"); |
245 |
|
} |
246 |
|
|
247 |
|
|
248 |
|
@see |
249 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
250 |
1 |
@Test... |
251 |
|
public void testEnterAfterImage() |
252 |
|
{ |
253 |
1 |
clickMenu(ImageTest.MENU_IMAGE); |
254 |
1 |
clickMenu(ImageTest.MENU_INSERT_ATTACHED_IMAGE); |
255 |
|
|
256 |
1 |
waitForDialogToLoad(); |
257 |
|
|
258 |
1 |
waitForElement("//*[contains(@class, 'xSelectorAggregatorStep')]"); |
259 |
|
|
260 |
1 |
getSelenium().click("//div[. = 'All pages']"); |
261 |
1 |
String imageSpace = "XWiki"; |
262 |
1 |
waitForElement(ImageTest.SPACE_SELECTOR + "/option[@value = '" + imageSpace + "']"); |
263 |
1 |
getSelenium().select(ImageTest.SPACE_SELECTOR, imageSpace); |
264 |
1 |
String imagePage = "AdminSheet"; |
265 |
1 |
waitForElement(ImageTest.PAGE_SELECTOR + "/option[@value = '" + imagePage + "']"); |
266 |
1 |
getSelenium().select(ImageTest.PAGE_SELECTOR, imagePage); |
267 |
1 |
getSelenium().click("//div[@class = 'xPageChooser']//button[. = 'Update']"); |
268 |
1 |
String imageSelector = "//div[@class = 'xImagesSelector']//img[@title = 'import.png']"; |
269 |
1 |
waitForElement(imageSelector); |
270 |
1 |
getSelenium().click(imageSelector); |
271 |
1 |
clickButtonWithText("Select"); |
272 |
1 |
waitForElement("//*[contains(@class, 'xImageConfig')]"); |
273 |
1 |
clickButtonWithText("Insert Image"); |
274 |
1 |
waitForDialogToClose(); |
275 |
|
|
276 |
|
|
277 |
1 |
getRichTextArea().sendKeys(""); |
278 |
|
|
279 |
|
|
280 |
|
|
281 |
1 |
getRichTextArea().executeScript("window.getSelection().collapseToEnd()"); |
282 |
|
|
283 |
1 |
getRichTextArea().sendKeys(Keys.RETURN, "xyz"); |
284 |
|
|
285 |
|
|
286 |
1 |
blurRichTextArea(); |
287 |
1 |
clickEditPageInWikiSyntaxEditor(); |
288 |
|
|
289 |
1 |
assertEquals("[[image:XWiki.AdminSheet@import.png]]\n\nxyz", getFieldValue("content")); |
290 |
|
} |
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
295 |
1 |
@Test... |
296 |
|
public void testEnterOnCrossParagraphSelection() |
297 |
|
{ |
298 |
|
|
299 |
1 |
typeText("ab"); |
300 |
1 |
applyStyleTitle1(); |
301 |
1 |
applyStylePlainText(); |
302 |
1 |
typeEnter(); |
303 |
1 |
typeText("cd"); |
304 |
|
|
305 |
|
|
306 |
1 |
select("document.body.firstChild.firstChild", 1, "document.body.lastChild.firstChild", 1); |
307 |
|
|
308 |
|
|
309 |
1 |
typeEnter(); |
310 |
1 |
switchToSource(); |
311 |
1 |
assertSourceText("a\n\nd"); |
312 |
|
} |
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
318 |
1 |
@Test... |
319 |
|
public void testEnterOnCrossTableCellSelection() |
320 |
|
{ |
321 |
1 |
insertTable(); |
322 |
|
|
323 |
|
|
324 |
|
|
325 |
1 |
typeBackspace(); |
326 |
1 |
typeText("ab"); |
327 |
1 |
typeTab(); |
328 |
1 |
typeText("cd"); |
329 |
|
|
330 |
1 |
typeDelete(); |
331 |
|
|
332 |
|
|
333 |
1 |
select("document.body.firstChild.rows[0].cells[0].firstChild", 1, |
334 |
|
"document.body.firstChild.rows[0].cells[1].firstChild", 1); |
335 |
|
|
336 |
|
|
337 |
1 |
typeEnter(); |
338 |
1 |
typeText("x"); |
339 |
1 |
switchToSource(); |
340 |
1 |
assertSourceText("|=a\nx|=d\n| | "); |
341 |
|
} |
342 |
|
|
343 |
|
|
344 |
|
@see |
345 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
346 |
1 |
@Test... |
347 |
|
public void testEnterInHeader() |
348 |
|
{ |
349 |
1 |
typeText("H1"); |
350 |
1 |
applyStyleTitle1(); |
351 |
1 |
switchToSource(); |
352 |
1 |
assertSourceText("= H1 ="); |
353 |
1 |
switchToWysiwyg(); |
354 |
|
|
355 |
|
|
356 |
1 |
moveCaret("document.body.firstChild.firstChild", 1); |
357 |
|
|
358 |
|
|
359 |
1 |
typeText("#"); |
360 |
|
|
361 |
|
|
362 |
1 |
waitForStyleDetected("Title 1"); |
363 |
|
|
364 |
|
|
365 |
1 |
typeEnter(); |
366 |
|
|
367 |
|
|
368 |
1 |
waitForStyleDetected("Plain text"); |
369 |
|
|
370 |
1 |
switchToSource(); |
371 |
1 |
assertSourceText("= H# =\n\n1"); |
372 |
|
} |
373 |
|
|
374 |
|
|
375 |
|
|
376 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
377 |
1 |
@Test... |
378 |
|
public void testEnterInListItem() |
379 |
|
{ |
380 |
1 |
typeText("a"); |
381 |
1 |
clickUnorderedListButton(); |
382 |
1 |
applyStyleTitle1(); |
383 |
|
|
384 |
|
|
385 |
1 |
typeShiftEnter(); |
386 |
1 |
typeText("b"); |
387 |
|
|
388 |
|
|
389 |
1 |
typeControlEnter(); |
390 |
1 |
typeText("c"); |
391 |
|
|
392 |
|
|
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
1 |
typeEnter(); |
399 |
1 |
typeText("e"); |
400 |
|
|
401 |
|
|
402 |
1 |
switchToSource(); |
403 |
1 |
assertSourceText("* (((\n= a\nb =\n\nc\n)))\n* e"); |
404 |
|
} |
405 |
|
|
406 |
|
|
407 |
|
@see |
408 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
409 |
1 |
@Test... |
410 |
|
public void testEmptyHeadingsAreEditable() |
411 |
|
{ |
412 |
1 |
switchToSource(); |
413 |
1 |
setSourceText("before\n\n= =\n\nafter"); |
414 |
1 |
switchToWysiwyg(); |
415 |
|
|
416 |
|
|
417 |
|
|
418 |
1 |
assertContent("<p>before</p><h1 id=\"H\"><span></span><br></h1><p>after</p>"); |
419 |
|
} |
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
424 |
1 |
@Test... |
425 |
|
public void testSplitEmptyLineWithGarbage() |
426 |
|
{ |
427 |
|
|
428 |
1 |
setContent("<p><em></em><strong></strong></p>"); |
429 |
|
|
430 |
1 |
moveCaret("document.body.firstChild", 1); |
431 |
|
|
432 |
1 |
typeEnter(); |
433 |
1 |
typeText("x"); |
434 |
|
|
435 |
1 |
assertContent("<p><em></em><br></p><p>x<strong></strong><br></p>"); |
436 |
|
} |
437 |
|
|
438 |
|
|
439 |
|
@see |
440 |
|
@see |
441 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
442 |
1 |
@Test... |
443 |
|
public void testEnterAtTheEndOfALink() |
444 |
|
{ |
445 |
1 |
switchToSource(); |
446 |
1 |
setSourceText("This is a [[link>>http://www.xwiki.org]]"); |
447 |
1 |
switchToWysiwyg(); |
448 |
|
|
449 |
1 |
moveCaret("document.body.firstChild.lastChild.firstChild", 4); |
450 |
1 |
typeEnter(); |
451 |
1 |
typeText("x"); |
452 |
1 |
switchToSource(); |
453 |
1 |
assertSourceText("This is a [[link>>http://www.xwiki.org]]\n\nx"); |
454 |
|
} |
455 |
|
|
456 |
|
|
457 |
|
@see |
458 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
459 |
1 |
@Test... |
460 |
|
public void testTextAlignmentIsPreservedOnANewParagraph() |
461 |
|
{ |
462 |
|
|
463 |
1 |
typeText("1"); |
464 |
1 |
applyStyleTitle1(); |
465 |
|
|
466 |
1 |
pushToolBarButton("Centered"); |
467 |
|
|
468 |
1 |
typeEnter(); |
469 |
1 |
typeTextThenEnter("2"); |
470 |
1 |
typeText("34"); |
471 |
|
|
472 |
1 |
moveCaret("document.body.lastChild.firstChild", 1); |
473 |
1 |
typeEnter(); |
474 |
|
|
475 |
1 |
switchToSource(); |
476 |
1 |
assertSourceText("(% style=\"text-align: center;\" %)\n= 1 =\n\n" |
477 |
|
+ "(% style=\"text-align: center;\" %)\n2\n\n" + "(% style=\"text-align: center;\" %)\n3\n\n" |
478 |
|
+ "(% style=\"text-align: center;\" %)\n4"); |
479 |
|
} |
480 |
|
|
481 |
|
|
482 |
|
@see |
483 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
484 |
1 |
@Test... |
485 |
|
public void testEmptyParagraphsGenerateEmptyLines() |
486 |
|
{ |
487 |
1 |
switchToSource(); |
488 |
1 |
setSourceText("(% style=\"color: blue; text-align: center;\" %)\nHello world"); |
489 |
1 |
switchToWysiwyg(); |
490 |
|
|
491 |
|
|
492 |
1 |
moveCaret("document.body.firstChild.firstChild", 6); |
493 |
|
|
494 |
1 |
typeEnter(3); |
495 |
|
|
496 |
1 |
switchToSource(); |
497 |
1 |
assertSourceText("(% style=\"color: blue; text-align: center;\" %)\nHello\n\n\n\n" |
498 |
|
+ "(% style=\"text-align: center;\" %)\nworld"); |
499 |
|
} |
500 |
|
} |