1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <sal/config.h>
11 #include <test/screenshot_test.hxx>
12 #include <rtl/bootstrap.hxx>
13 #include <tools/svlibrary.h>
14 #include <vcl/abstdlg.hxx>
15 #include <comphelper/processfactory.hxx>
16 #include <com/sun/star/text/DialogFactoryService.hpp>
18 class SwAbstractDialogFactory
;
20 using namespace ::com::sun::star
;
22 extern "C" { using Fn
= SwAbstractDialogFactory
* (*)(); }
23 // sw/source/ui/dialog/swuiexp.cxx
25 /// Test opening a dialog in sw
26 class SwDialogsTest
: public ScreenshotTest
29 css::uno::Reference
<css::lang::XComponent
> component_
;
31 /// helper method to populate KnownDialogs, called in setUp(). Needs to be
32 /// written and has to add entries to KnownDialogs
33 virtual void registerKnownDialogsByID(mapType
& rKnownDialogs
) override
;
35 /// dialog creation for known dialogs by ID. Has to be implemented for
36 /// each registered known dialog
37 virtual VclPtr
<VclAbstractDialog
> createDialogByID(sal_uInt32 nID
) override
;
42 void setUp() override
;
44 void tearDown() override
;
46 // try to open a dialog
49 CPPUNIT_TEST_SUITE(SwDialogsTest
);
50 CPPUNIT_TEST(openAnyDialog
);
51 CPPUNIT_TEST_SUITE_END();
54 SwDialogsTest::SwDialogsTest()
58 void SwDialogsTest::setUp()
60 ScreenshotTest::setUp();
61 // Make sure the sw library's global pSwResMgr is initialized:
62 component_
= loadFromDesktop(
63 "private:factory/swriter", "com.sun.star.text.TextDocument");
64 // Make sure the swui library's global pSwResMgr is initialized
65 auto xService
= css::text::DialogFactoryService::create(comphelper::getProcessComponentContext());
66 CPPUNIT_ASSERT(xService
.is());
67 // get a factory instance
68 SwAbstractDialogFactory
* pFactory
= reinterpret_cast<SwAbstractDialogFactory
*>(xService
->getSomething({}));
69 CPPUNIT_ASSERT(pFactory
!= nullptr);
72 void SwDialogsTest::tearDown()
74 component_
->dispose();
75 ScreenshotTest::tearDown();
78 void SwDialogsTest::registerKnownDialogsByID(mapType
& /*rKnownDialogs*/)
80 // fill map of known dialogs
83 VclPtr
<VclAbstractDialog
> SwDialogsTest::createDialogByID(sal_uInt32
/*nID*/)
88 void SwDialogsTest::openAnyDialog()
90 /// process input file containing the UXMLDescriptions of the dialogs to dump
91 processDialogBatchFile(u
"sw/qa/unit/data/sw-dialogs-test.txt");
94 CPPUNIT_TEST_SUITE_REGISTRATION(SwDialogsTest
);
96 CPPUNIT_PLUGIN_IMPLEMENT();
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */