Index: tests/SkDOMTest.cpp |
diff --git a/tests/SkDOMTest.cpp b/tests/SkDOMTest.cpp |
index a7fbda7f211dc3ad776c9650d585ced0bad51adc..6ea4e789746d031fcea8119f1f4703c36d35b163 100644 |
--- a/tests/SkDOMTest.cpp |
+++ b/tests/SkDOMTest.cpp |
@@ -12,14 +12,26 @@ |
#include "SkDOM.h" |
+static const SkDOM::Node* check_node(skiatest::Reporter* r, const SkDOM& dom, |
+ const SkDOM::Node* node, const char* expectedName, |
+ SkDOM::Type expectedType) { |
+ REPORTER_ASSERT(r, node); |
+ if (node) { |
+ REPORTER_ASSERT(r, !strcmp(dom.getName(node), expectedName)); |
+ REPORTER_ASSERT(r, dom.getType(node) == expectedType); |
+ } |
+ return node; |
+} |
+ |
DEF_TEST(SkDOM_test, r) { |
static const char gDoc[] = |
"<root a='1' b='2'>" |
"<elem1 c='3' />" |
"<elem2 d='4' />" |
"<elem3 e='5'>" |
- "<subelem1/>" |
+ "<subelem1>Some text.</subelem1>" |
"<subelem2 f='6' g='7'/>" |
+ "<subelem3>Some more text.</subelem3>" |
"</elem3>" |
"<elem4 h='8'/>" |
"</root>" |
@@ -42,6 +54,33 @@ DEF_TEST(SkDOM_test, r) { |
REPORTER_ASSERT(r, dom.getFirstChild(root, "elem1")); |
REPORTER_ASSERT(r, !dom.getFirstChild(root, "subelem1")); |
+ |
+ { |
+ const auto* elem1 = check_node(r, dom, dom.getFirstChild(root), |
+ "elem1", SkDOM::kElement_Type); |
+ const auto* elem2 = check_node(r, dom, dom.getNextSibling(elem1), |
+ "elem2", SkDOM::kElement_Type); |
+ const auto* elem3 = check_node(r, dom, dom.getNextSibling(elem2), |
+ "elem3", SkDOM::kElement_Type); |
+ { |
+ const auto* subelem1 = check_node(r, dom, dom.getFirstChild(elem3), |
+ "subelem1", SkDOM::kElement_Type); |
+ { |
+ check_node(r, dom, dom.getFirstChild(subelem1), |
+ "Some text.", SkDOM::kText_Type); |
+ } |
+ const auto* subelem2 = check_node(r, dom, dom.getNextSibling(subelem1), |
+ "subelem2", SkDOM::kElement_Type); |
+ const auto* subelem3 = check_node(r, dom, dom.getNextSibling(subelem2), |
+ "subelem3", SkDOM::kElement_Type); |
+ { |
+ check_node(r, dom, dom.getFirstChild(subelem3), |
+ "Some more text.", SkDOM::kText_Type); |
+ } |
+ } |
+ check_node(r, dom, dom.getNextSibling(elem3), |
+ "elem4", SkDOM::kElement_Type); |
+ } |
} |
#endif // SK_XML |