Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: tests/SkDOMTest.cpp

Issue 2154853002: [SkXMLParser] Initial text node support (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/xml/SkXMLParser.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/xml/SkXMLParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698