MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / splitText

Method splitText

src/test/java/org/htmlunit/html/DomTextTest.java:177–206  ·  view source on GitHub ↗

@throws Exception if the test fails

()

Source from the content-addressed store, hash-verified

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

Callers 10

tiny_mce_src.jsFile · 0.45
tiny_mce.jsFile · 0.45
tiny_mce_jquery.jsFile · 0.45
Range.jsFile · 0.45
RemoveFormat.jsFile · 0.45
parseTextBoundsFunction · 0.45
splitMethod · 0.45

Calls 10

getElementByIdMethod · 0.95
insertBeforeMethod · 0.95
getPreviousSiblingMethod · 0.95
getNextSiblingMethod · 0.95
splitTextMethod · 0.95
assertSameMethod · 0.80
loadPageMethod · 0.45
getParentNodeMethod · 0.45
assertEqualsMethod · 0.45

Tested by

no test coverage detected