Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / unit / sw-dialogs-test.cxx
blob48652ca1db74adc63eb93ed1a15ce922062791b5
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 <osl/module.hxx>
14 #include <tools/svlibrary.h>
15 #include <vcl/abstdlg.hxx>
17 class SwAbstractDialogFactory;
19 using namespace ::com::sun::star;
21 extern "C" { using Fn = SwAbstractDialogFactory * (*)(); }
22 // sw/source/ui/dialog/swuiexp.cxx
24 /// Test opening a dialog in sw
25 class SwDialogsTest : public ScreenshotTest
27 private:
28 css::uno::Reference<css::lang::XComponent> component_;
29 osl::Module libSwui_;
31 /// helper method to populate KnownDialogs, called in setUp(). Needs to be
32 /// written and has to add entries to KnownDialogs
33 virtual void registerKnownDialogsByID(mapType& rKnownDialogs) override;
35 /// dialog creation for known dialogs by ID. Has to be implemented for
36 /// each registered known dialog
37 virtual VclPtr<VclAbstractDialog> createDialogByID(sal_uInt32 nID) override;
39 public:
40 SwDialogsTest();
42 void setUp() override;
44 void tearDown() override;
46 // try to open a dialog
47 void openAnyDialog();
49 CPPUNIT_TEST_SUITE(SwDialogsTest);
50 CPPUNIT_TEST(openAnyDialog);
51 CPPUNIT_TEST_SUITE_END();
54 SwDialogsTest::SwDialogsTest()
58 void SwDialogsTest::setUp()
60 ScreenshotTest::setUp();
61 // Make sure the sw library's global pSwResMgr is initialized:
62 component_ = loadFromDesktop(
63 "private:factory/swriter", "com.sun.star.text.TextDocument");
64 // Make sure the swui library's global pSwResMgr is initialized
65 // (alternatively to dynamically loading the library, SwCreateDialogFactory
66 // could be declared in an include file and this CppunitTest link against
67 // the swui library):
68 OUString url("${LO_LIB_DIR}/" SVLIBRARY("swui"));
69 rtl::Bootstrap::expandMacros(url); //TODO: detect failure
70 CPPUNIT_ASSERT(libSwui_.load(url, SAL_LOADMODULE_GLOBAL));
71 auto fn = reinterpret_cast<Fn>(
72 libSwui_.getFunctionSymbol("SwCreateDialogFactory"));
73 CPPUNIT_ASSERT(fn != nullptr);
74 (*fn)();
77 void SwDialogsTest::tearDown()
79 component_->dispose();
80 ScreenshotTest::tearDown();
83 void SwDialogsTest::registerKnownDialogsByID(mapType& /*rKnownDialogs*/)
85 // fill map of known dialogs
88 VclPtr<VclAbstractDialog> SwDialogsTest::createDialogByID(sal_uInt32 /*nID*/)
90 return nullptr;
93 void SwDialogsTest::openAnyDialog()
95 /// process input file containing the UXMLDescriptions of the dialogs to dump
96 processDialogBatchFile(u"sw/qa/unit/data/sw-dialogs-test.txt");
99 CPPUNIT_TEST_SUITE_REGISTRATION(SwDialogsTest);
101 CPPUNIT_PLUGIN_IMPLEMENT();
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */