Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / cui / qa / unit / cui-dialogs-test.cxx
blobcf8c302fc209ac5f0a606da3767cd73591bc4afd
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 <svx/svdmodel.hxx>
13 #include <svx/svxdlg.hxx>
14 #include <vcl/abstdlg.hxx>
16 using namespace ::com::sun::star;
18 /// Test opening a dialog in cui
19 class CuiDialogsTest : public ScreenshotTest
21 private:
22 std::unique_ptr<SdrModel> mxModel;
23 std::unique_ptr<SfxItemSet> mxAttr;
24 SvxAbstractDialogFactory* mpFact;
26 void initialize();
28 /// helper method to populate KnownDialogs, called in setUp(). Needs to be
29 /// written and has to add entries to KnownDialogs
30 virtual void registerKnownDialogsByID(mapType& rKnownDialogs) override;
32 /// dialog creation for known dialogs by ID. Has to be implemented for
33 /// each registered known dialog
34 virtual VclPtr<VclAbstractDialog> createDialogByID(sal_uInt32 nID) override;
36 public:
37 CuiDialogsTest();
39 // try to open a dialog
40 void openAnyDialog();
42 CPPUNIT_TEST_SUITE(CuiDialogsTest);
43 CPPUNIT_TEST(openAnyDialog);
44 CPPUNIT_TEST_SUITE_END();
47 CuiDialogsTest::CuiDialogsTest() {}
49 void CuiDialogsTest::initialize()
51 mpFact = SvxAbstractDialogFactory::Create();
52 mxModel.reset(new SdrModel(nullptr, nullptr, true));
53 mxModel->GetItemPool().FreezeIdRanges();
54 mxAttr.reset(new SfxItemSet(mxModel->GetItemPool()));
57 void CuiDialogsTest::registerKnownDialogsByID(mapType& rKnownDialogs)
59 // fill map of known dialogs
60 rKnownDialogs["cui/ui/formatcellsdialog.ui"] = 0;
61 rKnownDialogs["cui/ui/textdialog.ui"] = 1;
64 VclPtr<VclAbstractDialog> CuiDialogsTest::createDialogByID(sal_uInt32 nID)
66 VclPtr<VclAbstractDialog> pReturnDialog;
68 switch (nID)
70 case 0: // "cui/ui/formatcellsdialog.ui"
72 pReturnDialog
73 = mpFact->CreateSvxFormatCellsDialog(nullptr, mxAttr.get(), *mxModel, true);
74 break;
77 case 1: // "cui/ui/textdialog.ui"
79 pReturnDialog = mpFact->CreateTextTabDialog(nullptr, mxAttr.get(), nullptr);
80 break;
83 default:
84 break;
87 return pReturnDialog;
90 void CuiDialogsTest::openAnyDialog()
92 initialize();
94 /// process input file containing the UXMLDescriptions of the dialogs to dump
95 processDialogBatchFile(u"cui/qa/unit/data/cui-dialogs-test.txt");
98 CPPUNIT_TEST_SUITE_REGISTRATION(CuiDialogsTest);
100 CPPUNIT_PLUGIN_IMPLEMENT();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */