5#include "core/fxcrt/xml/cfx_xmlelement.h"
6#include "core/fxcrt/xml/cfx_xmlchardata.h"
7#include "core/fxcrt/xml/cfx_xmldocument.h"
8#include "core/fxcrt/xml/cfx_xmltext.h"
9#include "testing/gtest/include/gtest/gtest.h"
10#include "testing/string_write_stream.h"
13 CFX_XMLElement node
(L"node"
);
18 CFX_XMLElement node
(L"node"
);
23 CFX_XMLElement node1
(L"node1"
);
26 CFX_XMLElement node2
(L"test:node2"
);
31 CFX_XMLElement node1
(L"node1"
);
34 CFX_XMLElement node2
(L"test:node2"
);
39 CFX_XMLElement node1
(L"node1"
);
45 CFX_XMLElement node2
(L"test:node2"
);
56 CFX_XMLElement node
(L"test:node"
);
65 ASSERT_EQ(2U, node.GetAttributes().size());
70 ASSERT_EQ(1U, node.GetAttributes().size());
75 CFX_XMLElement node
(L"test:node"
);
81 node.AppendLastChild(&text_child1);
83 CFX_XMLElement node_child1
(L"Node child"
);
84 node.AppendLastChild(&node_child1);
87 EXPECT_TRUE(clone !=
nullptr);
102 ASSERT_TRUE(inst->GetFirstChild() !=
nullptr);
103 EXPECT_TRUE(inst->GetFirstChild()->GetNextSibling() ==
nullptr);
106 auto* text = ToXMLText(inst->GetFirstChild());
107 EXPECT_EQ(L"Text Child", text->GetText());
111 auto stream = pdfium::MakeRetain<StringWriteStream>();
112 CFX_XMLElement node
(L"root"
);
115 EXPECT_EQ(
"<root />\n", stream->ToString());
119 auto stream = pdfium::MakeRetain<StringWriteStream>();
120 CFX_XMLElement node
(L"root"
);
125 EXPECT_EQ(
"<root first=\"one\" second=\"two\" />\n", stream->ToString());
129 auto stream = pdfium::MakeRetain<StringWriteStream>();
130 CFX_XMLElement node
(L"node"
);
133 node.AppendLastChild(&text_child1);
135 CFX_XMLElement node_child1
(L"node-child"
);
136 node.AppendLastChild(&node_child1);
139 node_child1.AppendLastChild(&text_child2);
141 CFX_XMLCharData char_data1
(L"Char Data"
);
142 node.AppendLastChild(&char_data1);
148 "<node-child>\nText Child 2</node-child>\n"
149 "<![CDATA[Char Data]]>"
155 auto stream = pdfium::MakeRetain<StringWriteStream>();
156 CFX_XMLElement node
(L"test:root"
);
160 EXPECT_EQ(
"<test:root xmlns:test=\"https://example.org/ns1\" />\n",
165 CFX_XMLElement node
(L"node"
);
166 CFX_XMLElement node_child1
(L"node-child"
);
167 node.AppendLastChild(&node_child1);
170 EXPECT_TRUE(found !=
nullptr);
171 EXPECT_EQ(&node_child1, found);
175 CFX_XMLElement node
(L"node"
);
176 CFX_XMLElement node_child1
(L"node-child"
);
177 node.AppendLastChild(&node_child1);
180 EXPECT_TRUE(found ==
nullptr);
184 CFX_XMLElement node
(L"node"
);
185 CFX_XMLElement node_child1
(L"node-child"
);
186 CFX_XMLElement node_child2
(L"node-child"
);
187 CFX_XMLElement node_child3
(L"node-child"
);
188 node.AppendLastChild(&node_child1);
189 node.AppendLastChild(&node_child2);
190 node.AppendLastChild(&node_child3);
192 auto* found = node.GetNthChildNamed(L"node-child", 2);
193 EXPECT_TRUE(found !=
nullptr);
194 EXPECT_EQ(&node_child3, found);
198 CFX_XMLElement node
(L"node"
);
199 CFX_XMLElement node_child1
(L"node-child"
);
200 CFX_XMLElement node_child2
(L"node-child"
);
201 CFX_XMLElement node_child3
(L"node-child"
);
202 node.AppendLastChild(&node_child1);
203 node.AppendLastChild(&node_child2);
204 node.AppendLastChild(&node_child3);
206 auto* found = node.GetNthChildNamed(L"node-child", 5);
207 EXPECT_TRUE(found ==
nullptr);
211 CFX_XMLElement node
(L"node"
);
214 node.AppendLastChild(&text_child1);
216 CFX_XMLElement node_child1
(L"Node child"
);
217 node.AppendLastChild(&node_child1);
220 node_child1.AppendLastChild(&text_child2);
222 CFX_XMLCharData char_data1
(L"Char Data"
);
223 node.AppendLastChild(&char_data1);
CFX_XMLElement * ToXMLElement(CFX_XMLNode *pNode)
CFX_XMLCharData(const WideString &wsCData)
void Save(const RetainPtr< IFX_RetainableWriteStream > &pXMLStream) override
WideString GetNamespacePrefix() const
WideString GetTextData() const
const WideString & GetName() const
CFX_XMLNode * Clone(CFX_XMLDocument *doc) override
CFX_XMLElement(const WideString &wsTag)
bool HasAttribute(const WideString &name) const
WideString GetLocalTagName() const
Type GetType() const override
WideString GetAttribute(const WideString &name) const
WideString GetNamespaceURI() const
void SetAttribute(const WideString &name, const WideString &value)
CFX_XMLElement * GetFirstChildNamed(WideStringView name) const
void RemoveAttribute(const WideString &name)
virtual Type GetType() const =0
CFX_XMLText(const WideString &wsText)
TEST(FXCRYPT, MD5GenerateEmtpyData)