Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sw / qa / unit / sw-dialogs-test.cxx
blobf5968d36b7e7ef443c19a98a29d62649d26c16ca
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 <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
29 private:
30 css::uno::Reference<css::lang::XComponent> component_;
31 osl::Module libSwui_;
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;
41 public:
42 SwDialogsTest();
44 void setUp() override;
46 void tearDown() override;
48 // try to open a dialog
49 void openAnyDialog();
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
69 // the swui library):
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);
76 (*fn)();
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*/)
92 return nullptr;
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: */