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>
19 class SwAbstractDialogFactory
;
21 using namespace ::com::sun::star
;
23 extern "C" { using Fn
= SwAbstractDialogFactory
* (*)(); }
24 // sw/source/ui/dialog/swuiexp.cxx
26 /// Test opening a dialog in sw
27 class SwDialogsTest2
: public ScreenshotTest
32 /// helper method to populate KnownDialogs, called in setUp(). Needs to be
33 /// written and has to add entries to KnownDialogs
34 virtual void registerKnownDialogsByID(mapType
& rKnownDialogs
) override
;
36 /// dialog creation for known dialogs by ID. Has to be implemented for
37 /// each registered known dialog
38 virtual VclPtr
<VclAbstractDialog
> createDialogByID(sal_uInt32 nID
) override
;
43 void setUp() override
;
45 // try to open a dialog
48 CPPUNIT_TEST_SUITE(SwDialogsTest2
);
49 CPPUNIT_TEST(openAnyDialog
);
50 CPPUNIT_TEST_SUITE_END();
53 SwDialogsTest2::SwDialogsTest2()
57 void SwDialogsTest2::setUp()
59 ScreenshotTest::setUp();
61 // Make sure the swui library's global pSwResMgr is initialized
62 // (alternatively to dynamically loading the library, SwCreateDialogFactory
63 // could be declared in an include file and this CppunitTest link against
65 OUString
url("${LO_LIB_DIR}/" SVLIBRARY("swui"));
66 rtl::Bootstrap::expandMacros(url
); //TODO: detect failure
67 CPPUNIT_ASSERT(libSwui_
.load(url
, SAL_LOADMODULE_GLOBAL
));
68 auto fn
= reinterpret_cast<Fn
>(
69 libSwui_
.getFunctionSymbol("SwCreateDialogFactory"));
70 CPPUNIT_ASSERT(fn
!= nullptr);
74 void SwDialogsTest2::registerKnownDialogsByID(mapType
& /*rKnownDialogs*/)
76 // fill map of known dialogs
79 VclPtr
<VclAbstractDialog
> SwDialogsTest2::createDialogByID(sal_uInt32
/*nID*/)
84 void SwDialogsTest2::openAnyDialog()
86 /// process input file containing the UXMLDescriptions of the dialogs to dump
87 processDialogBatchFile(u
"sw/qa/unit/data/sw-dialogs-test_2.txt");
90 CPPUNIT_TEST_SUITE_REGISTRATION(SwDialogsTest2
);
92 CPPUNIT_PLUGIN_IMPLEMENT();
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */