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.By; |
24 |
|
import org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
@version |
30 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (72) |
Complexity: 12 |
Complexity Density: 0.2 |
|
31 |
|
public class FontTest extends AbstractWysiwygTestCase |
32 |
|
{ |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
private static final String FONT_SIZE_SELECTOR = "//select[@title=\"Font Size\"]"; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
private static final String FONT_NAME_SELECTOR = "//select[@title=\"Font Name\"]"; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
@see |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
48 |
1 |
@Test... |
49 |
|
public void testSetFontSizeOnAPlainTextSelection() |
50 |
|
{ |
51 |
1 |
typeText("abc"); |
52 |
1 |
select("document.body.firstChild", 1, "document.body.firstChild", 2); |
53 |
1 |
applyFontSize("24px"); |
54 |
1 |
switchToSource(); |
55 |
1 |
assertSourceText("a(% style=\"font-size: 24px;\" %)b(%%)c"); |
56 |
|
} |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
61 |
1 |
@Test... |
62 |
|
public void testSetFontNameOnAPlainTextSelection() |
63 |
|
{ |
64 |
1 |
typeText("abc"); |
65 |
1 |
select("document.body.firstChild", 1, "document.body.firstChild", 2); |
66 |
1 |
applyFontName("Georgia"); |
67 |
1 |
switchToSource(); |
68 |
1 |
assertSourceText("a(% style=\"font-family: Georgia;\" %)b(%%)c"); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
74 |
1 |
@Test... |
75 |
|
public void testSetFontNameAndSizeOnAPlainTextSelection() |
76 |
|
{ |
77 |
1 |
typeText("abc"); |
78 |
1 |
select("document.body.firstChild", 1, "document.body.firstChild", 2); |
79 |
1 |
applyFontName("Arial"); |
80 |
1 |
applyFontSize("18px"); |
81 |
1 |
switchToSource(); |
82 |
1 |
assertSourceText("a(% style=\"font-family: Arial; font-size: 18px;\" %)b(%%)c"); |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
88 |
1 |
@Test... |
89 |
|
public void testDetectFont() |
90 |
|
{ |
91 |
1 |
switchToSource(); |
92 |
1 |
setSourceText("(% style=\"font-size: 24px; font-family: foo,verdana,sans-serif\" %)\nabc"); |
93 |
1 |
switchToWysiwyg(); |
94 |
1 |
selectAllContent(); |
95 |
1 |
waitForDetectedFontSize("24px"); |
96 |
1 |
waitForDetectedFontName("Verdana"); |
97 |
|
} |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
103 |
1 |
@Test... |
104 |
|
public void testDetectKnownUnsupportedFontName() |
105 |
|
{ |
106 |
1 |
switchToSource(); |
107 |
1 |
setSourceText("(% style=\"font-family: wingdings\" %)\nabc"); |
108 |
1 |
switchToWysiwyg(); |
109 |
1 |
selectAllContent(); |
110 |
1 |
waitForDetectedFontName("Wingdings"); |
111 |
|
|
112 |
1 |
switchToSource(); |
113 |
1 |
setSourceText("(% style=\"font-family: wingdings,arial\" %)\nabc"); |
114 |
1 |
switchToWysiwyg(); |
115 |
1 |
selectAllContent(); |
116 |
1 |
waitForDetectedFontName("Arial"); |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
122 |
1 |
@Test... |
123 |
|
public void testDetectUnknownFontName() |
124 |
|
{ |
125 |
1 |
switchToSource(); |
126 |
1 |
setSourceText("(% style=\"font-family: unknown\" %)\nabc"); |
127 |
1 |
switchToWysiwyg(); |
128 |
1 |
selectAllContent(); |
129 |
1 |
waitForDetectedFontName("unknown"); |
130 |
|
|
131 |
1 |
switchToSource(); |
132 |
1 |
setSourceText("(% style=\"font-family: unknown,arial\" %)\nabc"); |
133 |
1 |
switchToWysiwyg(); |
134 |
1 |
selectAllContent(); |
135 |
1 |
waitForDetectedFontName("Arial"); |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
141 |
1 |
@Test... |
142 |
|
public void testDetectUnlistedFontSize() |
143 |
|
{ |
144 |
1 |
switchToSource(); |
145 |
1 |
setSourceText("(% style=\"font-size: 21px\" %)\nabc"); |
146 |
1 |
switchToWysiwyg(); |
147 |
1 |
selectAllContent(); |
148 |
1 |
waitForDetectedFontSize("21px"); |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
154 |
1 |
@Test... |
155 |
|
public void testDetectFontNameOnCrossParagraphSelection() |
156 |
|
{ |
157 |
1 |
switchToSource(); |
158 |
1 |
setSourceText("(% style=\"font-family: courier new\" %)\nabc\n\n(% style=\"font-family: times new roman\" %)\nxyz"); |
159 |
1 |
switchToWysiwyg(); |
160 |
1 |
moveCaret("document.body.getElementsByTagName('p')[0].firstChild", 1); |
161 |
1 |
waitForDetectedFontName("Courier New"); |
162 |
1 |
moveCaret("document.body.getElementsByTagName('p')[1].firstChild", 1); |
163 |
1 |
waitForDetectedFontName("Times New Roman"); |
164 |
1 |
select("document.body.getElementsByTagName('p')[0].firstChild", 1, |
165 |
|
"document.body.getElementsByTagName('p')[1].firstChild", 1); |
166 |
1 |
waitForDetectedFontName(""); |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
@param |
173 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
174 |
2 |
protected void applyFontSize(String fontSize)... |
175 |
|
{ |
176 |
2 |
getSelenium().select(FONT_SIZE_SELECTOR, fontSize); |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
@param |
183 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
184 |
2 |
protected void applyFontName(String fontName)... |
185 |
|
{ |
186 |
2 |
getSelenium().select(FONT_NAME_SELECTOR, fontName); |
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
@param |
194 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
195 |
2 |
protected void waitForDetectedFontSize(final String expectedFontSize)... |
196 |
|
{ |
197 |
2 |
getDriver().waitUntilElementHasAttributeValue(By.xpath(FONT_SIZE_SELECTOR), "value", expectedFontSize); |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
@param |
204 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
205 |
8 |
protected void waitForDetectedFontName(final String expectedFontName)... |
206 |
|
{ |
207 |
8 |
getDriver().waitUntilElementHasAttributeValue(By.xpath(FONT_NAME_SELECTOR), "value", expectedFontName); |
208 |
|
} |
209 |
|
} |