Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / sw / qa / unit / sw-dialogs-test.cxx
blob22c7f4f740d845f19dbfc787755ac4bd003a8cc2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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 <sfx2/app.hxx>
16 #include <vcl/abstdlg.hxx>
18 #include <swabstdlg.hxx>
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
28 private:
29 css::uno::Reference<css::lang::XComponent> component_;
30 osl::Module libSwui_;
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;
40 public:
41 SwDialogsTest();
43 void setUp() override;
45 void tearDown() override;
47 // try to open a dialog
48 void openAnyDialog();
50 CPPUNIT_TEST_SUITE(SwDialogsTest);
51 CPPUNIT_TEST(openAnyDialog);
52 CPPUNIT_TEST_SUITE_END();
55 SwDialogsTest::SwDialogsTest()
59 void SwDialogsTest::setUp()
61 ScreenshotTest::setUp();
62 // Make sure the sw library's global pSwResMgr is initialized:
63 component_ = loadFromDesktop(
64 "private:factory/swriter", "com.sun.star.text.TextDocument");
65 // Make sure the swui library's global pSwResMgr is initialized
66 // (alternatively to dynamically loading the library, SwCreateDialogFactory
67 // could be declared in an include file and this CppunitTest link against
68 // the swui library):
69 OUString url("${LO_LIB_DIR}/" SVLIBRARY("swui"));
70 rtl::Bootstrap::expandMacros(url); //TODO: detect failure
71 CPPUNIT_ASSERT(libSwui_.load(url, SAL_LOADMODULE_GLOBAL));
72 auto fn = reinterpret_cast<Fn>(
73 libSwui_.getFunctionSymbol("SwCreateDialogFactory"));
74 CPPUNIT_ASSERT(fn != nullptr);
75 (*fn)();
78 void SwDialogsTest::tearDown()
80 component_->dispose();
81 ScreenshotTest::tearDown();
84 void SwDialogsTest::registerKnownDialogsByID(mapType& /*rKnownDialogs*/)
86 // fill map of known dialogs
89 VclPtr<VclAbstractDialog> SwDialogsTest::createDialogByID(sal_uInt32 /*nID*/)
91 return nullptr;
94 void SwDialogsTest::openAnyDialog()
96 /// process input file containing the UXMLDescriptions of the dialogs to dump
97 processDialogBatchFile("sw/qa/unit/data/sw-dialogs-test.txt");
100 CPPUNIT_TEST_SUITE_REGISTRATION(SwDialogsTest);
102 CPPUNIT_PLUGIN_IMPLEMENT();
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */