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 #ifndef INCLUDED_TEST_SCREENSHOT_TEST_HXX
11 #define INCLUDED_TEST_SCREENSHOT_TEST_HXX
13 #include <sal/config.h>
14 #include <test/bootstrapfixture.hxx>
15 #include <unotest/macros_test.hxx>
16 #include <com/sun/star/lang/XComponent.hpp>
17 #include <osl/file.hxx>
18 #include <vcl/vclptr.hxx>
19 #include <vcl/weld.hxx>
22 class VclAbstractDialog
;
23 typedef std::map
<OString
, sal_uInt32
> mapType
;
25 class OOO_DLLPUBLIC_TEST ScreenshotTest
: public test::BootstrapFixture
, public unotest::MacrosTest
28 /// The current UI language
29 OUString maCurrentLanguage
;
31 /// the set of known dialogs and their ID for usage in createDialogByID
32 mapType maKnownDialogs
;
34 /// parent for non-dialog buildables
35 weld::GenericDialogController maParent
;
36 std::unique_ptr
<weld::Container
> mxParentWidget
;
40 void implSaveScreenshot(const BitmapEx
& rScreenshot
, const OString
& rScreenshotId
);
41 void saveScreenshot(VclAbstractDialog
const& rDialog
);
42 void saveScreenshot(weld::Window
& rDialog
);
44 /// helper method to create and dump a dialog based on Builder contents.
45 void dumpDialogToPath(weld::Builder
& rDialog
);
47 /// helper method to populate maKnownDialogs, called in setUp(). Needs to be
48 /// written and has to add entries to maKnownDialogs
49 virtual void registerKnownDialogsByID(mapType
& rKnownDialogs
) = 0;
51 /// dialog creation for known dialogs by ID. Has to be implemented for
52 /// each registered known dialog
53 virtual VclPtr
<VclAbstractDialog
> createDialogByID(sal_uInt32 nID
) = 0;
57 virtual ~ScreenshotTest() override
;
59 virtual void setUp() override
;
61 /// Dialog creation for known dialogs by Name (path and UIXMLDescription, *.ui file).
62 /// This uses maKnownDialogs to check if known, and if so, calls createDialogByID
63 /// with the ID from the map
64 VclPtr
<VclAbstractDialog
> createDialogByName(const OString
& rName
);
66 /// version for AbstractDialogs, the ones created in AbstractDialogFactories
67 void dumpDialogToPath(VclAbstractDialog
& rDialog
);
69 /// fallback version for dialogs for which only the UXMLDescription is known.
70 /// This should be used with care - no active layouting will be done, only the
71 /// VclBuilder will be activated for layouting. Result can thus vary drastically
72 /// compared to the active dialog (can be compared with dialog previewer)
73 void dumpDialogToPath(const OString
& rUIXMLDescription
);
75 /// helper to process all known dialogs
76 void processAllKnownDialogs();
78 /// helper to process an input file containing the UXMLDescriptions
79 /// of the dialogs to dump. It will internally try to detect and open
80 /// as known dialog first. If not successful, it will then use the
81 /// fallback version to dump the dialog.
82 /// The syntax of the input file is as follows:
83 /// - empty lines are allowed
84 /// - lines starting with '#' are treated as comment
85 /// - all other lines should contain a *.ui filename in the same
86 /// notation as in the dialog constructors(see code)
87 void processDialogBatchFile(const OUString
& rFile
);
89 /// const access to known dialogs
90 const mapType
& getKnownDialogs() const { return maKnownDialogs
; }
93 #endif // INCLUDED_TEST_SCREENSHOT_TEST_HXX
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */