OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "SkDOM.h" |
| 9 #include "Test.h" |
| 10 |
| 11 DEF_TEST(SkDOM_test, r) { |
| 12 static const char gDoc[] = |
| 13 "<root a='1' b='2'>" |
| 14 "<elem1 c='3' />" |
| 15 "<elem2 d='4' />" |
| 16 "<elem3 e='5'>" |
| 17 "<subelem1/>" |
| 18 "<subelem2 f='6' g='7'/>" |
| 19 "</elem3>" |
| 20 "<elem4 h='8'/>" |
| 21 "</root>" |
| 22 ; |
| 23 |
| 24 SkDOM dom; |
| 25 REPORTER_ASSERT(r, !dom.getRootNode()); |
| 26 |
| 27 const SkDOM::Node* root = dom.build(gDoc, sizeof(gDoc) - 1); |
| 28 REPORTER_ASSERT(r, root && dom.getRootNode() == root); |
| 29 |
| 30 const char* v = dom.findAttr(root, "a"); |
| 31 REPORTER_ASSERT(r, v && !strcmp(v, "1")); |
| 32 v = dom.findAttr(root, "b"); |
| 33 REPORTER_ASSERT(r, v && !strcmp(v, "2")); |
| 34 v = dom.findAttr(root, "c"); |
| 35 REPORTER_ASSERT(r, v == nullptr); |
| 36 |
| 37 REPORTER_ASSERT(r, dom.getFirstChild(root, "elem1")); |
| 38 REPORTER_ASSERT(r, !dom.getFirstChild(root, "subelem1")); |
| 39 } |
OLD | NEW |