| 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 (77) |
Complexity: 6 |
Complexity Density: 0.08 |
|
| 33 |
|
public class TableTest extends AbstractWysiwygTestCase |
| 34 |
|
{ |
| 35 |
|
public static final String ROWS_SELECTOR = "//input[@title = 'Row count']"; |
| 36 |
|
|
| 37 |
|
public static final String COLUMNS_SELECTOR = "//input[@title = 'Column count']"; |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
@see |
| 43 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 44 |
1 |
@Test... |
| 45 |
|
public void testTabInTableCell() |
| 46 |
|
{ |
| 47 |
1 |
insertTable(); |
| 48 |
1 |
typeText("a"); |
| 49 |
|
|
| 50 |
1 |
typeShiftTab(); |
| 51 |
1 |
typeText("b"); |
| 52 |
1 |
typeTab(3); |
| 53 |
|
|
| 54 |
1 |
typeDelete(); |
| 55 |
1 |
typeText("c"); |
| 56 |
|
|
| 57 |
1 |
typeTab(); |
| 58 |
|
|
| 59 |
1 |
typeDelete(); |
| 60 |
1 |
typeText("d"); |
| 61 |
1 |
typeShiftTab(4); |
| 62 |
1 |
typeText("e"); |
| 63 |
1 |
switchToSource(); |
| 64 |
1 |
assertSourceText("|=eab|= \n| |c\n|d| "); |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
@see |
| 69 |
|
@see |
| 70 |
|
@see |
| 71 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
| 72 |
1 |
@Test... |
| 73 |
|
public void testMoveCaretBeforeAndAfterTable() |
| 74 |
|
{ |
| 75 |
1 |
switchToSource(); |
| 76 |
1 |
setSourceText("|=Space|=Page\n|Main|WebHome"); |
| 77 |
1 |
switchToWysiwyg(); |
| 78 |
|
|
| 79 |
|
|
| 80 |
1 |
moveCaret("document.body.getElementsByTagName('table')[0].rows[0].cells[0].firstChild", 2); |
| 81 |
|
|
| 82 |
|
|
| 83 |
1 |
getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.ARROW_UP), "1"); |
| 84 |
|
|
| 85 |
|
|
| 86 |
1 |
moveCaret("document.body.getElementsByTagName('table')[0].rows[0].cells[0].firstChild", 2); |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
1 |
moveCaret("document.body.getElementsByTagName('table')[0].rows[1].cells[1].firstChild", 3); |
| 94 |
|
|
| 95 |
|
|
| 96 |
1 |
getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.ARROW_DOWN), "4"); |
| 97 |
|
|
| 98 |
|
|
| 99 |
1 |
moveCaret("document.body.getElementsByTagName('table')[0].rows[1].cells[1].firstChild", 3); |
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
1 |
switchToSource(); |
| 106 |
1 |
assertSourceText("1\n\n|=Space|=Page\n|Main|WebHome\n\n4"); |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
@see |
| 111 |
|
|
| 112 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
| 113 |
1 |
@Test... |
| 114 |
|
public void testCancelInsertTable() |
| 115 |
|
{ |
| 116 |
1 |
openInsertTableDialog(); |
| 117 |
|
|
| 118 |
1 |
closeDialog(); |
| 119 |
|
|
| 120 |
|
|
| 121 |
1 |
insertTable(); |
| 122 |
|
|
| 123 |
|
|
| 124 |
1 |
getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.ARROW_DOWN)); |
| 125 |
|
|
| 126 |
1 |
openInsertTableDialog(); |
| 127 |
|
|
| 128 |
1 |
closeDialog(); |
| 129 |
|
|
| 130 |
|
|
| 131 |
1 |
switchToSource(); |
| 132 |
1 |
assertSourceText("|= |= \n| | \n"); |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
|
| 136 |
|
@see |
| 137 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
| 138 |
1 |
@Test... |
| 139 |
|
public void testEnterInTableConfigDialog() |
| 140 |
|
{ |
| 141 |
1 |
openInsertTableDialog(); |
| 142 |
|
|
| 143 |
1 |
getSelenium().type(ROWS_SELECTOR, "1"); |
| 144 |
1 |
getSelenium().type(COLUMNS_SELECTOR, "1"); |
| 145 |
1 |
getSelenium().uncheck("//div[@class = 'xDialogBody']//input[@type = 'checkbox']"); |
| 146 |
|
|
| 147 |
1 |
getSelenium().typeKeys(ROWS_SELECTOR, "\\13"); |
| 148 |
|
|
| 149 |
1 |
waitForDialogToClose(); |
| 150 |
1 |
switchToSource(); |
| 151 |
1 |
assertSourceText("| "); |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 158 |
1 |
@Test... |
| 159 |
|
public void testValidateTableConfigDialog() |
| 160 |
|
{ |
| 161 |
1 |
openInsertTableDialog(); |
| 162 |
|
|
| 163 |
1 |
assertFieldErrorIsNotPresent(); |
| 164 |
|
|
| 165 |
1 |
getSelenium().type(ROWS_SELECTOR, ""); |
| 166 |
1 |
getSelenium().type(COLUMNS_SELECTOR, "0"); |
| 167 |
|
|
| 168 |
1 |
getSelenium().click("//button[text()=\"Insert Table\"]"); |
| 169 |
|
|
| 170 |
1 |
assertFieldErrorIsPresent("Please enter a number greater than zero.", "//input[@title = 'Row count']"); |
| 171 |
|
|
| 172 |
1 |
assertFieldErrorIsPresent("Please enter a number greater than zero.", "//input[@title = 'Column count']"); |
| 173 |
|
|
| 174 |
1 |
assertEquals(2, getSelenium().getXpathCount("//div[contains(@class, 'xErrorMsg') and @style = '']")); |
| 175 |
|
|
| 176 |
1 |
getSelenium().type(ROWS_SELECTOR, "1"); |
| 177 |
|
|
| 178 |
1 |
getSelenium().click("//button[text()=\"Insert Table\"]"); |
| 179 |
|
|
| 180 |
1 |
assertFieldErrorIsPresent("Please enter a number greater than zero.", "//input[@title = 'Column count']"); |
| 181 |
|
|
| 182 |
1 |
closeDialog(); |
| 183 |
1 |
openInsertTableDialog(); |
| 184 |
|
|
| 185 |
1 |
assertFieldErrorIsNotPresent(); |
| 186 |
|
|
| 187 |
1 |
getSelenium().click("//button[text()=\"Insert Table\"]"); |
| 188 |
|
|
| 189 |
1 |
assertFieldErrorIsPresent("Please enter a number greater than zero.", "//input[@title = 'Column count']"); |
| 190 |
|
|
| 191 |
1 |
getSelenium().type(COLUMNS_SELECTOR, "1"); |
| 192 |
1 |
getSelenium().click("//button[text()=\"Insert Table\"]"); |
| 193 |
1 |
waitForDialogToClose(); |
| 194 |
|
|
| 195 |
1 |
switchToSource(); |
| 196 |
1 |
assertSourceText("|= "); |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
|
| 200 |
|
@see |
| 201 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
| 202 |
1 |
@Test... |
| 203 |
|
public void testDeleteRowWhenSelectionSpansAcrossMultipleCells() |
| 204 |
|
{ |
| 205 |
|
|
| 206 |
1 |
switchToSource(); |
| 207 |
1 |
setSourceText("|=A|=B|=C\n|1|2|3\n|x|y|z"); |
| 208 |
1 |
switchToWysiwyg(); |
| 209 |
|
|
| 210 |
|
|
| 211 |
1 |
select("document.body.getElementsByTagName('td')[0].firstChild", 0, |
| 212 |
|
"document.body.getElementsByTagName('td')[1].firstChild", 1); |
| 213 |
|
|
| 214 |
|
|
| 215 |
1 |
clickMenu("Table"); |
| 216 |
1 |
assertTrue(isMenuEnabled("Delete Row")); |
| 217 |
1 |
clickMenu("Delete Row"); |
| 218 |
|
|
| 219 |
|
|
| 220 |
1 |
switchToSource(); |
| 221 |
1 |
assertSourceText("|=A|=B|=C\n|x|y|z"); |
| 222 |
|
} |
| 223 |
|
} |