LCOV - code coverage report
Current view: top level - libreoffice/sd/qa/unit - uimpress.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 44 100.0 %
Date: 2012-12-27 Functions: 13 14 92.9 %
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             :  * 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           2 :     CPPUNIT_TEST_SUITE(Test);
      61           1 :     CPPUNIT_TEST(testAddPage);
      62           1 :     CPPUNIT_TEST(testCustomShow);
      63           2 :     CPPUNIT_TEST_SUITE_END();
      64             : 
      65             : private:
      66             :     uno::Reference< uno::XComponentContext > m_xContext;
      67             :     SdDrawDocument* m_pDoc;
      68             : };
      69             : 
      70           2 : Test::Test()
      71           2 :     : m_pDoc(0)
      72             : {
      73           2 :     m_xContext = cppu::defaultBootstrap_InitialComponentContext();
      74             : 
      75           2 :     uno::Reference<lang::XMultiComponentFactory> xFactory(m_xContext->getServiceManager());
      76           2 :     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           2 :     comphelper::setProcessServiceFactory(xSM);
      82             : 
      83           2 :     InitVCL();
      84             : 
      85           2 :     SdDLL::Init();
      86           2 : }
      87             : 
      88           2 : void Test::setUp()
      89             : {
      90           2 :     m_pDoc = new SdDrawDocument(DOCUMENT_TYPE_IMPRESS, NULL);
      91           2 : }
      92             : 
      93           2 : void Test::tearDown()
      94             : {
      95           2 :     delete m_pDoc;
      96           2 : }
      97             : 
      98           6 : Test::~Test()
      99             : {
     100           2 :     uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose();
     101           4 : }
     102             : 
     103           1 : void Test::testAddPage()
     104             : {
     105           1 :     SdrPage* pPage = m_pDoc->AllocPage(false);
     106           1 :     m_pDoc->InsertPage(pPage);
     107           2 :     CPPUNIT_ASSERT_MESSAGE("added one page to model",
     108           1 :                            m_pDoc->GetPageCount()==1);
     109           1 :     m_pDoc->DeletePage(0);
     110           2 :     CPPUNIT_ASSERT_MESSAGE("removed one page to model",
     111           1 :                            m_pDoc->GetPageCount()==0);
     112             : 
     113           1 :     SdrPage* pMasterPage = m_pDoc->AllocPage(true);
     114           1 :     m_pDoc->InsertMasterPage(pMasterPage);
     115           2 :     CPPUNIT_ASSERT_MESSAGE("added one master page to model",
     116           1 :                            m_pDoc->GetMasterPageCount()==1);
     117           1 :     m_pDoc->DeleteMasterPage(0);
     118           2 :     CPPUNIT_ASSERT_MESSAGE("removed one master page to model",
     119           1 :                            m_pDoc->GetMasterPageCount()==0);
     120           1 : }
     121             : 
     122           1 : void Test::testCustomShow()
     123             : {
     124           2 :     CPPUNIT_ASSERT_MESSAGE("test generation of custom show list!",
     125           1 :                            m_pDoc->GetCustomShowList(sal_True));
     126           1 : }
     127             : 
     128           1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
     129             : 
     130             : }
     131             : 
     132           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10