1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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
22 std::unique_ptr
<SdrModel
> mxModel
;
23 std::unique_ptr
<SfxItemSet
> mxAttr
;
24 SvxAbstractDialogFactory
* mpFact
;
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
;
39 // try to open a dialog
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 mxAttr
.reset(new SfxItemSet(mxModel
->GetItemPool()));
56 void CuiDialogsTest::registerKnownDialogsByID(mapType
& rKnownDialogs
)
58 // fill map of known dialogs
59 rKnownDialogs
["cui/ui/formatcellsdialog.ui"_ostr
] = 0;
60 rKnownDialogs
["cui/ui/textdialog.ui"_ostr
] = 1;
63 VclPtr
<VclAbstractDialog
> CuiDialogsTest::createDialogByID(sal_uInt32 nID
)
65 VclPtr
<VclAbstractDialog
> pReturnDialog
;
69 case 0: // "cui/ui/formatcellsdialog.ui"
71 pReturnDialog
= mpFact
->CreateSvxFormatCellsDialog(nullptr, *mxAttr
, *mxModel
, true);
75 case 1: // "cui/ui/textdialog.ui"
77 pReturnDialog
= mpFact
->CreateTextTabDialog(nullptr, mxAttr
.get(), nullptr);
88 void CuiDialogsTest::openAnyDialog()
92 /// process input file containing the UXMLDescriptions of the dialogs to dump
93 processDialogBatchFile(u
"cui/qa/unit/data/cui-dialogs-test.txt");
96 CPPUNIT_TEST_SUITE_REGISTRATION(CuiDialogsTest
);
98 CPPUNIT_PLUGIN_IMPLEMENT();
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */