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

Side by Side Diff: tests/SkDOMTest.cpp

Issue 2154733003: Remove SkDOM::build(const char doc[], size_t len) (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 unified diff | Download patch
« no previous file with comments | « src/xml/SkDOM.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkStream.h"
8 #include "Test.h" 9 #include "Test.h"
9 10
10 #if defined(SK_XML) 11 #if defined(SK_XML)
11 12
12 #include "SkDOM.h" 13 #include "SkDOM.h"
13 14
14 DEF_TEST(SkDOM_test, r) { 15 DEF_TEST(SkDOM_test, r) {
15 static const char gDoc[] = 16 static const char gDoc[] =
16 "<root a='1' b='2'>" 17 "<root a='1' b='2'>"
17 "<elem1 c='3' />" 18 "<elem1 c='3' />"
18 "<elem2 d='4' />" 19 "<elem2 d='4' />"
19 "<elem3 e='5'>" 20 "<elem3 e='5'>"
20 "<subelem1/>" 21 "<subelem1/>"
21 "<subelem2 f='6' g='7'/>" 22 "<subelem2 f='6' g='7'/>"
22 "</elem3>" 23 "</elem3>"
23 "<elem4 h='8'/>" 24 "<elem4 h='8'/>"
24 "</root>" 25 "</root>"
25 ; 26 ;
26 27
28 SkMemoryStream docStream(gDoc, sizeof(gDoc) - 1);
29
27 SkDOM dom; 30 SkDOM dom;
28 REPORTER_ASSERT(r, !dom.getRootNode()); 31 REPORTER_ASSERT(r, !dom.getRootNode());
29 32
30 const SkDOM::Node* root = dom.build(gDoc, sizeof(gDoc) - 1); 33 const SkDOM::Node* root = dom.build(docStream);
31 REPORTER_ASSERT(r, root && dom.getRootNode() == root); 34 REPORTER_ASSERT(r, root && dom.getRootNode() == root);
32 35
33 const char* v = dom.findAttr(root, "a"); 36 const char* v = dom.findAttr(root, "a");
34 REPORTER_ASSERT(r, v && !strcmp(v, "1")); 37 REPORTER_ASSERT(r, v && !strcmp(v, "1"));
35 v = dom.findAttr(root, "b"); 38 v = dom.findAttr(root, "b");
36 REPORTER_ASSERT(r, v && !strcmp(v, "2")); 39 REPORTER_ASSERT(r, v && !strcmp(v, "2"));
37 v = dom.findAttr(root, "c"); 40 v = dom.findAttr(root, "c");
38 REPORTER_ASSERT(r, v == nullptr); 41 REPORTER_ASSERT(r, v == nullptr);
39 42
40 REPORTER_ASSERT(r, dom.getFirstChild(root, "elem1")); 43 REPORTER_ASSERT(r, dom.getFirstChild(root, "elem1"));
41 REPORTER_ASSERT(r, !dom.getFirstChild(root, "subelem1")); 44 REPORTER_ASSERT(r, !dom.getFirstChild(root, "subelem1"));
42 } 45 }
43 46
44 #endif // SK_XML 47 #endif // SK_XML
OLDNEW
« no previous file with comments | « src/xml/SkDOM.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698