diff options
author | fmalita <fmalita@chromium.org> | 2016-07-14 19:14:06 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-14 19:14:06 -0700 |
commit | 7445e86bac478dea91da32473e5a01baff637c23 (patch) | |
tree | 8bcb373c49d64579f87bc57b4270b82ad0838fec /tests/SkDOMTest.cpp | |
parent | 59779ae8ce316bf8b8082ec2df1683ccd38161f1 (diff) |
Dust-off SkXMLParser
Hook up SkXMLParser to Expat, such that it can actually parse, err,
XML.
Add a trivial unit test.
R=robertphillips@google.com,reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2142893006
Review-Url: https://codereview.chromium.org/2142893006
Diffstat (limited to 'tests/SkDOMTest.cpp')
-rw-r--r-- | tests/SkDOMTest.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/SkDOMTest.cpp b/tests/SkDOMTest.cpp new file mode 100644 index 0000000000..aca2c4870b --- /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")); +} |