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.openqa.selenium.Keys; |
25 |
|
import org.openqa.selenium.TimeoutException; |
26 |
|
import org.openqa.selenium.WebDriver; |
27 |
|
import org.openqa.selenium.support.ui.ExpectedCondition; |
28 |
|
import org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase; |
29 |
|
|
30 |
|
import com.thoughtworks.selenium.Wait; |
31 |
|
|
32 |
|
import static org.junit.Assert.*; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@version |
38 |
|
|
|
|
| 99.4% |
Uncovered Elements: 5 (813) |
Complexity: 85 |
Complexity Density: 0.12 |
|
39 |
|
public class MacroTest extends AbstractWysiwygTestCase |
40 |
|
{ |
41 |
|
public static final String MENU_MACRO = "Macro"; |
42 |
|
|
43 |
|
public static final String MENU_REFRESH = "Refresh"; |
44 |
|
|
45 |
|
public static final String MENU_COLLAPSE = "Collapse"; |
46 |
|
|
47 |
|
public static final String MENU_COLLAPSE_ALL = "Collapse All"; |
48 |
|
|
49 |
|
public static final String MENU_EXPAND = "Expand"; |
50 |
|
|
51 |
|
public static final String MENU_EXPAND_ALL = "Expand All"; |
52 |
|
|
53 |
|
public static final String MENU_EDIT = "Edit Macro Properties..."; |
54 |
|
|
55 |
|
public static final String MENU_INSERT = "Insert Macro..."; |
56 |
|
|
57 |
|
public static final String MACRO_CATEGORY_SELECTOR = "//select[@title='Select a macro category']"; |
58 |
|
|
59 |
|
public static final String MACRO_LIVE_FILTER_SELECTOR = "//input[@title = 'Type to filter']"; |
60 |
|
|
61 |
|
public static final String MACRO_SELECTOR_LIST = "//div[contains(@class, 'xListBox')]"; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
67 |
1 |
@Test... |
68 |
|
public void testDeleteCharacterBeforeMacro() |
69 |
|
{ |
70 |
1 |
switchToSource(); |
71 |
1 |
setSourceText("a{{html}}b{{/html}}"); |
72 |
1 |
switchToWysiwyg(); |
73 |
1 |
typeDelete(); |
74 |
1 |
typeText("x"); |
75 |
1 |
switchToSource(); |
76 |
1 |
assertSourceText("x{{html}}b{{/html}}"); |
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
83 |
1 |
@Test... |
84 |
|
public void testHoldDeleteKeyBeforeMacro() |
85 |
|
{ |
86 |
1 |
switchToSource(); |
87 |
1 |
setSourceText("bc{{html}}def{{/html}}g"); |
88 |
1 |
switchToWysiwyg(); |
89 |
|
|
90 |
1 |
moveCaret("document.body.firstChild.firstChild", 1); |
91 |
1 |
typeDelete(2, true); |
92 |
1 |
typeText("x"); |
93 |
1 |
switchToSource(); |
94 |
1 |
assertSourceText("bxg"); |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
101 |
1 |
@Test... |
102 |
|
public void testSelectCharacterBeforeMacroAndPressBackspace() |
103 |
|
{ |
104 |
1 |
switchToSource(); |
105 |
1 |
setSourceText("g{{html}}h{{/html}}"); |
106 |
1 |
switchToWysiwyg(); |
107 |
|
|
108 |
1 |
selectNode("document.body.firstChild.firstChild"); |
109 |
1 |
typeBackspace(); |
110 |
1 |
typeText("x"); |
111 |
1 |
switchToSource(); |
112 |
1 |
assertSourceText("x{{html}}h{{/html}}"); |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
119 |
1 |
@Test... |
120 |
|
public void testSelectCharacterBeforeMacroAndInsertSymbol() |
121 |
|
{ |
122 |
1 |
switchToSource(); |
123 |
1 |
setSourceText("i{{html}}j{{/html}}"); |
124 |
1 |
switchToWysiwyg(); |
125 |
|
|
126 |
1 |
selectNode("document.body.firstChild.firstChild"); |
127 |
1 |
clickSymbolButton(); |
128 |
1 |
getSelenium().click("//div[@title='copyright sign']"); |
129 |
1 |
typeText("x"); |
130 |
1 |
switchToSource(); |
131 |
1 |
assertSourceText("\u00A9x{{html}}j{{/html}}"); |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
137 |
1 |
@Test... |
138 |
|
public void testPressDeleteJustBeforeMacro() |
139 |
|
{ |
140 |
1 |
switchToSource(); |
141 |
1 |
setSourceText("j{{html}}k{{/html}}l"); |
142 |
1 |
switchToWysiwyg(); |
143 |
|
|
144 |
1 |
moveCaret("document.body.firstChild.firstChild", 1); |
145 |
1 |
typeDelete(); |
146 |
1 |
typeText("x"); |
147 |
1 |
switchToSource(); |
148 |
1 |
assertSourceText("jxl"); |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
155 |
1 |
@Test... |
156 |
|
public void testDeleteCharacterAfterMacro() |
157 |
|
{ |
158 |
1 |
switchToSource(); |
159 |
1 |
setSourceText("a{{html}}b{{/html}}c"); |
160 |
1 |
switchToWysiwyg(); |
161 |
|
|
162 |
1 |
moveCaret("document.body.firstChild.lastChild", 1); |
163 |
1 |
typeBackspace(); |
164 |
1 |
typeText("x"); |
165 |
1 |
switchToSource(); |
166 |
1 |
assertSourceText("a{{html}}b{{/html}}x"); |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
173 |
1 |
@Test... |
174 |
|
public void testHoldBackspaceKeyAfterMacro() |
175 |
|
{ |
176 |
1 |
switchToSource(); |
177 |
1 |
setSourceText("c{{html}}def{{/html}}g"); |
178 |
1 |
switchToWysiwyg(); |
179 |
|
|
180 |
1 |
moveCaret("document.body.firstChild.lastChild", 1); |
181 |
1 |
typeBackspace(2, true); |
182 |
1 |
typeText("x"); |
183 |
1 |
switchToSource(); |
184 |
1 |
assertSourceText("cx"); |
185 |
|
} |
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
191 |
1 |
@Test... |
192 |
|
public void testSelectCharacterAfterMacroAndPressDelete() |
193 |
|
{ |
194 |
1 |
switchToSource(); |
195 |
1 |
setSourceText("g{{html}}h{{/html}}i"); |
196 |
1 |
switchToWysiwyg(); |
197 |
|
|
198 |
1 |
selectNode("document.body.firstChild.lastChild"); |
199 |
1 |
typeDelete(); |
200 |
1 |
typeText("x"); |
201 |
1 |
switchToSource(); |
202 |
1 |
assertSourceText("g{{html}}h{{/html}}x"); |
203 |
|
} |
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
209 |
1 |
@Test... |
210 |
|
public void testSelectCharacterAfterMacroAndInsertSymbol() |
211 |
|
{ |
212 |
1 |
switchToSource(); |
213 |
1 |
setSourceText("i{{html}}j{{/html}}k"); |
214 |
1 |
switchToWysiwyg(); |
215 |
|
|
216 |
1 |
selectNode("document.body.firstChild.lastChild"); |
217 |
1 |
clickSymbolButton(); |
218 |
1 |
getSelenium().click("//div[@title='copyright sign']"); |
219 |
1 |
typeText("x"); |
220 |
1 |
switchToSource(); |
221 |
1 |
assertSourceText("i{{html}}j{{/html}}\u00A9x"); |
222 |
|
} |
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
227 |
1 |
@Test... |
228 |
|
public void testPressBackspaceJustAfterMacro() |
229 |
|
{ |
230 |
1 |
switchToSource(); |
231 |
1 |
setSourceText("k{{html}}l{{/html}}m"); |
232 |
1 |
switchToWysiwyg(); |
233 |
|
|
234 |
1 |
moveCaret("document.body.firstChild.lastChild", 0); |
235 |
1 |
typeBackspace(); |
236 |
1 |
typeText("x"); |
237 |
1 |
switchToSource(); |
238 |
1 |
assertSourceText("kxm"); |
239 |
|
} |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
244 |
1 |
@Test... |
245 |
|
public void testUndoRedoWhenMacrosArePresent() |
246 |
|
{ |
247 |
1 |
switchToSource(); |
248 |
1 |
setSourceText("{{html}}pq{{/html}}"); |
249 |
1 |
switchToWysiwyg(); |
250 |
|
|
251 |
|
|
252 |
1 |
moveCaret("document.body", 0); |
253 |
1 |
typeText("uv"); |
254 |
1 |
clickUndoButton(); |
255 |
1 |
clickRedoButton(); |
256 |
1 |
switchToSource(); |
257 |
1 |
assertSourceText("uv{{html}}pq{{/html}}"); |
258 |
|
} |
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
263 |
1 |
@Test... |
264 |
|
public void testSelectAndDeleteMacro() |
265 |
|
{ |
266 |
1 |
switchToSource(); |
267 |
1 |
setSourceText("{{html}}<p>foo</p>{{/html}}\n\nbar"); |
268 |
1 |
switchToWysiwyg(); |
269 |
1 |
selectRichTextAreaFrame(); |
270 |
1 |
try { |
271 |
1 |
getSelenium().click(getMacroLocator(0)); |
272 |
|
} finally { |
273 |
1 |
selectTopFrame(); |
274 |
|
} |
275 |
1 |
typeBackspace(); |
276 |
1 |
switchToSource(); |
277 |
1 |
assertSourceText("bar"); |
278 |
|
} |
279 |
|
|
280 |
|
|
281 |
|
@see |
282 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
283 |
1 |
@Test... |
284 |
|
public void testWhiteSpacesInsideCodeMacroArePreserved() |
285 |
|
{ |
286 |
1 |
String wikiText = "{{code}}\nfunction foo() {\n alert('bar');\n}\n{{/code}}"; |
287 |
1 |
switchToSource(); |
288 |
1 |
setSourceText(wikiText); |
289 |
1 |
switchToWysiwyg(); |
290 |
1 |
switchToSource(); |
291 |
1 |
assertSourceText(wikiText); |
292 |
|
} |
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
298 |
1 |
@Test... |
299 |
|
public void testCollapseAndExpandAllMacros() |
300 |
|
{ |
301 |
1 |
setContent("no macro"); |
302 |
|
|
303 |
1 |
clickMenu(MENU_MACRO); |
304 |
1 |
assertTrue(isMenuEnabled(MENU_REFRESH)); |
305 |
|
|
306 |
1 |
assertFalse(isMenuEnabled(MENU_COLLAPSE_ALL)); |
307 |
1 |
assertFalse(isMenuEnabled(MENU_EXPAND_ALL)); |
308 |
1 |
closeMenuContaining(MENU_REFRESH); |
309 |
|
|
310 |
1 |
switchToSource(); |
311 |
1 |
setSourceText("k\n\n{{html}}l{{/html}}\n\nm\n\n{{code}}n{{/code}}\n\no"); |
312 |
1 |
switchToWysiwyg(); |
313 |
1 |
clickMenu(MENU_MACRO); |
314 |
|
|
315 |
1 |
assertTrue(isMenuEnabled(MENU_COLLAPSE_ALL)); |
316 |
1 |
assertFalse(isMenuEnabled(MENU_EXPAND_ALL)); |
317 |
|
|
318 |
|
|
319 |
1 |
clickMenu(MENU_COLLAPSE_ALL); |
320 |
|
|
321 |
1 |
clickMenu(MENU_MACRO); |
322 |
|
|
323 |
1 |
assertFalse(isMenuEnabled(MENU_COLLAPSE_ALL)); |
324 |
1 |
assertTrue(isMenuEnabled(MENU_EXPAND_ALL)); |
325 |
|
|
326 |
|
|
327 |
1 |
clickMenu(MENU_EXPAND_ALL); |
328 |
|
|
329 |
1 |
clickMenu(MENU_MACRO); |
330 |
|
|
331 |
1 |
assertTrue(isMenuEnabled(MENU_COLLAPSE_ALL)); |
332 |
1 |
assertFalse(isMenuEnabled(MENU_EXPAND_ALL)); |
333 |
1 |
closeMenuContaining(MENU_REFRESH); |
334 |
|
|
335 |
|
|
336 |
1 |
selectMacro(0); |
337 |
1 |
collapseMacrosUsingShortcutKey(); |
338 |
|
|
339 |
1 |
clearMacroSelection(); |
340 |
|
|
341 |
|
|
342 |
1 |
clickMenu(MENU_MACRO); |
343 |
1 |
assertTrue(isMenuEnabled(MENU_COLLAPSE_ALL)); |
344 |
1 |
assertTrue(isMenuEnabled(MENU_EXPAND_ALL)); |
345 |
|
} |
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
|
350 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (32) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
351 |
1 |
@Test... |
352 |
|
public void testCollapseAndExpandSelectedMacros() |
353 |
|
{ |
354 |
1 |
switchToSource(); |
355 |
1 |
setSourceText("o\n\n{{html}}n{{/html}}\n\nm\n\n{{code}}l{{/code}}\n\nk"); |
356 |
1 |
switchToWysiwyg(); |
357 |
|
|
358 |
|
|
359 |
1 |
clickMenu(MENU_MACRO); |
360 |
1 |
assertTrue(isMenuEnabled(MENU_REFRESH)); |
361 |
1 |
assertFalse(isMenuEnabled(MENU_COLLAPSE)); |
362 |
1 |
assertFalse(isMenuEnabled(MENU_EXPAND)); |
363 |
1 |
closeMenuContaining(MENU_REFRESH); |
364 |
|
|
365 |
|
|
366 |
1 |
selectMacro(0); |
367 |
1 |
clickMenu(MENU_MACRO); |
368 |
1 |
assertTrue(isMenuEnabled(MENU_COLLAPSE)); |
369 |
1 |
assertFalse(isMenuEnabled(MENU_EXPAND)); |
370 |
1 |
clickMenu(MENU_COLLAPSE); |
371 |
|
|
372 |
|
|
373 |
1 |
clickMenu(MENU_MACRO); |
374 |
1 |
assertFalse(isMenuEnabled(MENU_COLLAPSE)); |
375 |
1 |
assertTrue(isMenuEnabled(MENU_EXPAND)); |
376 |
1 |
clickMenu(MENU_EXPAND); |
377 |
|
|
378 |
|
|
379 |
1 |
getSelenium().controlKeyDown(); |
380 |
1 |
selectMacro(1); |
381 |
1 |
getSelenium().controlKeyUp(); |
382 |
|
|
383 |
|
|
384 |
1 |
clickMenu(MENU_MACRO); |
385 |
1 |
assertTrue(isMenuEnabled(MENU_COLLAPSE)); |
386 |
1 |
assertFalse(isMenuEnabled(MENU_EXPAND)); |
387 |
1 |
clickMenu(MENU_COLLAPSE); |
388 |
|
|
389 |
|
|
390 |
1 |
clickMenu(MENU_MACRO); |
391 |
1 |
assertFalse(isMenuEnabled(MENU_COLLAPSE)); |
392 |
1 |
assertTrue(isMenuEnabled(MENU_EXPAND)); |
393 |
|
|
394 |
|
|
395 |
1 |
clickMenu(MENU_EXPAND); |
396 |
|
|
397 |
|
|
398 |
1 |
clickMenu(MENU_MACRO); |
399 |
1 |
assertTrue(isMenuEnabled(MENU_COLLAPSE)); |
400 |
1 |
assertFalse(isMenuEnabled(MENU_EXPAND)); |
401 |
1 |
closeMenuContaining(MENU_COLLAPSE); |
402 |
|
} |
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
408 |
1 |
@Test... |
409 |
|
public void testClickToSelectMacroAndToggleCollapse() |
410 |
|
{ |
411 |
|
|
412 |
1 |
switchToSource(); |
413 |
1 |
setSourceText("{{foo}}bar{{/foo}}"); |
414 |
1 |
switchToWysiwyg(); |
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
1 |
selectRichTextAreaFrame(); |
420 |
1 |
try { |
421 |
1 |
assertFalse(getSelenium().isVisible(getMacroPlaceHolderLocator(0))); |
422 |
1 |
assertTrue(getSelenium().isVisible(getMacroOutputLocator(0))); |
423 |
|
} finally { |
424 |
1 |
selectTopFrame(); |
425 |
|
} |
426 |
|
|
427 |
|
|
428 |
1 |
selectMacro(0); |
429 |
|
|
430 |
|
|
431 |
1 |
toggleMacroCollapsedState(); |
432 |
1 |
selectRichTextAreaFrame(); |
433 |
1 |
try { |
434 |
1 |
assertTrue(getSelenium().isVisible(getMacroPlaceHolderLocator(0))); |
435 |
1 |
assertFalse(getSelenium().isVisible(getMacroOutputLocator(0))); |
436 |
|
} finally { |
437 |
1 |
selectTopFrame(); |
438 |
|
} |
439 |
|
|
440 |
|
|
441 |
1 |
toggleMacroCollapsedState(); |
442 |
1 |
selectRichTextAreaFrame(); |
443 |
1 |
try { |
444 |
1 |
assertFalse(getSelenium().isVisible(getMacroPlaceHolderLocator(0))); |
445 |
1 |
assertTrue(getSelenium().isVisible(getMacroOutputLocator(0))); |
446 |
|
} finally { |
447 |
1 |
selectTopFrame(); |
448 |
|
} |
449 |
|
} |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
454 |
1 |
@Test... |
455 |
|
public void testRefreshContentWithoutMacros() |
456 |
|
{ |
457 |
1 |
String text = "a b"; |
458 |
1 |
typeText(text); |
459 |
1 |
assertEquals(text, getRichTextArea().getText()); |
460 |
|
|
461 |
|
|
462 |
1 |
refreshMacros(); |
463 |
1 |
assertEquals(text, getRichTextArea().getText()); |
464 |
|
} |
465 |
|
|
466 |
|
|
467 |
|
|
468 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
469 |
1 |
@Test... |
470 |
|
public void testRefreshMacros() |
471 |
|
{ |
472 |
1 |
switchToSource(); |
473 |
1 |
setSourceText("{{box}}p{{/box}}\n\n{{code}}q{{/code}}"); |
474 |
1 |
switchToWysiwyg(); |
475 |
|
|
476 |
|
|
477 |
1 |
selectRichTextAreaFrame(); |
478 |
1 |
try { |
479 |
1 |
assertFalse(getSelenium().isVisible(getMacroPlaceHolderLocator(1))); |
480 |
1 |
assertTrue(getSelenium().isVisible(getMacroOutputLocator(1))); |
481 |
|
} finally { |
482 |
1 |
selectTopFrame(); |
483 |
|
} |
484 |
1 |
selectMacro(1); |
485 |
1 |
toggleMacroCollapsedState(); |
486 |
1 |
selectRichTextAreaFrame(); |
487 |
1 |
try { |
488 |
1 |
assertTrue(getSelenium().isVisible(getMacroPlaceHolderLocator(1))); |
489 |
1 |
assertFalse(getSelenium().isVisible(getMacroOutputLocator(1))); |
490 |
|
} finally { |
491 |
1 |
selectTopFrame(); |
492 |
|
} |
493 |
|
|
494 |
|
|
495 |
1 |
clearMacroSelection(); |
496 |
|
|
497 |
|
|
498 |
1 |
refreshMacros(); |
499 |
|
|
500 |
|
|
501 |
1 |
selectRichTextAreaFrame(); |
502 |
1 |
try { |
503 |
1 |
assertFalse(getSelenium().isVisible(getMacroPlaceHolderLocator(1))); |
504 |
1 |
assertTrue(getSelenium().isVisible(getMacroOutputLocator(1))); |
505 |
|
} finally { |
506 |
1 |
selectTopFrame(); |
507 |
|
} |
508 |
|
} |
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
513 |
1 |
@Test... |
514 |
|
public void testRefreshTocMacro() |
515 |
|
{ |
516 |
1 |
switchToSource(); |
517 |
1 |
setSourceText("{{toc start=\"1\"/}}\n\n= Title 1\n\n== Title 2"); |
518 |
1 |
switchToWysiwyg(); |
519 |
|
|
520 |
|
|
521 |
1 |
String listItemCountExpression = "return document.getElementsByTagName('li').length"; |
522 |
1 |
assertEquals(2L, getRichTextArea().executeScript(listItemCountExpression)); |
523 |
|
|
524 |
|
|
525 |
1 |
moveCaret("document.getElementsByTagName('h2')[0].firstChild.firstChild", 7); |
526 |
|
|
527 |
1 |
waitForSelectedMacroCount(0); |
528 |
1 |
typeEnter(); |
529 |
1 |
typeText("Title 3"); |
530 |
1 |
applyStyleTitle3(); |
531 |
|
|
532 |
|
|
533 |
1 |
refreshMacros(); |
534 |
|
|
535 |
|
|
536 |
1 |
assertEquals(3L, getRichTextArea().executeScript(listItemCountExpression)); |
537 |
|
} |
538 |
|
|
539 |
|
|
540 |
|
|
541 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
542 |
1 |
@Test... |
543 |
|
public void testEditHTMLMacro() |
544 |
|
{ |
545 |
1 |
switchToSource(); |
546 |
1 |
setSourceText("{{html}}white{{/html}}"); |
547 |
1 |
switchToWysiwyg(); |
548 |
1 |
editMacro(0); |
549 |
|
|
550 |
|
|
551 |
1 |
setFieldValue("pd-content-input", "black"); |
552 |
|
|
553 |
|
|
554 |
1 |
getSelenium().select("pd-wiki-input", "yes"); |
555 |
|
|
556 |
|
|
557 |
1 |
applyMacroChanges(); |
558 |
|
|
559 |
|
|
560 |
1 |
switchToSource(); |
561 |
1 |
assertSourceText("{{html wiki=\"true\"}}\nblack\n{{/html}}"); |
562 |
1 |
switchToWysiwyg(); |
563 |
|
|
564 |
|
|
565 |
1 |
editMacro(0); |
566 |
|
|
567 |
|
|
568 |
1 |
assertEquals("true", getSelenium().getValue("pd-wiki-input")); |
569 |
1 |
getSelenium().select("pd-wiki-input", "no"); |
570 |
|
|
571 |
|
|
572 |
1 |
applyMacroChanges(); |
573 |
|
|
574 |
|
|
575 |
|
|
576 |
1 |
switchToSource(); |
577 |
1 |
assertSourceText("{{html}}\nblack\n{{/html}}"); |
578 |
|
} |
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
|
585 |
|
@see |
586 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
587 |
1 |
@Test... |
588 |
|
public void testEditMacroWithSpecialCharactersInParameterValues() |
589 |
|
{ |
590 |
1 |
switchToSource(); |
591 |
1 |
setSourceText("{{box title = \"1~\"2|-|3=~~~\"4~~\" }}=~\"|-|~~{{/box}}"); |
592 |
1 |
switchToWysiwyg(); |
593 |
1 |
editMacro(0); |
594 |
|
|
595 |
|
|
596 |
1 |
assertEquals("=~\"|-|~~", getSelenium().getValue("pd-content-input")); |
597 |
|
|
598 |
|
|
599 |
1 |
assertEquals("1\"2|-|3=~\"4~", getSelenium().getValue("pd-title-input")); |
600 |
|
|
601 |
|
|
602 |
1 |
setFieldValue("pd-title-input", "a\"b|-|c=~\"d~"); |
603 |
1 |
applyMacroChanges(); |
604 |
|
|
605 |
1 |
switchToSource(); |
606 |
1 |
assertSourceText("{{box title=\"a~\"b|-|c=~~~\"d~~\"}}\n=~\"|-|~~\n{{/box}}"); |
607 |
|
} |
608 |
|
|
609 |
|
|
610 |
|
|
611 |
|
|
612 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
613 |
1 |
@Test... |
614 |
|
public void testEditUnregisteredMacro() |
615 |
|
{ |
616 |
1 |
switchToSource(); |
617 |
1 |
setSourceText("{{foo}}bar{{/foo}}"); |
618 |
1 |
switchToWysiwyg(); |
619 |
1 |
editMacro(0); |
620 |
|
|
621 |
|
|
622 |
1 |
assertTrue(getSelenium().isVisible("//div[@class = 'xDialogBody']/div[contains(@class, 'errormessage')]")); |
623 |
|
} |
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
628 |
1 |
@Test... |
629 |
|
public void testUndoMacroEdit() |
630 |
|
{ |
631 |
1 |
switchToSource(); |
632 |
1 |
setSourceText("{{velocity}}$xcontext.user{{/velocity}}"); |
633 |
1 |
switchToWysiwyg(); |
634 |
|
|
635 |
|
|
636 |
1 |
editMacro(0); |
637 |
1 |
setFieldValue("pd-content-input", "$datetool.date"); |
638 |
1 |
applyMacroChanges(); |
639 |
|
|
640 |
|
|
641 |
1 |
editMacro(0); |
642 |
1 |
setFieldValue("pd-content-input", "$xwiki.version"); |
643 |
1 |
applyMacroChanges(); |
644 |
|
|
645 |
1 |
waitForPushButton(TOOLBAR_BUTTON_UNDO_TITLE, true); |
646 |
1 |
clickUndoButton(2); |
647 |
1 |
waitForPushButton(TOOLBAR_BUTTON_REDO_TITLE, true); |
648 |
1 |
clickRedoButton(); |
649 |
1 |
switchToSource(); |
650 |
1 |
assertSourceText("{{velocity}}\n$datetool.date\n{{/velocity}}"); |
651 |
|
} |
652 |
|
|
653 |
|
|
654 |
|
|
655 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
656 |
1 |
@Test... |
657 |
|
public void testInsertCodeMacro() |
658 |
|
{ |
659 |
1 |
insertMacro("Code"); |
660 |
|
|
661 |
1 |
setFieldValue("pd-content-input", "function f(x) {\n return x;\n}"); |
662 |
1 |
applyMacroChanges(); |
663 |
|
|
664 |
1 |
editMacro(0); |
665 |
1 |
setFieldValue("pd-title-input", "Identity function"); |
666 |
1 |
applyMacroChanges(); |
667 |
|
|
668 |
1 |
switchToSource(); |
669 |
1 |
assertSourceText("{{code title=\"Identity function\"}}\nfunction f(x) {\n return x;\n}\n{{/code}}"); |
670 |
|
} |
671 |
|
|
672 |
|
|
673 |
|
|
674 |
|
|
675 |
|
|
676 |
|
@see |
677 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
678 |
1 |
@Test... |
679 |
|
public void testInsertTOCMacro() |
680 |
|
{ |
681 |
|
|
682 |
1 |
typeText("Title 1"); |
683 |
1 |
applyStyleTitle1(); |
684 |
|
|
685 |
1 |
typeEnter(); |
686 |
1 |
typeText("Title 2"); |
687 |
1 |
applyStyleTitle2(); |
688 |
|
|
689 |
|
|
690 |
|
|
691 |
1 |
moveCaret("document.body.getElementsByTagName('h1')[0].firstChild", 7); |
692 |
|
|
693 |
1 |
typeEnter(); |
694 |
|
|
695 |
1 |
insertMacro("Table Of Contents"); |
696 |
|
|
697 |
1 |
setFieldValue("pd-start-input", "2"); |
698 |
1 |
applyMacroChanges(); |
699 |
|
|
700 |
|
|
701 |
1 |
assertEquals(1L, getRichTextArea().executeScript("return document.getElementsByTagName('li').length")); |
702 |
|
|
703 |
|
|
704 |
1 |
switchToSource(); |
705 |
1 |
assertSourceText("= Title 1 =\n\n\n{{toc start=\"2\"/}}\n\n\n== Title 2 =="); |
706 |
|
} |
707 |
|
|
708 |
|
|
709 |
|
@see |
710 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
711 |
1 |
@Test... |
712 |
|
public void testInsertStandAloneMacroInline() |
713 |
|
{ |
714 |
1 |
switchToSource(); |
715 |
1 |
setSourceText("= Heading =\n\nparagraph"); |
716 |
1 |
switchToWysiwyg(); |
717 |
|
|
718 |
|
|
719 |
1 |
moveCaret("document.body.lastChild.firstChild", 4); |
720 |
|
|
721 |
|
|
722 |
1 |
insertMacro("Table Of Contents"); |
723 |
1 |
applyMacroChanges(); |
724 |
|
|
725 |
|
|
726 |
1 |
assertEquals(1L, getRichTextArea().executeScript("return document.getElementsByTagName('li').length")); |
727 |
|
|
728 |
|
|
729 |
1 |
switchToSource(); |
730 |
1 |
assertSourceText("= Heading =\n\npara\n\n{{toc/}}\n\ngraph"); |
731 |
|
} |
732 |
|
|
733 |
|
|
734 |
|
|
735 |
|
|
736 |
|
|
737 |
|
@see |
738 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
739 |
1 |
@Test... |
740 |
|
public void testInsertHTMLMacroWithBlockContentInANotEmptyParagraph() |
741 |
|
{ |
742 |
|
|
743 |
1 |
typeText("beforeafter"); |
744 |
1 |
applyStyleTitle1(); |
745 |
1 |
applyStylePlainText(); |
746 |
|
|
747 |
|
|
748 |
1 |
moveCaret("document.body.firstChild.firstChild", 6); |
749 |
|
|
750 |
|
|
751 |
1 |
insertMacro("HTML"); |
752 |
|
|
753 |
1 |
setFieldValue("pd-content-input", "<ul><li>xwiki</li></ul>"); |
754 |
1 |
applyMacroChanges(); |
755 |
|
|
756 |
|
|
757 |
1 |
String listItemCountExpression = "return document.getElementsByTagName('li').length"; |
758 |
1 |
assertEquals(0L, getRichTextArea().executeScript(listItemCountExpression)); |
759 |
|
|
760 |
|
|
761 |
|
|
762 |
1 |
moveCaret("document.body.firstChild.firstChild", 6); |
763 |
1 |
typeEnter(); |
764 |
|
|
765 |
1 |
moveCaret("document.body.lastChild.lastChild", 0); |
766 |
1 |
typeEnter(); |
767 |
|
|
768 |
|
|
769 |
|
|
770 |
1 |
refreshMacros(); |
771 |
|
|
772 |
1 |
assertEquals(1L, getRichTextArea().executeScript(listItemCountExpression)); |
773 |
|
|
774 |
|
|
775 |
1 |
switchToSource(); |
776 |
1 |
assertSourceText("before\n\n{{html}}\n<ul><li>xwiki</li></ul>\n{{/html}}\n\nafter"); |
777 |
|
} |
778 |
|
|
779 |
|
|
780 |
|
@see |
781 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
782 |
1 |
@Test... |
783 |
|
public void testInsertCodeMacroWithXMLComments() |
784 |
|
{ |
785 |
|
|
786 |
1 |
insertMacro("Code"); |
787 |
|
|
788 |
1 |
setFieldValue("pd-language-input", "xml"); |
789 |
|
|
790 |
1 |
setFieldValue("pd-content-input", |
791 |
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- this is a test -->\n<test>123</test>"); |
792 |
1 |
applyMacroChanges(); |
793 |
|
|
794 |
|
|
795 |
1 |
switchToSource(); |
796 |
1 |
assertSourceText("{{code language=\"xml\"}}\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
797 |
|
+ "<!-- this is a test -->\n<test>123</test>\n{{/code}}"); |
798 |
1 |
switchToWysiwyg(); |
799 |
|
|
800 |
|
|
801 |
1 |
editMacro(0); |
802 |
1 |
assertEquals("xml", getSelenium().getValue("pd-language-input")); |
803 |
1 |
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- this is a test -->\n<test>123</test>", |
804 |
|
getSelenium().getValue("pd-content-input")); |
805 |
1 |
closeDialog(); |
806 |
|
} |
807 |
|
|
808 |
|
|
809 |
|
@see |
810 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
811 |
1 |
@Test... |
812 |
|
public void testDetectMacroParameterNamesIgnoringCase() |
813 |
|
{ |
814 |
1 |
switchToSource(); |
815 |
1 |
setSourceText("{{box CSSClaSS=\"foo\"}}bar{{/box}}"); |
816 |
1 |
switchToWysiwyg(); |
817 |
|
|
818 |
1 |
editMacro(0); |
819 |
|
|
820 |
1 |
assertEquals("foo", getSelenium().getValue("pd-cssClass-input")); |
821 |
|
|
822 |
1 |
setFieldValue("pd-cssClass-input", "xyz"); |
823 |
1 |
applyMacroChanges(); |
824 |
|
|
825 |
1 |
switchToSource(); |
826 |
1 |
assertSourceText("{{box CSSClaSS=\"xyz\"}}\nbar\n{{/box}}"); |
827 |
|
} |
828 |
|
|
829 |
|
|
830 |
|
@see |
831 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
832 |
1 |
@Test... |
833 |
|
public void testDifferentiateMacrosWithEmptyContentFromMacrosWithoutContent() |
834 |
|
{ |
835 |
1 |
StringBuffer macros = new StringBuffer(); |
836 |
1 |
macros.append("{{code/}}"); |
837 |
1 |
macros.append("{{code}}{{/code}}"); |
838 |
1 |
macros.append("{{code title=\"1|-|2\"/}}"); |
839 |
1 |
macros.append("{{code title=\"1|-|2\"}}{{/code}}"); |
840 |
|
|
841 |
|
|
842 |
1 |
switchToSource(); |
843 |
1 |
setSourceText(macros.toString()); |
844 |
1 |
switchToWysiwyg(); |
845 |
|
|
846 |
1 |
switchToSource(); |
847 |
1 |
assertSourceText(macros.toString()); |
848 |
1 |
switchToWysiwyg(); |
849 |
|
|
850 |
|
|
851 |
1 |
editMacro(0); |
852 |
1 |
setFieldValue("pd-content-input", "|-|"); |
853 |
1 |
applyMacroChanges(); |
854 |
1 |
switchToSource(); |
855 |
1 |
assertSourceText("{{code}}|-|{{/code}}{{code}}{{/code}}{{code title=\"1|-|2\"/}}{{code title=\"1|-|2\"}}{{/code}}"); |
856 |
1 |
switchToWysiwyg(); |
857 |
|
|
858 |
|
|
859 |
1 |
editMacro(1); |
860 |
1 |
setFieldValue("pd-title-input", "|-|"); |
861 |
1 |
setFieldValue("pd-content-input", "|-|"); |
862 |
1 |
applyMacroChanges(); |
863 |
|
|
864 |
|
|
865 |
1 |
editMacro(2); |
866 |
1 |
setFieldValue("pd-title-input", ""); |
867 |
1 |
setFieldValue("pd-content-input", "|-|"); |
868 |
1 |
applyMacroChanges(); |
869 |
|
|
870 |
|
|
871 |
1 |
editMacro(3); |
872 |
1 |
setFieldValue("pd-content-input", "|-|"); |
873 |
1 |
applyMacroChanges(); |
874 |
|
|
875 |
|
|
876 |
1 |
switchToSource(); |
877 |
1 |
assertSourceText("{{code}}|-|{{/code}}{{code title=\"|-|\"}}|-|{{/code}}" |
878 |
|
+ "{{code}}|-|{{/code}}{{code title=\"1|-|2\"}}|-|{{/code}}"); |
879 |
|
} |
880 |
|
|
881 |
|
|
882 |
|
@see |
883 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
884 |
1 |
@Test... |
885 |
|
public void testNestedMacrosAreNotDuplicated() |
886 |
|
{ |
887 |
1 |
StringBuilder content = new StringBuilder(); |
888 |
1 |
content.append("{{html wiki=\"true\"}}\n\n"); |
889 |
1 |
content.append("= Hello title 1 =\n\n"); |
890 |
1 |
content.append("{{toc start=\"2\"/}}\n\n"); |
891 |
1 |
content.append("= Hello title 2 =\n\n"); |
892 |
1 |
content.append("{{/html}}"); |
893 |
1 |
switchToSource(); |
894 |
1 |
setSourceText(content.toString()); |
895 |
1 |
switchToWysiwyg(); |
896 |
|
|
897 |
|
|
898 |
1 |
assertEquals(1, getMacroCount()); |
899 |
|
|
900 |
|
|
901 |
1 |
deleteMacro(0); |
902 |
1 |
switchToSource(); |
903 |
1 |
assertSourceText(""); |
904 |
|
|
905 |
|
|
906 |
1 |
setSourceText(content.toString()); |
907 |
1 |
switchToWysiwyg(); |
908 |
|
|
909 |
|
|
910 |
1 |
switchToSource(); |
911 |
1 |
assertSourceText(content.toString()); |
912 |
|
} |
913 |
|
|
914 |
|
|
915 |
|
@see |
916 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
917 |
1 |
@Test... |
918 |
|
public void testDoubleClickToSelectMacroToInsert() |
919 |
|
{ |
920 |
1 |
openSelectMacroDialog(); |
921 |
|
|
922 |
|
|
923 |
|
|
924 |
1 |
waitForMacroListItem("Info Message", true); |
925 |
|
|
926 |
1 |
getSelenium().click(getMacroListItemLocator("Info Message")); |
927 |
|
|
928 |
1 |
getSelenium().doubleClick(getMacroListItemLocator("Info Message")); |
929 |
1 |
waitForDialogToLoad(); |
930 |
|
|
931 |
|
|
932 |
1 |
setFieldValue("pd-content-input", "x"); |
933 |
1 |
applyMacroChanges(); |
934 |
|
|
935 |
|
|
936 |
1 |
switchToSource(); |
937 |
1 |
assertSourceText("{{info}}\nx\n{{/info}}"); |
938 |
|
} |
939 |
|
|
940 |
|
|
941 |
|
@see |
942 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
943 |
1 |
@Test... |
944 |
|
public void testPressEnterToSelectMacroToInsert() |
945 |
|
{ |
946 |
1 |
openSelectMacroDialog(); |
947 |
|
|
948 |
|
|
949 |
|
|
950 |
1 |
waitForMacroListItem("HTML", true); |
951 |
|
|
952 |
1 |
getSelenium().click(getMacroListItemLocator("HTML")); |
953 |
|
|
954 |
1 |
getSelenium().typeKeys("//div[@class = 'xListBox']", "\\13"); |
955 |
1 |
waitForDialogToLoad(); |
956 |
|
|
957 |
|
|
958 |
1 |
setFieldValue("pd-content-input", "a"); |
959 |
1 |
applyMacroChanges(); |
960 |
|
|
961 |
|
|
962 |
1 |
switchToSource(); |
963 |
1 |
assertSourceText("{{html}}\na\n{{/html}}"); |
964 |
|
} |
965 |
|
|
966 |
|
|
967 |
|
@see |
968 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
969 |
1 |
@Test... |
970 |
|
public void testDoubleClickToEditMacro() |
971 |
|
{ |
972 |
|
|
973 |
1 |
switchToSource(); |
974 |
1 |
setSourceText("{{error}}x{{/error}}{{info}}y{{/info}}"); |
975 |
1 |
switchToWysiwyg(); |
976 |
|
|
977 |
|
|
978 |
1 |
selectRichTextAreaFrame(); |
979 |
1 |
try { |
980 |
1 |
String infoMacroLocator = getMacroLocator(1); |
981 |
1 |
waitForElement(infoMacroLocator); |
982 |
1 |
getSelenium().doubleClick(infoMacroLocator); |
983 |
|
} finally { |
984 |
1 |
selectTopFrame(); |
985 |
|
} |
986 |
1 |
waitForDialogToLoad(); |
987 |
|
|
988 |
|
|
989 |
1 |
setFieldValue("pd-content-input", "z"); |
990 |
1 |
applyMacroChanges(); |
991 |
|
|
992 |
|
|
993 |
1 |
switchToSource(); |
994 |
1 |
assertSourceText("{{error}}x{{/error}}{{info}}z{{/info}}"); |
995 |
|
} |
996 |
|
|
997 |
|
|
998 |
|
|
999 |
|
|
1000 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
1001 |
1 |
@Test... |
1002 |
|
public void testDoubleClickToEditMacroWhenDOMSelectionWrapsTheMacroContainer() |
1003 |
|
{ |
1004 |
|
|
1005 |
1 |
switchToSource(); |
1006 |
1 |
setSourceText("before {{error}}currently{{/error}} after"); |
1007 |
1 |
switchToWysiwyg(); |
1008 |
|
|
1009 |
|
|
1010 |
1 |
selectRichTextAreaFrame(); |
1011 |
1 |
try { |
1012 |
|
|
1013 |
1 |
getSelenium().doubleClick(getMacroLocator(0)); |
1014 |
|
} finally { |
1015 |
1 |
selectTopFrame(); |
1016 |
|
} |
1017 |
1 |
waitForDialogToLoad(); |
1018 |
|
|
1019 |
|
|
1020 |
1 |
setFieldValue("pd-content-input", "now"); |
1021 |
1 |
applyMacroChanges(); |
1022 |
|
|
1023 |
|
|
1024 |
1 |
switchToSource(); |
1025 |
1 |
assertSourceText("before {{error}}now{{/error}} after"); |
1026 |
|
} |
1027 |
|
|
1028 |
|
|
1029 |
|
@see |
1030 |
|
|
|
|
| 91.7% |
Uncovered Elements: 1 (12) |
Complexity: 2 |
Complexity Density: 0.17 |
1PASS
|
|
1031 |
1 |
@Test... |
1032 |
|
public void testDoubleClickOutsideSelectedMacro() |
1033 |
|
{ |
1034 |
|
|
1035 |
1 |
switchToSource(); |
1036 |
|
|
1037 |
|
|
1038 |
|
|
1039 |
1 |
setSourceText("(% id=\"outside\" %)after\n\n{{info}}before{{/info}}"); |
1040 |
1 |
switchToWysiwyg(); |
1041 |
|
|
1042 |
|
|
1043 |
1 |
selectMacro(0); |
1044 |
1 |
waitForSelectedMacroCount(1); |
1045 |
|
|
1046 |
|
|
1047 |
1 |
selectRichTextAreaFrame(); |
1048 |
1 |
try { |
1049 |
1 |
getSelenium().doubleClick("document.getElementById('outside')"); |
1050 |
|
} finally { |
1051 |
1 |
selectTopFrame(); |
1052 |
|
} |
1053 |
|
|
1054 |
1 |
try { |
1055 |
1 |
waitForDialogToLoad(); |
1056 |
0 |
fail("The macro edit box shouldn't be triggered by double clicking outside of the macro output."); |
1057 |
|
} catch (TimeoutException e) { |
1058 |
|
|
1059 |
|
} |
1060 |
|
} |
1061 |
|
|
1062 |
|
|
1063 |
|
@see |
1064 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
1065 |
1 |
@Test... |
1066 |
|
public void testSelectMacroFromCategory() |
1067 |
|
{ |
1068 |
1 |
openSelectMacroDialog(); |
1069 |
|
|
1070 |
|
|
1071 |
1 |
assertEquals("All Macros", getSelectedMacroCategory()); |
1072 |
|
|
1073 |
|
|
1074 |
1 |
waitForMacroListItem("Code", true); |
1075 |
1 |
waitForMacroListItem("Velocity", true); |
1076 |
|
|
1077 |
|
|
1078 |
1 |
selectMacroCategory("Formatting"); |
1079 |
1 |
waitForMacroListItem("Code", true); |
1080 |
1 |
waitForMacroListItem("Velocity", false); |
1081 |
|
|
1082 |
|
|
1083 |
1 |
selectMacroCategory("Development"); |
1084 |
1 |
waitForMacroListItem("Velocity", true); |
1085 |
1 |
waitForMacroListItem("Code", false); |
1086 |
|
|
1087 |
|
|
1088 |
1 |
getSelenium().click(getMacroListItemLocator("Velocity")); |
1089 |
1 |
getSelenium().click("//div[@class = 'xDialogFooter']/button[text() = 'Select']"); |
1090 |
1 |
waitForDialogToLoad(); |
1091 |
|
|
1092 |
|
|
1093 |
1 |
setFieldValue("pd-content-input", "$xwiki.version"); |
1094 |
1 |
applyMacroChanges(); |
1095 |
|
|
1096 |
|
|
1097 |
1 |
openSelectMacroDialog(); |
1098 |
1 |
assertEquals("Development", getSelectedMacroCategory()); |
1099 |
1 |
closeDialog(); |
1100 |
|
|
1101 |
|
|
1102 |
1 |
switchToSource(); |
1103 |
1 |
assertSourceText("{{velocity}}\n$xwiki.version\n{{/velocity}}"); |
1104 |
|
} |
1105 |
|
|
1106 |
|
|
1107 |
|
@see |
1108 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
1109 |
1 |
@Test... |
1110 |
|
public void testFilterMacrosFromCategory() |
1111 |
|
{ |
1112 |
1 |
openSelectMacroDialog(); |
1113 |
|
|
1114 |
|
|
1115 |
1 |
selectMacroCategory("All Macros"); |
1116 |
|
|
1117 |
|
|
1118 |
1 |
waitForMacroListItem("Velocity", true); |
1119 |
1 |
waitForMacroListItem("Footnote", true); |
1120 |
1 |
waitForMacroListItem("Error Message", true); |
1121 |
|
|
1122 |
|
|
1123 |
1 |
int expectedMacroCountAfterFilterAllMacros = getMacroListItemCount("note"); |
1124 |
1 |
assertTrue(expectedMacroCountAfterFilterAllMacros < getMacroListItemCount()); |
1125 |
|
|
1126 |
|
|
1127 |
1 |
filterMacrosContaining("note"); |
1128 |
|
|
1129 |
|
|
1130 |
1 |
waitForMacroListItem("Velocity", false); |
1131 |
1 |
waitForMacroListItem("Error Message", true); |
1132 |
|
|
1133 |
|
|
1134 |
1 |
assertEquals(expectedMacroCountAfterFilterAllMacros, getMacroListItemCount()); |
1135 |
|
|
1136 |
|
|
1137 |
|
|
1138 |
1 |
selectMacroCategory("Content"); |
1139 |
1 |
waitForMacroListItem("Footnote", true); |
1140 |
1 |
waitForMacroListItem("Error Message", false); |
1141 |
|
|
1142 |
1 |
selectMacroCategory("Formatting"); |
1143 |
1 |
waitForMacroListItem("Error Message", true); |
1144 |
1 |
waitForMacroListItem("Footnote", false); |
1145 |
|
|
1146 |
|
|
1147 |
1 |
int previousMacroListItemCount = getMacroListItemCount(); |
1148 |
|
|
1149 |
|
|
1150 |
1 |
getSelenium().click(getMacroListItemLocator("Error Message")); |
1151 |
1 |
getSelenium().click("//div[@class = 'xDialogFooter']/button[text() = 'Select']"); |
1152 |
1 |
waitForDialogToLoad(); |
1153 |
|
|
1154 |
|
|
1155 |
1 |
setFieldValue("pd-content-input", "test"); |
1156 |
1 |
applyMacroChanges(); |
1157 |
|
|
1158 |
|
|
1159 |
1 |
openSelectMacroDialog(); |
1160 |
1 |
waitForMacroListItem("Error Message", true); |
1161 |
1 |
assertEquals("note", getMacroFilterValue()); |
1162 |
1 |
assertEquals(previousMacroListItemCount, getMacroListItemCount()); |
1163 |
1 |
assertEquals(previousMacroListItemCount, getMacroListItemCount("note")); |
1164 |
1 |
closeDialog(); |
1165 |
|
|
1166 |
|
|
1167 |
1 |
switchToSource(); |
1168 |
1 |
assertSourceText("{{error}}\ntest\n{{/error}}"); |
1169 |
|
} |
1170 |
|
|
1171 |
|
|
1172 |
|
@see |
1173 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
1174 |
1 |
@Test... |
1175 |
|
public void testReturnToSelectMacroStep() |
1176 |
|
{ |
1177 |
1 |
openSelectMacroDialog(); |
1178 |
1 |
waitForMacroListItem("Velocity", true); |
1179 |
|
|
1180 |
|
|
1181 |
1 |
int scriptMacroCount = getMacroListItemCount("script"); |
1182 |
1 |
selectMacroCategory("Development"); |
1183 |
1 |
filterMacrosContaining("script"); |
1184 |
1 |
waitForMacroListItemCount(scriptMacroCount); |
1185 |
|
|
1186 |
|
|
1187 |
1 |
getSelenium().click(getMacroListItemLocator("Groovy")); |
1188 |
1 |
getSelenium().click("//div[@class = 'xDialogFooter']/button[text() = 'Select']"); |
1189 |
1 |
waitForDialogToLoad(); |
1190 |
|
|
1191 |
|
|
1192 |
1 |
getSelenium().click("//div[@class = 'xDialogContent']//button[text() = 'Previous']"); |
1193 |
1 |
waitForDialogToLoad(); |
1194 |
|
|
1195 |
|
|
1196 |
1 |
assertEquals("Development", getSelectedMacroCategory()); |
1197 |
1 |
assertEquals("script", getMacroFilterValue()); |
1198 |
|
|
1199 |
|
|
1200 |
1 |
waitForMacroListItem("Velocity", true); |
1201 |
1 |
getSelenium().click(getMacroListItemLocator("Velocity")); |
1202 |
1 |
getSelenium().click("//div[@class = 'xDialogFooter']/button[text() = 'Select']"); |
1203 |
1 |
waitForDialogToLoad(); |
1204 |
|
|
1205 |
|
|
1206 |
1 |
setFieldValue("pd-content-input", "$xcontext.user"); |
1207 |
1 |
applyMacroChanges(); |
1208 |
|
|
1209 |
|
|
1210 |
1 |
switchToSource(); |
1211 |
1 |
assertSourceText("{{velocity}}\n$xcontext.user\n{{/velocity}}"); |
1212 |
|
} |
1213 |
|
|
1214 |
|
|
1215 |
|
|
1216 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (32) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
1217 |
1 |
@Test... |
1218 |
|
public void testValidateSelectMacroStep() |
1219 |
|
{ |
1220 |
1 |
openSelectMacroDialog(); |
1221 |
|
|
1222 |
1 |
waitForMacroListItem("Velocity", true); |
1223 |
|
|
1224 |
1 |
assertFalse(isMacroListItemSelected()); |
1225 |
|
|
1226 |
1 |
assertFieldErrorIsNotPresent(); |
1227 |
|
|
1228 |
1 |
getSelenium().click("//div[@class = 'xDialogFooter']/button[text() = 'Select']"); |
1229 |
|
|
1230 |
1 |
assertFieldErrorIsPresent("Please select a macro from the list below.", MACRO_SELECTOR_LIST); |
1231 |
|
|
1232 |
|
|
1233 |
1 |
selectMacroCategory("Navigation"); |
1234 |
|
|
1235 |
1 |
waitForMacroListItem("Velocity", false); |
1236 |
|
|
1237 |
1 |
assertFalse(isMacroListItemSelected()); |
1238 |
|
|
1239 |
1 |
assertFieldErrorIsNotPresent(); |
1240 |
|
|
1241 |
1 |
getSelenium().click("//div[@class = 'xDialogFooter']/button[text() = 'Select']"); |
1242 |
|
|
1243 |
1 |
assertFieldErrorIsPresent("Please select a macro from the list below.", MACRO_SELECTOR_LIST); |
1244 |
|
|
1245 |
|
|
1246 |
1 |
filterMacrosContaining("anchor"); |
1247 |
|
|
1248 |
1 |
waitForMacroListItem("Table Of Contents", false); |
1249 |
|
|
1250 |
1 |
assertFalse(isMacroListItemSelected()); |
1251 |
|
|
1252 |
1 |
assertFieldErrorIsNotPresent(); |
1253 |
|
|
1254 |
1 |
getSelenium().click("//div[@class = 'xDialogFooter']/button[text() = 'Select']"); |
1255 |
|
|
1256 |
1 |
assertFieldErrorIsPresent("Please select a macro from the list below.", MACRO_SELECTOR_LIST); |
1257 |
|
|
1258 |
|
|
1259 |
1 |
closeDialog(); |
1260 |
1 |
openSelectMacroDialog(); |
1261 |
1 |
assertFieldErrorIsNotPresent(); |
1262 |
|
|
1263 |
1 |
assertFalse(isMacroListItemSelected()); |
1264 |
|
|
1265 |
1 |
getSelenium().click("//div[@class = 'xDialogFooter']/button[text() = 'Select']"); |
1266 |
|
|
1267 |
1 |
assertFieldErrorIsPresent("Please select a macro from the list below.", MACRO_SELECTOR_LIST); |
1268 |
|
|
1269 |
|
|
1270 |
1 |
getSelenium().click(getMacroListItemLocator("Id")); |
1271 |
1 |
getSelenium().click("//div[@class = 'xDialogFooter']/button[text() = 'Select']"); |
1272 |
1 |
waitForDialogToLoad(); |
1273 |
|
|
1274 |
|
|
1275 |
1 |
assertFieldErrorIsNotPresent(); |
1276 |
|
|
1277 |
|
|
1278 |
1 |
setFieldValue("pd-name-input", "foo"); |
1279 |
1 |
applyMacroChanges(); |
1280 |
|
|
1281 |
|
|
1282 |
1 |
switchToSource(); |
1283 |
1 |
assertSourceText("{{id name=\"foo\"/}}"); |
1284 |
|
} |
1285 |
|
|
1286 |
|
|
1287 |
|
|
1288 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
1289 |
1 |
@Test... |
1290 |
|
public void testSelectFromPreviouslyInsertedMacros() |
1291 |
|
{ |
1292 |
1 |
openSelectMacroDialog(); |
1293 |
|
|
1294 |
|
|
1295 |
1 |
selectMacroCategory("Previously Inserted Macros"); |
1296 |
1 |
waitForMacroListItemCount(0); |
1297 |
|
|
1298 |
|
|
1299 |
1 |
selectMacroCategory("All Macros"); |
1300 |
1 |
waitForMacroListItem("HTML", true); |
1301 |
1 |
getSelenium().click(getMacroListItemLocator("HTML")); |
1302 |
1 |
getSelenium().click("//div[@class = 'xDialogFooter']/button[text() = 'Select']"); |
1303 |
1 |
waitForDialogToLoad(); |
1304 |
1 |
setFieldValue("pd-content-input", "xwiki"); |
1305 |
1 |
applyMacroChanges(); |
1306 |
|
|
1307 |
|
|
1308 |
1 |
openSelectMacroDialog(); |
1309 |
1 |
selectMacroCategory("Previously Inserted Macros"); |
1310 |
|
|
1311 |
1 |
waitForMacroListItemCount(1); |
1312 |
|
|
1313 |
1 |
assertFalse(getDriver().hasElementWithoutWaiting(By.xpath(getMacroListItemLocator("Velocity")))); |
1314 |
1 |
assertTrue(getDriver().hasElementWithoutWaiting(By.xpath(getMacroListItemLocator("HTML")))); |
1315 |
|
|
1316 |
|
|
1317 |
1 |
closeDialog(); |
1318 |
1 |
switchToSource(); |
1319 |
1 |
assertSourceText("{{html}}\nxwiki\n{{/html}}"); |
1320 |
|
} |
1321 |
|
|
1322 |
|
|
1323 |
|
@see |
1324 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
1325 |
1 |
@Test... |
1326 |
|
public void testRefreshContextSensitiveVelocity() |
1327 |
|
{ |
1328 |
1 |
switchToSource(); |
1329 |
1 |
setSourceText("{{velocity}}$doc.fullName{{/velocity}}"); |
1330 |
1 |
switchToWysiwyg(); |
1331 |
1 |
String expected = getRichTextArea().getText(); |
1332 |
1 |
refreshMacrosUsingShortcutKey(); |
1333 |
1 |
assertEquals(expected, getRichTextArea().getText()); |
1334 |
|
} |
1335 |
|
|
1336 |
|
|
1337 |
|
@see |
1338 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
1339 |
1 |
@Test... |
1340 |
|
public void testLinksArePreservedWhenMacroIsCollapsed() |
1341 |
|
{ |
1342 |
1 |
switchToSource(); |
1343 |
1 |
setSourceText("before\n\n{{velocity}}abc [[123>>http://www.xwiki.org]] xyz{{/velocity}}\n\nafter"); |
1344 |
1 |
switchToWysiwyg(); |
1345 |
|
|
1346 |
1 |
focusRichTextArea(); |
1347 |
|
|
1348 |
1 |
String linkCountExpression = "return document.getElementsByTagName('a').length"; |
1349 |
1 |
assertEquals(1L, getRichTextArea().executeScript(linkCountExpression)); |
1350 |
|
|
1351 |
1 |
selectMacro(0); |
1352 |
|
|
1353 |
1 |
toggleMacroCollapsedState(); |
1354 |
|
|
1355 |
1 |
blurRichTextArea(); |
1356 |
1 |
focusRichTextArea(); |
1357 |
|
|
1358 |
1 |
toggleMacroCollapsedState(); |
1359 |
|
|
1360 |
1 |
assertEquals(1L, getRichTextArea().executeScript(linkCountExpression)); |
1361 |
|
} |
1362 |
|
|
1363 |
|
|
1364 |
|
@see |
1365 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
1366 |
1 |
@Test... |
1367 |
|
public void testHTMLMacroWithStyleTag() |
1368 |
|
{ |
1369 |
1 |
switchToSource(); |
1370 |
1 |
StringBuilder sourceText = new StringBuilder(); |
1371 |
1 |
sourceText.append("{{html clean=\"false\"}}\n"); |
1372 |
1 |
sourceText.append("<style type=\"text/css\">\n"); |
1373 |
1 |
sourceText.append(".test {\n"); |
1374 |
1 |
sourceText.append(" color: red;\n"); |
1375 |
1 |
sourceText.append("}\n"); |
1376 |
1 |
sourceText.append("</style>\n"); |
1377 |
1 |
sourceText.append("<div class=\"test\">This is a test.</div>\n"); |
1378 |
1 |
sourceText.append("{{/html}}"); |
1379 |
1 |
setSourceText(sourceText.toString()); |
1380 |
1 |
switchToWysiwyg(); |
1381 |
|
|
1382 |
1 |
refreshMacrosUsingShortcutKey(); |
1383 |
|
|
1384 |
1 |
switchToSource(); |
1385 |
1 |
assertSourceText(sourceText.toString()); |
1386 |
|
} |
1387 |
|
|
1388 |
|
|
1389 |
|
@see |
1390 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
1391 |
1 |
@Test... |
1392 |
|
public void testMacroWithUnicodeCharacters() |
1393 |
|
{ |
1394 |
|
|
1395 |
1 |
switchToSource(); |
1396 |
1 |
String sourceText = "before {{info}}\u0103\u0219\u021B\u00E2\u00EE\u00E9\u00E8{{/info}} after"; |
1397 |
1 |
setSourceText(sourceText); |
1398 |
1 |
switchToWysiwyg(); |
1399 |
|
|
1400 |
1 |
refreshMacros(); |
1401 |
|
|
1402 |
1 |
typeText("1 2"); |
1403 |
1 |
waitForPushButton(TOOLBAR_BUTTON_UNDO_TITLE, true); |
1404 |
1 |
clickUndoButton(2); |
1405 |
|
|
1406 |
1 |
switchToSource(); |
1407 |
1 |
assertSourceText("1" + sourceText); |
1408 |
|
} |
1409 |
|
|
1410 |
|
|
1411 |
|
@see |
1412 |
|
|
|
|
| 95.7% |
Uncovered Elements: 1 (23) |
Complexity: 2 |
Complexity Density: 0.1 |
1PASS
|
|
1413 |
1 |
@Test... |
1414 |
|
public void testDefaultValuesForMandatoryParametersAreSent() |
1415 |
|
{ |
1416 |
1 |
open(this.getClass().getSimpleName(), getTestMethodName(), "edit", "editor=object"); |
1417 |
1 |
if (!isElementPresent("xclass_XWiki.WikiMacroClass")) { |
1418 |
|
|
1419 |
1 |
getSelenium().select("classname", "WikiMacroClass"); |
1420 |
1 |
clickEditAddObject(); |
1421 |
1 |
setFieldValue("XWiki.WikiMacroClass_0_id", "now"); |
1422 |
1 |
setFieldValue("XWiki.WikiMacroClass_0_name", "Now"); |
1423 |
1 |
getSelenium().select("XWiki.WikiMacroClass_0_contentType", "No content"); |
1424 |
1 |
setFieldValue("XWiki.WikiMacroClass_0_code", "{{velocity}}$datetool.date{{/velocity}}"); |
1425 |
1 |
clickEditSaveAndContinue(); |
1426 |
|
|
1427 |
1 |
getSelenium().select("classname", "WikiMacroParameterClass"); |
1428 |
1 |
clickEditAddObject(); |
1429 |
1 |
setFieldValue("XWiki.WikiMacroParameterClass_0_name", "format"); |
1430 |
1 |
getSelenium().select("XWiki.WikiMacroParameterClass_0_mandatory", "Yes"); |
1431 |
1 |
setFieldValue("XWiki.WikiMacroParameterClass_0_defaultValue", "yyyy.MM.dd"); |
1432 |
1 |
clickEditSaveAndContinue(); |
1433 |
|
} |
1434 |
1 |
open(this.getClass().getSimpleName(), getTestMethodName(), "edit", "editor=wysiwyg"); |
1435 |
1 |
waitForEditorToLoad(); |
1436 |
|
|
1437 |
1 |
insertMacro("Now"); |
1438 |
1 |
applyMacroChanges(); |
1439 |
|
|
1440 |
1 |
switchToSource(); |
1441 |
1 |
assertSourceText("{{now format=\"yyyy.MM.dd\"/}}"); |
1442 |
|
} |
1443 |
|
|
1444 |
|
|
1445 |
|
@see |
1446 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
1447 |
1 |
@Test... |
1448 |
|
public void testInsertVelocityMacroDisplayingAProperty() |
1449 |
|
{ |
1450 |
1 |
insertMacro("Velocity"); |
1451 |
1 |
setFieldValue("pd-content-input", "$xwiki.getDocument(\"XWiki.Admin\").display(\"comment\")"); |
1452 |
1 |
applyMacroChanges(); |
1453 |
|
|
1454 |
|
|
1455 |
|
|
1456 |
1 |
assertEquals("Admin is the default Wiki Admin.", getRichTextArea().getText().trim()); |
1457 |
|
} |
1458 |
|
|
1459 |
|
|
1460 |
|
|
1461 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
1462 |
1 |
@Test... |
1463 |
|
public void testInsertMacroFromToolBar() |
1464 |
|
{ |
1465 |
|
|
1466 |
1 |
clickInsertMacroButton("velocity"); |
1467 |
1 |
waitForDialogToLoad(); |
1468 |
1 |
setFieldValue("pd-content-input", "$xwiki.version"); |
1469 |
1 |
applyMacroChanges(); |
1470 |
|
|
1471 |
1 |
switchToSource(); |
1472 |
1 |
assertSourceText("{{velocity}}\n$xwiki.version\n{{/velocity}}"); |
1473 |
|
} |
1474 |
|
|
1475 |
|
|
1476 |
|
@see |
1477 |
|
@see |
1478 |
|
|
|
|
| 96.4% |
Uncovered Elements: 1 (28) |
Complexity: 2 |
Complexity Density: 0.07 |
1PASS
|
|
1479 |
1 |
@Test... |
1480 |
|
public void testTypeAroundMacro() |
1481 |
|
{ |
1482 |
1 |
switchToSource(); |
1483 |
1 |
setSourceText("{{info}}one{{/info}}{{warning}}two{{/warning}}{{error}}three{{/error}}" |
1484 |
|
+ "\n\n{{info}}four{{/info}}\n\n{{warning}}five{{/warning}}"); |
1485 |
1 |
switchToWysiwyg(); |
1486 |
|
|
1487 |
|
|
1488 |
1 |
moveCaret(getMacroOutputLocator(0) + ".firstChild.firstChild", 0); |
1489 |
1 |
typeText("1"); |
1490 |
|
|
1491 |
|
|
1492 |
1 |
moveCaret(getMacroOutputLocator(0) + ".firstChild.firstChild", 3); |
1493 |
1 |
typeText(" "); |
1494 |
|
|
1495 |
|
|
1496 |
|
|
1497 |
1 |
selectRichTextAreaFrame(); |
1498 |
1 |
try { |
1499 |
1 |
assertFalse(getSelenium().isVisible(getMacroPlaceHolderLocator(0))); |
1500 |
1 |
assertTrue(getSelenium().isVisible(getMacroOutputLocator(0))); |
1501 |
|
} finally { |
1502 |
1 |
selectTopFrame(); |
1503 |
|
} |
1504 |
|
|
1505 |
|
|
1506 |
1 |
moveCaret(getMacroOutputLocator(2) + ".firstChild.firstChild", 0); |
1507 |
1 |
typeText("3"); |
1508 |
|
|
1509 |
|
|
1510 |
1 |
moveCaret(getMacroOutputLocator(2) + ".firstChild.firstChild", 5); |
1511 |
1 |
typeEnter(); |
1512 |
1 |
try { |
1513 |
1 |
waitForDialogToLoad(); |
1514 |
0 |
fail("The macro edit box shouldn't be triggered by pressing Enter at the end of the output."); |
1515 |
|
} catch (TimeoutException e) { |
1516 |
|
|
1517 |
|
} |
1518 |
1 |
typeText("2"); |
1519 |
|
|
1520 |
|
|
1521 |
1 |
moveCaret(getMacroOutputLocator(4) + ".firstChild.firstChild", 0); |
1522 |
1 |
typeEnter(); |
1523 |
1 |
typeText("4"); |
1524 |
|
|
1525 |
|
|
1526 |
1 |
moveCaret(getMacroOutputLocator(4) + ".firstChild.firstChild", 4); |
1527 |
1 |
typeEnter(); |
1528 |
1 |
typeText("5"); |
1529 |
|
|
1530 |
1 |
switchToSource(); |
1531 |
1 |
assertSourceText("1{{info}}one{{/info}} {{warning}}two{{/warning}}3{{error}}three{{/error}}\n\n2" |
1532 |
|
+ "\n\n{{info}}\nfour\n{{/info}}\n\n4\n\n{{warning}}\nfive\n{{/warning}}\n\n5"); |
1533 |
|
} |
1534 |
|
|
1535 |
|
|
1536 |
|
@see |
1537 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
1538 |
1 |
@Test... |
1539 |
|
public void testEditorWidthIsRestoredAfterFullScreenEdit() |
1540 |
|
{ |
1541 |
1 |
clickEditInFullScreen(); |
1542 |
1 |
refreshMacros(); |
1543 |
1 |
clickExitFullScreen(); |
1544 |
|
|
1545 |
1 |
assertEquals("", getSelenium().getEval("window.document.getElementsByTagName('iframe')[0].style.width")); |
1546 |
|
} |
1547 |
|
|
1548 |
|
|
1549 |
|
@param |
1550 |
|
@return@link |
1551 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1552 |
24 |
public String getMacroLocator(int index)... |
1553 |
|
{ |
1554 |
24 |
return "document.getElementsByClassName('macro')[" + index + "]"; |
1555 |
|
} |
1556 |
|
|
1557 |
|
|
1558 |
|
@return |
1559 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1560 |
1 |
public long getMacroCount()... |
1561 |
|
{ |
1562 |
1 |
return (Long) getRichTextArea().executeScript("return document.getElementsByClassName('macro').length"); |
1563 |
|
} |
1564 |
|
|
1565 |
|
|
1566 |
|
@return |
1567 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1568 |
7 |
public long getSelectedMacroCount()... |
1569 |
|
{ |
1570 |
7 |
return (Long) getRichTextArea() |
1571 |
|
.executeScript("return document.getElementsByClassName('macro-selected').length"); |
1572 |
|
} |
1573 |
|
|
1574 |
|
|
1575 |
|
|
1576 |
|
|
1577 |
|
@param |
1578 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1579 |
4 |
public void waitForSelectedMacroCount(final int count)... |
1580 |
|
{ |
1581 |
4 |
new Wait() |
1582 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1583 |
7 |
public boolean until()... |
1584 |
|
{ |
1585 |
7 |
return count == getSelectedMacroCount(); |
1586 |
|
} |
1587 |
|
}.wait("The specified number of selected macros, " + count + ", hasn't been reached in a decent amount of time"); |
1588 |
|
} |
1589 |
|
|
1590 |
|
|
1591 |
|
|
1592 |
|
|
1593 |
|
@param |
1594 |
|
@return@link |
1595 |
|
|
1596 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1597 |
7 |
public String getMacroPlaceHolderLocator(int index)... |
1598 |
|
{ |
1599 |
7 |
return "document.getElementsByClassName('macro-placeholder')[" + index + "]"; |
1600 |
|
} |
1601 |
|
|
1602 |
|
|
1603 |
|
|
1604 |
|
|
1605 |
|
@param |
1606 |
|
@return@link |
1607 |
|
|
1608 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1609 |
13 |
public String getMacroOutputLocator(int index)... |
1610 |
|
{ |
1611 |
13 |
return "document.getElementsByClassName('macro-output')[" + index + "]"; |
1612 |
|
} |
1613 |
|
|
1614 |
|
|
1615 |
|
|
1616 |
|
|
1617 |
|
@param |
1618 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
|
1619 |
21 |
public void selectMacro(int index)... |
1620 |
|
{ |
1621 |
21 |
String locator = getMacroLocator(index); |
1622 |
21 |
selectRichTextAreaFrame(); |
1623 |
21 |
try { |
1624 |
21 |
getSelenium().mouseOver(locator); |
1625 |
21 |
getSelenium().mouseMove(locator); |
1626 |
21 |
getSelenium().mouseDown(locator); |
1627 |
21 |
getSelenium().mouseUp(locator); |
1628 |
21 |
getSelenium().click(locator); |
1629 |
21 |
getSelenium().mouseMove(locator); |
1630 |
21 |
|