Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
HistoryTest | 31 | 23 | 0% | 2 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
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 | /** | |
27 | * Functional tests for history support (undo/redo) inside the WYSIWYG editor. | |
28 | * | |
29 | * @version $Id: 263e90e3f686c9cdb05d97db46cdf53b7614f0c4 $ | |
30 | */ | |
31 | public class HistoryTest extends AbstractWysiwygTestCase | |
32 | { | |
33 | /** | |
34 | * Basic integration test for the history mechanism. | |
35 | */ | |
36 | 1 | ![]() |
37 | public void testUndoRedo() | |
38 | { | |
39 | 1 | getRichTextArea().sendKeys("a b", Keys.TAB, "c"); |
40 | 1 | clickSymbolButton(); |
41 | 1 | getSelenium().click("//div[@title='copyright sign']"); |
42 | 1 | applyStyleTitle1(); |
43 | 1 | waitForPushButton(TOOLBAR_BUTTON_UNDO_TITLE, true); |
44 | 1 | clickUndoButton(4); |
45 | 1 | assertContent("a b<br>"); |
46 | 1 | clickUndoButton(3); |
47 | 1 | assertContent("<br>"); |
48 | 1 | waitForPushButton(TOOLBAR_BUTTON_REDO_TITLE, true); |
49 | 1 | clickRedoButton(7); |
50 | 1 | assertContent("<h1>a b c\u00A9<br></h1>"); |
51 | } | |
52 | ||
53 | /** | |
54 | * Tests the shortcut keys for undo and redo operations. Undo is triggered by CTRL+Z or META+Z. The second is used | |
55 | * on apple keyboards. Redo is triggered by CTRL+Y or META+Y. The second is also used on apple keyboards. | |
56 | * | |
57 | * @see XWIKI-3048: Undo/Redo/Copy/Paste/Cut Mac shortcuts should be mapped to the corresponding features of the | |
58 | * WYSIWYG editor | |
59 | */ | |
60 | 1 | ![]() |
61 | public void testUndoRedoShortcutKeys() | |
62 | { | |
63 | 1 | setContent("March 9th, 2009"); |
64 | 1 | select("document.body.firstChild", 0, "document.body.firstChild", 5); |
65 | ||
66 | // Make text bold. | |
67 | 1 | getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "b")); |
68 | ||
69 | // Make text italic. | |
70 | // FIXME: getRichTextArea().sendKeys(Keys.chord(Keys.META, "i")); | |
71 | 1 | getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "i")); |
72 | ||
73 | // Make text underline. | |
74 | 1 | getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "u")); |
75 | ||
76 | // Undo last 3 steps. | |
77 | // The undo tool bar button is initially disabled because no action has been taken on the edited document. We | |
78 | // have to wait for it to become enabled because the tool bar is updated with delay after each edit action. | |
79 | 1 | waitForPushButton(TOOLBAR_BUTTON_UNDO_TITLE, true); |
80 | // FIXME: getRichTextArea().sendKeys(Keys.chord(Keys.META, "zzz")); | |
81 | 1 | getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "zzz")); |
82 | ||
83 | // Redo 2 steps. | |
84 | // We have to wait for the redo tool bar button to become enabled because the tool bar is updated with delay | |
85 | // after an undo operation. | |
86 | 1 | waitForPushButton(TOOLBAR_BUTTON_REDO_TITLE, true); |
87 | 1 | getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "yy")); |
88 | ||
89 | 1 | switchToSource(); |
90 | 1 | assertSourceText("**//March//** 9th, 2009"); |
91 | } | |
92 | } |