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

Side by Side Diff: tests/SkDOMTest.cpp

Issue 2142893006: Dust-off SkXMLParser (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review 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/SkXMLParser.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
(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 "SkStream.h"
10 #include "Test.h"
11
12 DEF_TEST(SkDOM_test, r) {
13 static const char gDoc[] =
14 "<root a='1' b='2'>"
15 "<elem1 c='3' />"
16 "<elem2 d='4' />"
17 "<elem3 e='5'>"
18 "<subelem1/>"
19 "<subelem2 f='6' g='7'/>"
20 "</elem3>"
21 "<elem4 h='8'/>"
22 "</root>"
23 ;
24
25 SkMemoryStream docStream(gDoc, sizeof(gDoc) - 1);
26
27 SkDOM dom;
28 REPORTER_ASSERT(r, !dom.getRootNode());
29
30 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
31 REPORTER_ASSERT(r, root && dom.getRootNode() == root);
32
33 const char* v = dom.findAttr(root, "a");
34 REPORTER_ASSERT(r, v && !strcmp(v, "1"));
35 v = dom.findAttr(root, "b");
36 REPORTER_ASSERT(r, v && !strcmp(v, "2"));
37 v = dom.findAttr(root, "c");
38 REPORTER_ASSERT(r, v == nullptr);
39
40 REPORTER_ASSERT(r, dom.getFirstChild(root, "elem1"));
41 REPORTER_ASSERT(r, !dom.getFirstChild(root, "subelem1"));
42 }
OLDNEW
« 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