Chromium Code Reviews| Index: tests/SkDOMTest.cpp |
| diff --git a/tests/SkDOMTest.cpp b/tests/SkDOMTest.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a7195b236ec45471aaadd06bf5da4031758d0b79 |
| --- /dev/null |
| +++ b/tests/SkDOMTest.cpp |
| @@ -0,0 +1,42 @@ |
| +/* |
| + * 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 "SkStream.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>" |
| + ; |
| + |
| + SkMemoryStream docStream(gDoc, sizeof(gDoc) - 1); |
| + |
| + SkDOM dom; |
| + REPORTER_ASSERT(r, !dom.getRootNode()); |
| + |
| + const SkDOM::Node* root = dom.build(docStream); |
|
stephana
2016/07/14 18:53:22
Nit:
If you called
... dom.build(gDoc, sizeof
f(malita)
2016/07/14 23:22:11
Done.
I was thinking we should kill that build va
|
| + 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")); |
| +} |