OInterfaceContainerHelper3 needs to be thread-safe
[LibreOffice.git] / cui / qa / unit / cui-dialogs-test.cxx
blob85f6b5f55bbf20e326ca53cbb3d55df398aa3822
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 = mpFact->CreateSvxFormatCellsDialog(nullptr, mxAttr.get(), *mxModel);
73 break;
76 case 1: // "cui/ui/textdialog.ui"
78 pReturnDialog = mpFact->CreateTextTabDialog(nullptr, mxAttr.get(), nullptr);
79 break;
82 default:
83 break;
86 return pReturnDialog;
89 void CuiDialogsTest::openAnyDialog()
91 initialize();
93 /// process input file containing the UXMLDescriptions of the dialogs to dump
94 processDialogBatchFile("cui/qa/unit/data/cui-dialogs-test.txt");
97 CPPUNIT_TEST_SUITE_REGISTRATION(CuiDialogsTest);
99 CPPUNIT_PLUGIN_IMPLEMENT();
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */