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 <rtl/strbuf.hxx>
14 #include <osl/file.hxx>
15 #include <tools/svlibrary.h>
16 #include <sfx2/app.hxx>
17 #include <vcl/abstdlg.hxx>
19 #include <swabstdlg.hxx>
22 using namespace ::com::sun::star
;
24 extern "C" { using Fn
= SwAbstractDialogFactory
* (*)(); }
25 // sw/source/ui/dialog/swuiexp.cxx
27 /// Test opening a dialog in sw
28 class SwDialogsTest2
: public ScreenshotTest
33 /// helper method to populate KnownDialogs, called in setUp(). Needs to be
34 /// written and has to add entries to KnownDialogs
35 virtual void registerKnownDialogsByID(mapType
& rKnownDialogs
) override
;
37 /// dialog creation for known dialogs by ID. Has to be implemented for
38 /// each registered known dialog
39 virtual VclPtr
<VclAbstractDialog
> createDialogByID(sal_uInt32 nID
) override
;
44 void setUp() override
;
46 // try to open a dialog
49 CPPUNIT_TEST_SUITE(SwDialogsTest2
);
50 CPPUNIT_TEST(openAnyDialog
);
51 CPPUNIT_TEST_SUITE_END();
54 SwDialogsTest2::SwDialogsTest2()
58 void SwDialogsTest2::setUp()
60 ScreenshotTest::setUp();
62 // Make sure the swui library's global pSwResMgr is initialized
63 // (alternatively to dynamically loading the library, SwCreateDialogFactory
64 // could be declared in an include file and this CppunitTest link against
66 OUString
url("${LO_LIB_DIR}/" SVLIBRARY("swui"));
67 rtl::Bootstrap::expandMacros(url
); //TODO: detect failure
68 CPPUNIT_ASSERT(libSwui_
.load(url
, SAL_LOADMODULE_GLOBAL
));
69 auto fn
= reinterpret_cast<Fn
>(
70 libSwui_
.getFunctionSymbol("SwCreateDialogFactory"));
71 CPPUNIT_ASSERT(fn
!= nullptr);
75 void SwDialogsTest2::registerKnownDialogsByID(mapType
& /*rKnownDialogs*/)
77 // fill map of known dialogs
80 VclPtr
<VclAbstractDialog
> SwDialogsTest2::createDialogByID(sal_uInt32
/*nID*/)
85 void SwDialogsTest2::openAnyDialog()
87 /// process input file containing the UXMLDescriptions of the dialogs to dump
88 processDialogBatchFile("sw/qa/unit/data/sw-dialogs-test_2.txt");
91 CPPUNIT_TEST_SUITE_REGISTRATION(SwDialogsTest2
);
93 CPPUNIT_PLUGIN_IMPLEMENT();
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */