2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #include "webrtc/libjingle/xmllite/xmlprinter.h"
16 #include "webrtc/libjingle/xmllite/qname.h"
17 #include "webrtc/libjingle/xmllite/xmlelement.h"
18 #include "webrtc/libjingle/xmllite/xmlnsstack.h"
19 #include "webrtc/base/common.h"
20 #include "webrtc/base/gunit.h"
23 using buzz::XmlElement;
24 using buzz::XmlnsStack;
25 using buzz::XmlPrinter;
27 TEST(XmlPrinterTest, TestBasicPrinting) {
28 XmlElement elt(QName("google:test", "first"));
30 XmlPrinter::PrintXml(&ss, &elt);
31 EXPECT_EQ("<test:first xmlns:test=\"google:test\"/>", ss.str());
34 TEST(XmlPrinterTest, TestNamespacedPrinting) {
35 XmlElement elt(QName("google:test", "first"));
36 elt.AddElement(new XmlElement(QName("nested:test", "second")));
40 ns_stack.AddXmlns("gg", "google:test");
41 ns_stack.AddXmlns("", "nested:test");
43 XmlPrinter::PrintXml(&ss, &elt, &ns_stack);
44 EXPECT_EQ("<gg:first><second/></gg:first>", ss.str());