Bump version to 6.4.7.2.M8
[LibreOffice.git] / cui / qa / unit / cui-dialogs-test.cxx
blobfe8091a8e33ec0d9232e360c4972a21ca3056bde
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/strbuf.hxx>
13 #include <osl/file.hxx>
14 #include <sfx2/app.hxx>
15 #include <svx/svdmodel.hxx>
16 #include <svx/svxdlg.hxx>
17 #include <vcl/abstdlg.hxx>
19 using namespace ::com::sun::star;
21 /// Test opening a dialog in cui
22 class CuiDialogsTest : public ScreenshotTest
24 private:
25 std::unique_ptr<SdrModel> mxModel;
26 std::unique_ptr<SfxItemSet> mxAttr;
27 SvxAbstractDialogFactory* mpFact;
29 void initialize();
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 CuiDialogsTest();
42 // try to open a dialog
43 void openAnyDialog();
45 CPPUNIT_TEST_SUITE(CuiDialogsTest);
46 CPPUNIT_TEST(openAnyDialog);
47 CPPUNIT_TEST_SUITE_END();
50 CuiDialogsTest::CuiDialogsTest()
54 void CuiDialogsTest::initialize()
56 mpFact = SvxAbstractDialogFactory::Create();
57 mxModel.reset(new SdrModel(nullptr, nullptr, true));
58 mxModel->GetItemPool().FreezeIdRanges();
59 mxAttr.reset(new SfxItemSet(mxModel->GetItemPool()));
62 void CuiDialogsTest::registerKnownDialogsByID(mapType& rKnownDialogs)
64 // fill map of known dialogs
65 rKnownDialogs["cui/ui/formatcellsdialog.ui"] = 0;
66 rKnownDialogs["cui/ui/textdialog.ui"] = 1;
69 VclPtr<VclAbstractDialog> CuiDialogsTest::createDialogByID(sal_uInt32 nID)
71 VclPtr<VclAbstractDialog> pReturnDialog;
73 switch ( nID )
75 case 0: // "cui/ui/formatcellsdialog.ui"
77 pReturnDialog = mpFact->CreateSvxFormatCellsDialog(
78 nullptr, mxAttr.get(), *mxModel);
79 break;
82 case 1: // "cui/ui/textdialog.ui"
84 pReturnDialog = mpFact->CreateTextTabDialog(
85 nullptr, mxAttr.get(), nullptr);
86 break;
89 default:
90 break;
93 return pReturnDialog;
96 void CuiDialogsTest::openAnyDialog()
98 initialize();
100 /// process input file containing the UXMLDescriptions of the dialogs to dump
101 processDialogBatchFile("cui/qa/unit/data/cui-dialogs-test.txt");
104 CPPUNIT_TEST_SUITE_REGISTRATION(CuiDialogsTest);
106 CPPUNIT_PLUGIN_IMPLEMENT();
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */