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

Unified Diff: tests/SkDOMTest.cpp

Issue 2142893006: Dust-off SkXMLParser (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: XML_STATIC for MSVC voodoo 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
new file mode 100644
index 0000000000000000000000000000000000000000..aca2c4870bb58943435a5a223aefd9f1c1b0470b
--- /dev/null
+++ b/tests/SkDOMTest.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkDOM.h"
+#include "Test.h"
+
+DEF_TEST(SkDOM_test, r) {
+ static const char gDoc[] =
+ "<root a='1' b='2'>"
+ "<elem1 c='3' />"
+ "<elem2 d='4' />"
+ "<elem3 e='5'>"
+ "<subelem1/>"
+ "<subelem2 f='6' g='7'/>"
+ "</elem3>"
+ "<elem4 h='8'/>"
+ "</root>"
+ ;
+
+ SkDOM dom;
+ REPORTER_ASSERT(r, !dom.getRootNode());
+
+ const SkDOM::Node* root = dom.build(gDoc, sizeof(gDoc) - 1);
+ REPORTER_ASSERT(r, root && dom.getRootNode() == root);
+
+ const char* v = dom.findAttr(root, "a");
+ REPORTER_ASSERT(r, v && !strcmp(v, "1"));
+ v = dom.findAttr(root, "b");
+ REPORTER_ASSERT(r, v && !strcmp(v, "2"));
+ v = dom.findAttr(root, "c");
+ REPORTER_ASSERT(r, v == nullptr);
+
+ REPORTER_ASSERT(r, dom.getFirstChild(root, "elem1"));
+ REPORTER_ASSERT(r, !dom.getFirstChild(root, "subelem1"));
+}
« 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