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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (46) |
Complexity: 6 |
Complexity Density: 0.15 |
|
30 |
|
public class RemoveFormattingTest extends AbstractWysiwygTestCase |
31 |
|
{ |
32 |
|
|
33 |
|
|
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
35 |
1 |
@Test... |
36 |
|
public void testRemoveFormattingMarkers() |
37 |
|
{ |
38 |
1 |
switchToSource(); |
39 |
1 |
setSourceText("==== **//__--abc--__//** ===="); |
40 |
1 |
switchToWysiwyg(); |
41 |
1 |
selectAllContent(); |
42 |
1 |
clickRemoveFormattingButton(); |
43 |
1 |
switchToSource(); |
44 |
1 |
assertSourceText("==== abc ===="); |
45 |
|
} |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
50 |
1 |
@Test... |
51 |
|
public void testRemoveInlineStyle() |
52 |
|
{ |
53 |
1 |
switchToSource(); |
54 |
1 |
setSourceText("a(% style=\"color:red;\" %)b(% style=\"font-size:36pt;\" %)c(%%)d(%%)e"); |
55 |
1 |
switchToWysiwyg(); |
56 |
1 |
selectAllContent(); |
57 |
1 |
clickRemoveFormattingButton(); |
58 |
1 |
switchToSource(); |
59 |
1 |
assertSourceText("abcde"); |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
65 |
1 |
@Test... |
66 |
|
public void testRemoveFormattingFromCrossBlockSelection() |
67 |
|
{ |
68 |
1 |
switchToSource(); |
69 |
1 |
setSourceText("= a(% style=\"color:green\" %)b**cd**(%%)e =\n\nf(% style=\"font-size:36pt\" %)g//hi//(%%)j"); |
70 |
1 |
switchToWysiwyg(); |
71 |
1 |
select("document.body.getElementsByTagName('strong')[0].firstChild", 1, |
72 |
|
"document.body.getElementsByTagName('em')[0].firstChild", 1); |
73 |
1 |
clickRemoveFormattingButton(); |
74 |
1 |
switchToSource(); |
75 |
1 |
assertSourceText("= a(% style=\"color:green\" %)b**c**(%%)de =\n\nfgh(% style=\"font-size:36pt\" %)//i//(%%)j"); |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
81 |
1 |
@Test... |
82 |
|
public void testRemoveFormattingKeepsTheAnchorsIntact() |
83 |
|
{ |
84 |
|
|
85 |
1 |
switchToSource(); |
86 |
1 |
setSourceText("a**b[[c//d//e>>http://www.xwiki.org]]f**g"); |
87 |
1 |
switchToWysiwyg(); |
88 |
1 |
selectAllContent(); |
89 |
1 |
clickRemoveFormattingButton(); |
90 |
1 |
switchToSource(); |
91 |
1 |
assertSourceText("ab[[cde>>http://www.xwiki.org]]fg"); |
92 |
|
|
93 |
|
|
94 |
1 |
setSourceText("1**2[[3//456//7>>http://www.xwiki.org]]8**9"); |
95 |
1 |
switchToWysiwyg(); |
96 |
1 |
select("document.getElementsByTagName('em')[0].firstChild", 1, |
97 |
|
"document.getElementsByTagName('em')[0].firstChild", 2); |
98 |
1 |
clickRemoveFormattingButton(); |
99 |
1 |
switchToSource(); |
100 |
1 |
assertSourceText("1**2**[[**3//4//**5**//6//7**>>http://www.xwiki.org]]**8**9"); |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
106 |
1 |
@Test... |
107 |
|
public void testRemoveFormattingFromStandaloneAnchor() |
108 |
|
{ |
109 |
1 |
setContent("<a href=\"http://www.xwiki.org\" style=\"color: red; font-size: 18pt;\">123456</a>"); |
110 |
1 |
select("document.body.firstChild.firstChild", 2, "document.body.firstChild.firstChild", 4); |
111 |
1 |
clickRemoveFormattingButton(); |
112 |
1 |
switchToSource(); |
113 |
1 |
assertSourceText("[[(% style=\"color: red; font-size: 18pt;\" %)12(%%)34" |
114 |
|
+ "(% style=\"color: red; font-size: 18pt;\" %)56>>url:http://www.xwiki.org]]"); |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
6 |
protected void clickRemoveFormattingButton()... |
121 |
|
{ |
122 |
6 |
pushToolBarButton("Clear Formatting"); |
123 |
|
} |
124 |
|
} |