LCOV - code coverage report
Current view: top level - sd/qa/unit - uimpress.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 44 100.0 %
Date: 2012-08-25 Functions: 13 14 92.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 94 192 49.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4                 :            :  *
       5                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :            :  * the License. You may obtain a copy of the License at
       8                 :            :  * http://www.mozilla.org/MPL/
       9                 :            :  *
      10                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :            :  * for the specific language governing rights and limitations under the
      13                 :            :  * License.
      14                 :            :  *
      15                 :            :  * The Initial Developer of the Original Code is
      16                 :            :  *       Novell, Inc.
      17                 :            :  * Portions created by the Initial Developer are Copyright (C) 2010 the
      18                 :            :  * Initial Developer. All Rights Reserved.
      19                 :            :  *
      20                 :            :  * Contributor(s):  Thorsten Behrens <tbehrens@novell.com>
      21                 :            :  *
      22                 :            :  * Alternatively, the contents of this file may be used under the terms of
      23                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26                 :            :  * instead of those above.
      27                 :            :  */
      28                 :            : 
      29                 :            : #include <sal/types.h>
      30                 :            : #include "cppunit/TestAssert.h"
      31                 :            : #include "cppunit/TestFixture.h"
      32                 :            : #include "cppunit/extensions/HelperMacros.h"
      33                 :            : #include "cppunit/plugin/TestPlugIn.h"
      34                 :            : 
      35                 :            : #include <cppuhelper/bootstrap.hxx>
      36                 :            : #include <comphelper/processfactory.hxx>
      37                 :            : 
      38                 :            : #include <vcl/svapp.hxx>
      39                 :            : #include <sddll.hxx>
      40                 :            : #include <drawdoc.hxx>
      41                 :            : 
      42                 :            : #include <iostream>
      43                 :            : #include <vector>
      44                 :            : 
      45                 :            : using namespace ::com::sun::star;
      46                 :            : 
      47                 :            : namespace {
      48                 :            : 
      49                 :            : class Test : public CppUnit::TestFixture {
      50                 :            : public:
      51                 :            :     Test();
      52                 :            :     ~Test();
      53                 :            : 
      54                 :            :     virtual void setUp();
      55                 :            :     virtual void tearDown();
      56                 :            : 
      57                 :            :     void testAddPage();
      58                 :            :     void testCustomShow();
      59                 :            : 
      60 [ +  - ][ +  - ]:          6 :     CPPUNIT_TEST_SUITE(Test);
         [ +  - ][ +  - ]
                 [ #  # ]
      61 [ +  - ][ +  - ]:          3 :     CPPUNIT_TEST(testAddPage);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      62 [ +  - ][ +  - ]:          3 :     CPPUNIT_TEST(testCustomShow);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      63 [ +  - ][ +  - ]:          6 :     CPPUNIT_TEST_SUITE_END();
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      64                 :            : 
      65                 :            : private:
      66                 :            :     uno::Reference< uno::XComponentContext > m_xContext;
      67                 :            :     SdDrawDocument* m_pDoc;
      68                 :            : };
      69                 :            : 
      70                 :          6 : Test::Test()
      71                 :          6 :     : m_pDoc(0)
      72                 :            : {
      73 [ +  - ][ +  - ]:          6 :     m_xContext = cppu::defaultBootstrap_InitialComponentContext();
      74                 :            : 
      75 [ +  - ][ +  - ]:          6 :     uno::Reference<lang::XMultiComponentFactory> xFactory(m_xContext->getServiceManager());
      76         [ +  - ]:          6 :     uno::Reference<lang::XMultiServiceFactory> xSM(xFactory, uno::UNO_QUERY_THROW);
      77                 :            : 
      78                 :            :     //Without this we're crashing because callees are using
      79                 :            :     //getProcessServiceFactory.  In general those should be removed in favour
      80                 :            :     //of retaining references to the root ServiceFactory as its passed around
      81         [ +  - ]:          6 :     comphelper::setProcessServiceFactory(xSM);
      82                 :            : 
      83         [ +  - ]:          6 :     InitVCL(xSM);
      84                 :            : 
      85         [ +  - ]:          6 :     SdDLL::Init();
      86                 :          6 : }
      87                 :            : 
      88                 :          6 : void Test::setUp()
      89                 :            : {
      90         [ +  - ]:          6 :     m_pDoc = new SdDrawDocument(DOCUMENT_TYPE_IMPRESS, NULL);
      91                 :          6 : }
      92                 :            : 
      93                 :          6 : void Test::tearDown()
      94                 :            : {
      95         [ +  - ]:          6 :     delete m_pDoc;
      96                 :          6 : }
      97                 :            : 
      98                 :          6 : Test::~Test()
      99                 :            : {
     100 [ +  - ][ +  - ]:          6 :     uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose();
                 [ +  - ]
     101         [ -  + ]:         12 : }
     102                 :            : 
     103                 :          3 : void Test::testAddPage()
     104                 :            : {
     105                 :          3 :     SdrPage* pPage = m_pDoc->AllocPage(false);
     106                 :          3 :     m_pDoc->InsertPage(pPage);
     107 [ +  - ][ +  - ]:          6 :     CPPUNIT_ASSERT_MESSAGE("added one page to model",
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     108         [ +  - ]:          3 :                            m_pDoc->GetPageCount()==1);
     109                 :          3 :     m_pDoc->DeletePage(0);
     110 [ +  - ][ +  - ]:          6 :     CPPUNIT_ASSERT_MESSAGE("removed one page to model",
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     111         [ +  - ]:          3 :                            m_pDoc->GetPageCount()==0);
     112                 :            : 
     113                 :          3 :     SdrPage* pMasterPage = m_pDoc->AllocPage(true);
     114                 :          3 :     m_pDoc->InsertMasterPage(pMasterPage);
     115 [ +  - ][ +  - ]:          6 :     CPPUNIT_ASSERT_MESSAGE("added one master page to model",
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     116         [ +  - ]:          3 :                            m_pDoc->GetMasterPageCount()==1);
     117                 :          3 :     m_pDoc->DeleteMasterPage(0);
     118 [ +  - ][ +  - ]:          6 :     CPPUNIT_ASSERT_MESSAGE("removed one master page to model",
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     119         [ +  - ]:          3 :                            m_pDoc->GetMasterPageCount()==0);
     120                 :          3 : }
     121                 :            : 
     122                 :          3 : void Test::testCustomShow()
     123                 :            : {
     124 [ +  - ][ +  - ]:          6 :     CPPUNIT_ASSERT_MESSAGE("test generation of custom show list!",
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     125         [ +  - ]:          3 :                            m_pDoc->GetCustomShowList(sal_True));
     126                 :          3 : }
     127                 :            : 
     128                 :          3 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
     129                 :            : 
     130                 :            : }
     131                 :            : 
     132 [ +  - ][ +  - ]:         12 : CPPUNIT_PLUGIN_IMPLEMENT();
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
     133                 :            : 
     134                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10