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>
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 SwDialogsTest
: public ScreenshotTest
30 css::uno::Reference
<css::lang::XComponent
> component_
;
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 void tearDown() override
;
48 // try to open a dialog
51 CPPUNIT_TEST_SUITE(SwDialogsTest
);
52 CPPUNIT_TEST(openAnyDialog
);
53 CPPUNIT_TEST_SUITE_END();
56 SwDialogsTest::SwDialogsTest()
60 void SwDialogsTest::setUp()
62 ScreenshotTest::setUp();
63 // Make sure the sw library's global pSwResMgr is initialized:
64 component_
= loadFromDesktop(
65 "private:factory/swriter", "com.sun.star.text.TextDocument");
66 // Make sure the swui library's global pSwResMgr is initialized
67 // (alternatively to dynamically loading the library, SwCreateDialogFactory
68 // could be declared in an include file and this CppunitTest link against
70 OUString
url("${LO_LIB_DIR}/" SVLIBRARY("swui"));
71 rtl::Bootstrap::expandMacros(url
); //TODO: detect failure
72 CPPUNIT_ASSERT(libSwui_
.load(url
, SAL_LOADMODULE_GLOBAL
));
73 auto fn
= reinterpret_cast<Fn
>(
74 libSwui_
.getFunctionSymbol("SwCreateDialogFactory"));
75 CPPUNIT_ASSERT(fn
!= nullptr);
79 void SwDialogsTest::tearDown()
81 component_
->dispose();
82 ScreenshotTest::tearDown();
85 void SwDialogsTest::registerKnownDialogsByID(mapType
& /*rKnownDialogs*/)
87 // fill map of known dialogs
90 VclPtr
<VclAbstractDialog
> SwDialogsTest::createDialogByID(sal_uInt32
/*nID*/)
95 void SwDialogsTest::openAnyDialog()
97 /// process input file containing the UXMLDescriptions of the dialogs to dump
98 processDialogBatchFile("sw/qa/unit/data/sw-dialogs-test.txt");
101 CPPUNIT_TEST_SUITE_REGISTRATION(SwDialogsTest
);
103 CPPUNIT_PLUGIN_IMPLEMENT();
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */