calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / tools / qa / cppunit / test_xmlwalker.cxx
blobec0a695b62d13ab956c08ab184e11d06b4a0ae55
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <cppunit/extensions/HelperMacros.h>
11 #include <test/bootstrapfixture.hxx>
12 #include <rtl/ustring.hxx>
13 #include <tools/stream.hxx>
14 #include <tools/XmlWalker.hxx>
16 namespace
18 class XmlWalkerTest : public test::BootstrapFixture
20 OUString maBasePath;
22 public:
23 XmlWalkerTest()
24 : BootstrapFixture(true, false)
28 virtual void setUp() override { maBasePath = m_directories.getURLFromSrc(u"/tools/qa/data/"); }
30 void testReadXML();
32 CPPUNIT_TEST_SUITE(XmlWalkerTest);
33 CPPUNIT_TEST(testReadXML);
34 CPPUNIT_TEST_SUITE_END();
37 void XmlWalkerTest::testReadXML()
39 OUString aXmlFilePath = maBasePath + "test.xml";
41 tools::XmlWalker aWalker;
42 SvFileStream aFileStream(aXmlFilePath, StreamMode::READ);
43 CPPUNIT_ASSERT(aWalker.open(&aFileStream));
44 CPPUNIT_ASSERT_EQUAL(OString("root"), aWalker.name());
45 CPPUNIT_ASSERT_EQUAL(OString("Hello World"), aWalker.attribute("root-attr"));
47 int nNumberOfChildNodes = 0;
49 aWalker.children();
50 while (aWalker.isValid())
52 if (aWalker.name() == "child")
54 nNumberOfChildNodes++;
56 CPPUNIT_ASSERT_EQUAL(OString(OString::number(nNumberOfChildNodes)),
57 aWalker.attribute("number"));
59 if (nNumberOfChildNodes == 1) // only the first node has the attribute
60 CPPUNIT_ASSERT_EQUAL(OString("123"), aWalker.attribute("attribute"));
61 else
62 CPPUNIT_ASSERT_EQUAL(OString(), aWalker.attribute("attribute"));
64 aWalker.children();
65 while (aWalker.isValid())
67 if (aWalker.name() == "grandchild")
69 CPPUNIT_ASSERT_EQUAL(OString("ABC"), aWalker.attribute("attribute1"));
70 CPPUNIT_ASSERT_EQUAL(OString("CDE"), aWalker.attribute("attribute2"));
71 CPPUNIT_ASSERT_EQUAL(OString("Content"), aWalker.content());
73 aWalker.next();
75 aWalker.parent();
77 else if (aWalker.name() == "with-namespace")
79 CPPUNIT_ASSERT_EQUAL(OString("adobe:ns:meta/"), aWalker.namespaceHref());
80 CPPUNIT_ASSERT_EQUAL(OString("xx"), aWalker.namespacePrefix());
82 aWalker.next();
84 aWalker.parent();
86 CPPUNIT_ASSERT_EQUAL(3, nNumberOfChildNodes);
89 CPPUNIT_TEST_SUITE_REGISTRATION(XmlWalkerTest);
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */