tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / sd / qa / unit / uimpress.cxx
blobbd6bb16a75b524ebf669a4b4234499894a1cac59
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 <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>
16 #include <cppuhelper/bootstrap.hxx>
17 #include <comphelper/processfactory.hxx>
19 #include <vcl/svapp.hxx>
20 #include <svx/svdpage.hxx>
21 #include <sddll.hxx>
22 #include <drawdoc.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
28 using namespace ::com::sun::star;
30 namespace {
32 class Test : public CppUnit::TestFixture {
33 public:
34 Test();
36 virtual void setUp() override;
37 virtual void tearDown() override;
39 void testAddPage();
40 void testCustomShow();
42 CPPUNIT_TEST_SUITE(Test);
43 CPPUNIT_TEST(testAddPage);
44 CPPUNIT_TEST(testCustomShow);
45 CPPUNIT_TEST_SUITE_END();
47 private:
48 uno::Reference< uno::XComponentContext > m_xContext;
49 std::unique_ptr<SdDrawDocument> m_pDoc;
52 Test::Test()
53 : m_xContext(cppu::defaultBootstrap_InitialComponentContext())
56 uno::Reference<lang::XMultiComponentFactory> xFactory(m_xContext->getServiceManager());
57 uno::Reference<lang::XMultiServiceFactory> xSM(xFactory, uno::UNO_QUERY_THROW);
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 it's passed around
62 comphelper::setProcessServiceFactory(xSM);
64 InitVCL();
66 SdDLL::Init();
69 void Test::setUp()
71 m_pDoc.reset(new SdDrawDocument(DocumentType::Impress, nullptr));
74 void Test::tearDown()
76 m_pDoc.reset();
79 void Test::testAddPage()
81 rtl::Reference<SdrPage> pPage = m_pDoc->AllocPage(false);
82 m_pDoc->InsertPage(pPage.get());
83 CPPUNIT_ASSERT_EQUAL_MESSAGE("added one page to model",
84 static_cast<sal_uInt16>(1), m_pDoc->GetPageCount());
85 m_pDoc->DeletePage(0);
86 CPPUNIT_ASSERT_EQUAL_MESSAGE("removed one page to model",
87 static_cast<sal_uInt16>(0), m_pDoc->GetPageCount());
89 rtl::Reference<SdrPage> pMasterPage = m_pDoc->AllocPage(true);
90 m_pDoc->InsertMasterPage(pMasterPage.get());
91 CPPUNIT_ASSERT_EQUAL_MESSAGE("added one master page to model",
92 static_cast<sal_uInt16>(1), m_pDoc->GetMasterPageCount());
93 m_pDoc->DeleteMasterPage(0);
94 CPPUNIT_ASSERT_EQUAL_MESSAGE("removed one master page to model",
95 static_cast<sal_uInt16>(0), m_pDoc->GetMasterPageCount());
98 void Test::testCustomShow()
100 CPPUNIT_ASSERT_MESSAGE("test generation of custom show list!",
101 m_pDoc->GetCustomShowList(true));
104 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
108 CPPUNIT_PLUGIN_IMPLEMENT();
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */