LCOV - code coverage report
Current view: top level - sd/qa/unit - uimpress.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 44 44 100.0 %
Date: 2015-06-13 12:38:46 Functions: 16 17 94.1 %
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/types.h>
      11             : #include "cppunit/TestAssert.h"
      12             : #include "cppunit/TestFixture.h"
      13             : #include "cppunit/extensions/HelperMacros.h"
      14             : #include "cppunit/plugin/TestPlugIn.h"
      15             : 
      16             : #include <cppuhelper/bootstrap.hxx>
      17             : #include <comphelper/processfactory.hxx>
      18             : 
      19             : #include <vcl/svapp.hxx>
      20             : #include <sddll.hxx>
      21             : #include <drawdoc.hxx>
      22             : 
      23             : #include <iostream>
      24             : #include <vector>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : 
      28             : namespace {
      29             : 
      30             : class Test : public CppUnit::TestFixture {
      31             : public:
      32             :     Test();
      33             :     virtual ~Test();
      34             : 
      35             :     virtual void setUp() SAL_OVERRIDE;
      36             :     virtual void tearDown() SAL_OVERRIDE;
      37             : 
      38             :     void testAddPage();
      39             :     void testCustomShow();
      40             : 
      41           2 :     CPPUNIT_TEST_SUITE(Test);
      42           1 :     CPPUNIT_TEST(testAddPage);
      43           1 :     CPPUNIT_TEST(testCustomShow);
      44           5 :     CPPUNIT_TEST_SUITE_END();
      45             : 
      46             : private:
      47             :     uno::Reference< uno::XComponentContext > m_xContext;
      48             :     SdDrawDocument* m_pDoc;
      49             : };
      50             : 
      51           2 : Test::Test()
      52           2 :     : m_pDoc(0)
      53             : {
      54           2 :     m_xContext = cppu::defaultBootstrap_InitialComponentContext();
      55             : 
      56           2 :     uno::Reference<lang::XMultiComponentFactory> xFactory(m_xContext->getServiceManager());
      57           4 :     uno::Reference<lang::XMultiServiceFactory> xSM(xFactory, uno::UNO_QUERY_THROW);
      58             : 
      59             :     //Without this we're crashing because callees are using
      60             :     //getProcessServiceFactory.  In general those should be removed in favour
      61             :     //of retaining references to the root ServiceFactory as its passed around
      62           2 :     comphelper::setProcessServiceFactory(xSM);
      63             : 
      64           2 :     InitVCL();
      65             : 
      66           4 :     SdDLL::Init();
      67           2 : }
      68             : 
      69           2 : void Test::setUp()
      70             : {
      71           2 :     m_pDoc = new SdDrawDocument(DOCUMENT_TYPE_IMPRESS, NULL);
      72           2 : }
      73             : 
      74           2 : void Test::tearDown()
      75             : {
      76           2 :     delete m_pDoc;
      77           2 : }
      78             : 
      79           6 : Test::~Test()
      80             : {
      81           2 :     uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose();
      82           4 : }
      83             : 
      84           1 : void Test::testAddPage()
      85             : {
      86           1 :     SdrPage* pPage = m_pDoc->AllocPage(false);
      87           1 :     m_pDoc->InsertPage(pPage);
      88           2 :     CPPUNIT_ASSERT_MESSAGE("added one page to model",
      89           1 :                            m_pDoc->GetPageCount()==1);
      90           1 :     m_pDoc->DeletePage(0);
      91           2 :     CPPUNIT_ASSERT_MESSAGE("removed one page to model",
      92           1 :                            m_pDoc->GetPageCount()==0);
      93             : 
      94           1 :     SdrPage* pMasterPage = m_pDoc->AllocPage(true);
      95           1 :     m_pDoc->InsertMasterPage(pMasterPage);
      96           2 :     CPPUNIT_ASSERT_MESSAGE("added one master page to model",
      97           1 :                            m_pDoc->GetMasterPageCount()==1);
      98           1 :     m_pDoc->DeleteMasterPage(0);
      99           2 :     CPPUNIT_ASSERT_MESSAGE("removed one master page to model",
     100           1 :                            m_pDoc->GetMasterPageCount()==0);
     101           1 : }
     102             : 
     103           1 : void Test::testCustomShow()
     104             : {
     105           2 :     CPPUNIT_ASSERT_MESSAGE("test generation of custom show list!",
     106           1 :                            m_pDoc->GetCustomShowList(true));
     107           1 : }
     108             : 
     109           1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
     110             : 
     111             : }
     112             : 
     113           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11