bump product version to 7.6.3.2-android
[LibreOffice.git] / include / test / screenshot_test.hxx
blob801eb80c7bf58e7d7fe011ca38acd23534537a8d
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 #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>
20 #include <map>
21 #include <string_view>
23 class VclAbstractDialog;
24 typedef std::map<OString, sal_uInt32> mapType;
26 class OOO_DLLPUBLIC_TEST ScreenshotTest : public test::BootstrapFixture, public unotest::MacrosTest
28 private:
29 /// The current UI language
30 OUString maCurrentLanguage;
32 /// the set of known dialogs and their ID for usage in createDialogByID
33 mapType maKnownDialogs;
35 /// parent for non-dialog buildables
36 weld::GenericDialogController maParent;
37 std::unique_ptr<weld::Container> mxParentWidget;
39 private:
40 /// helpers
41 void implSaveScreenshot(const BitmapEx& rScreenshot, const OUString& rScreenshotId);
42 void saveScreenshot(VclAbstractDialog const& rDialog);
43 void saveScreenshot(weld::Window& rDialog);
45 /// helper method to create and dump a dialog based on Builder contents.
46 void dumpDialogToPath(weld::Builder& rDialog);
48 /// helper method to populate maKnownDialogs, called in setUp(). Needs to be
49 /// written and has to add entries to maKnownDialogs
50 virtual void registerKnownDialogsByID(mapType& rKnownDialogs) = 0;
52 /// dialog creation for known dialogs by ID. Has to be implemented for
53 /// each registered known dialog
54 virtual VclPtr<VclAbstractDialog> createDialogByID(sal_uInt32 nID) = 0;
56 public:
57 ScreenshotTest();
58 virtual ~ScreenshotTest() override;
60 virtual void setUp() override;
62 /// Dialog creation for known dialogs by Name (path and UIXMLDescription, *.ui file).
63 /// This uses maKnownDialogs to check if known, and if so, calls createDialogByID
64 /// with the ID from the map
65 VclPtr<VclAbstractDialog> createDialogByName(const OString& rName);
67 /// version for AbstractDialogs, the ones created in AbstractDialogFactories
68 void dumpDialogToPath(VclAbstractDialog& rDialog);
70 /// fallback version for dialogs for which only the UXMLDescription is known.
71 /// This should be used with care - no active layouting will be done, only the
72 /// VclBuilder will be activated for layouting. Result can thus vary drastically
73 /// compared to the active dialog (can be compared with dialog previewer)
74 void dumpDialogToPath(std::string_view rUIXMLDescription);
76 /// helper to process all known dialogs
77 void processAllKnownDialogs();
79 /// helper to process an input file containing the UXMLDescriptions
80 /// of the dialogs to dump. It will internally try to detect and open
81 /// as known dialog first. If not successful, it will then use the
82 /// fallback version to dump the dialog.
83 /// The syntax of the input file is as follows:
84 /// - empty lines are allowed
85 /// - lines starting with '#' are treated as comment
86 /// - all other lines should contain a *.ui filename in the same
87 /// notation as in the dialog constructors(see code)
88 void processDialogBatchFile(std::u16string_view rFile);
90 /// const access to known dialogs
91 const mapType& getKnownDialogs() const { return maKnownDialogs; }
94 #endif // INCLUDED_TEST_SCREENSHOT_TEST_HXX
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */