build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / include / test / screenshot_test.hxx
blob5f8fbf89f02243616e56b6167d43597d34ecaa6c
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/dialog.hxx>
19 #include <map>
21 class VclAbstractDialog;
22 typedef std::map< OString, sal_uInt32 > mapType;
24 class OOO_DLLPUBLIC_TEST ScreenshotTest : public test::BootstrapFixture, public unotest::MacrosTest
26 private:
27 /// the target directory for screenshots
28 OUString m_aScreenshotDirectory;
30 /// The current UI language
31 OUString maCurrentLanguage;
33 /// the set of known dialogs and their ID for usage in createDialogByID
34 mapType maKnownDialogs;
36 private:
37 /// helpers
38 void implSaveScreenshot(const Bitmap& rScreenshot, const OString& rScreenshotId);
39 void saveScreenshot(VclAbstractDialog& rDialog);
40 void saveScreenshot(Dialog& rDialog);
42 /// helper method to populate maKnownDialogs, called in setUp(). Needs to be
43 /// written and has to add entries to maKnownDialogs
44 virtual void registerKnownDialogsByID(mapType& rKnownDialogs) = 0;
46 /// dialog creation for known dialogs by ID. Has to be implemented for
47 /// each registered known dialog
48 virtual VclPtr<VclAbstractDialog> createDialogByID(sal_uInt32 nID) = 0;
50 public:
51 ScreenshotTest();
52 virtual ~ScreenshotTest() override;
54 virtual void setUp() override;
56 /// Dialog creation for known dialogs by Name (path and UIXMLDescription, *.ui file).
57 /// This uses maKnownDialogs to check if known, and if so, calls createDialogByID
58 /// with the ID from the map
59 VclPtr<VclAbstractDialog> createDialogByName(const OString& rName);
61 /// version for AbstractDialogs, the ones created in AbstractDialogFactories
62 void dumpDialogToPath(VclAbstractDialog& rDialog);
64 /// version for pure vcl-based dialogs
65 void dumpDialogToPath(Dialog& rDialog);
67 /// fallback version for dialogs for which only the UXMLDescription is known.
68 /// This should be used with care - no active layouting will be done, only the
69 /// VclBuilder will be activated for layouting. Result can thus vary drastically
70 /// compared to the active dialog (can be compared with dialog previewer)
71 void dumpDialogToPath(const OString& rUIXMLDescription);
73 /// helper to process all known dialogs
74 void processAllKnownDialogs();
76 /// helper to process an input file containing the UXMLDescriptions
77 /// of the dialogs to dump. It will internally try to detect and open
78 /// as known dialog first. If not successful, it will then use the
79 /// fallback version to dump the dialog.
80 /// The syntax of the input file is as follows:
81 /// - emty lines are allowed
82 /// - lines starting with '#' are treated as comment
83 /// - all other lines should contain a *.ui filename in the same
84 /// notation as in the dialog constructors(see code)
85 void processDialogBatchFile(const OUString& rFile);
87 /// const access to known dialogs
88 const mapType& getKnownDialogs() const { return maKnownDialogs; }
91 #endif // INCLUDED_TEST_SCREENSHOT_TEST_HXX
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */