LCOV - code coverage report
Current view: top level - xmloff/qa/unit - uxmloff.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 32 33 97.0 %
Date: 2015-06-13 12:38:46 Functions: 15 16 93.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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             :  */
       9             : 
      10             : #include <sal/config.h>
      11             : #include <test/bootstrapfixture.hxx>
      12             : 
      13             : #include <xmloff/xmlexp.hxx>
      14             : #include <xmloff/xmltoken.hxx>
      15             : #include <xmloff/xmlaustp.hxx>
      16             : #include "SchXMLExport.hxx"
      17             : #include "XMLChartPropertySetMapper.hxx"
      18             : #include "impastpl.hxx"
      19             : #include <comphelper/processfactory.hxx>
      20             : #include <com/sun/star/util/MeasureUnit.hpp>
      21             : 
      22             : using namespace ::xmloff::token;
      23             : using namespace ::com::sun::star;
      24             : 
      25           2 : class Test : public test::BootstrapFixture {
      26             : public:
      27             :     Test();
      28             : 
      29             :     virtual void setUp() SAL_OVERRIDE;
      30             :     virtual void tearDown() SAL_OVERRIDE;
      31             : 
      32             :     void testAutoStylePool();
      33             : 
      34           2 :     CPPUNIT_TEST_SUITE(Test);
      35           1 :     CPPUNIT_TEST(testAutoStylePool);
      36           5 :     CPPUNIT_TEST_SUITE_END();
      37             : private:
      38             :     SvXMLExport *pExport;
      39             : };
      40             : 
      41           1 : Test::Test()
      42           1 :     : pExport( NULL )
      43             : {
      44           1 : }
      45             : 
      46           1 : void Test::setUp()
      47             : {
      48           1 :     BootstrapFixture::setUp();
      49             : 
      50             :     pExport = new SchXMLExport(
      51             :         comphelper::getProcessComponentContext(), "SchXMLExport.Compact",
      52           1 :         SvXMLExportFlags::ALL);
      53           1 : }
      54             : 
      55           1 : void Test::tearDown()
      56             : {
      57           1 :     delete pExport;
      58           1 :     BootstrapFixture::tearDown();
      59           1 : }
      60             : 
      61           1 : void Test::testAutoStylePool()
      62             : {
      63             :     rtl::Reference< SvXMLAutoStylePoolP > xPool(
      64           1 :         new SvXMLAutoStylePoolP( *pExport ) );
      65             :     rtl::Reference< XMLPropertySetMapper > xSetMapper(
      66           2 :         new XMLChartPropertySetMapper( true) );
      67             :     rtl::Reference< XMLChartExportPropertyMapper > xExportPropMapper(
      68           2 :         new XMLChartExportPropertyMapper( xSetMapper, *pExport ) );
      69             : 
      70             :     xPool->AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
      71           1 :                       GetXMLToken( XML_PARAGRAPH ),
      72           1 :                       xExportPropMapper.get(),
      73           2 :                       OUString( "Bob" ) );
      74             : 
      75           2 :     std::vector< XMLPropertyState > aProperties;
      76           2 :     OUString aName = xPool->Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, "", aProperties );
      77             : 
      78             :     // not that interesting but worth checking
      79           1 :     bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != NULL);
      80           1 :     if (bHack)
      81           0 :         CPPUNIT_ASSERT_MESSAGE( "style / naming changed", aName == "Bob" );
      82             :     else
      83           1 :         CPPUNIT_ASSERT_MESSAGE( "style / naming changed", aName == "Bob1" );
      84             : 
      85             :     // find ourselves again:
      86           2 :     OUString aSameName = xPool->Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, "", aProperties );
      87           2 :     CPPUNIT_ASSERT_MESSAGE( "same style not found", aSameName == aName );
      88           1 : }
      89             : 
      90           1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
      91             : 
      92           4 : CPPUNIT_PLUGIN_IMPLEMENT();
      93             : 
      94             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11