@throws Exception if the test fails
()
| 175 | * @throws Exception if the test fails |
| 176 | */ |
| 177 | @Test |
| 178 | public void splitText() throws Exception { |
| 179 | final String html = DOCTYPE_HTML |
| 180 | + "<html><head></head><body>\n" |
| 181 | + "<br><div id='tag'></div><br></body></html>"; |
| 182 | final HtmlPage page = loadPage(html); |
| 183 | |
| 184 | final DomNode divNode = page.getElementById("tag"); |
| 185 | |
| 186 | final DomText node = new DomText(page, "test split"); |
| 187 | divNode.insertBefore(node); |
| 188 | |
| 189 | final DomNode previousSibling = node.getPreviousSibling(); |
| 190 | final DomNode nextSibling = node.getNextSibling(); |
| 191 | final DomNode parent = node.getParentNode(); |
| 192 | |
| 193 | // position among parent's children |
| 194 | final int position = readPositionAmongParentChildren(node); |
| 195 | |
| 196 | final DomText newNode = node.splitText(5); |
| 197 | |
| 198 | assertSame("new node previous sibling", node, newNode.getPreviousSibling()); |
| 199 | assertSame("previous sibling", previousSibling, node.getPreviousSibling()); |
| 200 | assertSame("new node next sibling", nextSibling, newNode.getNextSibling()); |
| 201 | assertSame("next sibling", newNode, node.getNextSibling()); |
| 202 | assertSame("parent", parent, newNode.getParentNode()); |
| 203 | assertSame(node, previousSibling.getNextSibling()); |
| 204 | assertSame(newNode, nextSibling.getPreviousSibling()); |
| 205 | assertEquals(position + 1, readPositionAmongParentChildren(newNode)); |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * @throws Exception if the test fails |
no test coverage detected