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 <osl/module.hxx>
14 #include <tools/svlibrary.h>
15 #include <vcl/abstdlg.hxx>
17 class SwAbstractDialogFactory
;
19 using namespace ::com::sun::star
;
21 extern "C" { using Fn
= SwAbstractDialogFactory
* (*)(); }
22 // sw/source/ui/dialog/swuiexp.cxx
24 /// Test opening a dialog in sw
25 class SwDialogsTest
: public ScreenshotTest
28 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 // (alternatively to dynamically loading the library, SwCreateDialogFactory
66 // could be declared in an include file and this CppunitTest link against
68 OUString
url("${LO_LIB_DIR}/" SVLIBRARY("swui"));
69 rtl::Bootstrap::expandMacros(url
); //TODO: detect failure
70 CPPUNIT_ASSERT(libSwui_
.load(url
, SAL_LOADMODULE_GLOBAL
));
71 auto fn
= reinterpret_cast<Fn
>(
72 libSwui_
.getFunctionSymbol("SwCreateDialogFactory"));
73 CPPUNIT_ASSERT(fn
!= nullptr);
77 void SwDialogsTest::tearDown()
79 component_
->dispose();
80 ScreenshotTest::tearDown();
83 void SwDialogsTest::registerKnownDialogsByID(mapType
& /*rKnownDialogs*/)
85 // fill map of known dialogs
88 VclPtr
<VclAbstractDialog
> SwDialogsTest::createDialogByID(sal_uInt32
/*nID*/)
93 void SwDialogsTest::openAnyDialog()
95 /// process input file containing the UXMLDescriptions of the dialogs to dump
96 processDialogBatchFile(u
"sw/qa/unit/data/sw-dialogs-test.txt");
99 CPPUNIT_TEST_SUITE_REGISTRATION(SwDialogsTest
);
101 CPPUNIT_PLUGIN_IMPLEMENT();
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */