summaryrefslogtreecommitdiffstats
path: root/luni/src/test/java/tests/xml/DomTest.java
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2010-06-11 14:57:31 -0700
committerJesse Wilson <jessewilson@google.com>2010-06-11 15:35:56 -0700
commit8e8c7faab913b335d14b7659e597822e160b3e2c (patch)
tree151ed500f2fc601fcbea8fcca8c2125afa61a239 /luni/src/test/java/tests/xml/DomTest.java
parent9a0668a7f531b04dd001a4d193c159dabdb7bf0c (diff)
downloadlibcore-8e8c7faab913b335d14b7659e597822e160b3e2c.zip
libcore-8e8c7faab913b335d14b7659e597822e160b3e2c.tar.gz
libcore-8e8c7faab913b335d14b7659e597822e160b3e2c.tar.bz2
Test for DOM node iteration thru siblings.
This passes. http://code.google.com/p/android/issues/detail?id=8944 Change-Id: Ia7f0c8f750bef71d7f2bf9e277eda82b8c1a7b38
Diffstat (limited to 'luni/src/test/java/tests/xml/DomTest.java')
-rw-r--r--luni/src/test/java/tests/xml/DomTest.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/luni/src/test/java/tests/xml/DomTest.java b/luni/src/test/java/tests/xml/DomTest.java
index 90748a6..eb3a842 100644
--- a/luni/src/test/java/tests/xml/DomTest.java
+++ b/luni/src/test/java/tests/xml/DomTest.java
@@ -1341,6 +1341,50 @@ public class DomTest extends TestCase {
}
}
+ public void testIterateForwardsThroughInnerNodeSiblings() throws Exception {
+ document = builder.parse(new InputSource(new StringReader(
+ "<root><child/><child/></root>")));
+ Node root = document.getDocumentElement();
+ Node current = root.getChildNodes().item(0);
+ while (current.getNextSibling() != null) {
+ current = current.getNextSibling();
+ }
+ assertEquals(root.getChildNodes().item(root.getChildNodes().getLength() - 1), current);
+ }
+
+ public void testIterateBackwardsThroughInnerNodeSiblings() throws Exception {
+ document = builder.parse(new InputSource(new StringReader(
+ "<root><child/><child/></root>")));
+ Node root = document.getDocumentElement();
+ Node current = root.getChildNodes().item(root.getChildNodes().getLength() - 1);
+ while (current.getPreviousSibling() != null) {
+ current = current.getPreviousSibling();
+ }
+ assertEquals(root.getChildNodes().item(0), current);
+ }
+
+ public void testIterateForwardsThroughLeafNodeSiblings() throws Exception {
+ document = builder.parse(new InputSource(new StringReader(
+ "<root> <!-- --> </root>")));
+ Node root = document.getDocumentElement();
+ Node current = root.getChildNodes().item(0);
+ while (current.getNextSibling() != null) {
+ current = current.getNextSibling();
+ }
+ assertEquals(root.getChildNodes().item(root.getChildNodes().getLength() - 1), current);
+ }
+
+ public void testIterateBackwardsThroughLeafNodeSiblings() throws Exception {
+ document = builder.parse(new InputSource(new StringReader(
+ "<root> <!-- --> </root>")));
+ Node root = document.getDocumentElement();
+ Node current = root.getChildNodes().item(root.getChildNodes().getLength() - 1);
+ while (current.getPreviousSibling() != null) {
+ current = current.getPreviousSibling();
+ }
+ assertEquals(root.getChildNodes().item(0), current);
+ }
+
private class RecordingHandler implements UserDataHandler {
final Set<String> calls = new HashSet<String>();
public void handle(short operation, String key, Object data, Node src, Node dst) {