Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / test / bootstrapfixture.hxx
blob438bba58a431ab0c349096860de1dc5c492ddb41
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 */
9 #pragma once
11 #include <sal/config.h>
13 #include <rtl/string.hxx>
14 #include <tools/link.hxx>
15 #include <vcl/salctype.hxx>
16 #include <com/sun/star/uno/XComponentContext.hpp>
17 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
18 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
20 #include <cppunit/TestAssert.h>
21 #include <cppunit/TestFixture.h>
22 #include <cppunit/extensions/HelperMacros.h>
23 #include <cppunit/plugin/TestPlugIn.h>
24 #include <unotest/bootstrapfixturebase.hxx>
25 #include <test/testdllapi.hxx>
27 namespace test
29 enum ValidationFormat
31 OOXML,
32 ODF,
33 MSBINARY
36 // Class to do lots of heavy-lifting UNO & environment
37 // bootstrapping for unit tests, such that we can use
38 // almost an entire LibreOffice during compile - so
39 // that we can get pieces of code alone to beat them up.
41 // NB. this class is instantiated multiple times during a
42 // run of unit tests ...
43 class OOO_DLLPUBLIC_TEST BootstrapFixture : public BootstrapFixtureBase
45 bool m_bNeedUCB;
46 bool m_bAssertOnDialog;
48 protected:
49 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
51 // A convenience function to be used to conditionally exclude tests not behaving properly
52 // on UI scaling other than 1:1. Using this should be considered a temporary workaround,
53 // until a proper fix is implemented that either considers the DPI properly in the test, or
54 // makes the invariants that test uses independent of DPI.
55 static bool IsDefaultDPI();
56 static std::pair<double, double> getDPIScaling();
58 public:
59 DECL_DLLPRIVATE_STATIC_LINK(BootstrapFixture, ImplInitFilterHdl, ConvertData&, bool);
61 BootstrapFixture(bool bAssertOnDialog = true, bool bNeedUCB = true);
62 virtual ~BootstrapFixture() override;
64 virtual void setUp() override;
66 void validate(const OUString& rURL, ValidationFormat) const;
68 // Allows to exclude tests dependent on color depth of the default virtual device
69 static sal_uInt16 getDefaultDeviceBitCount();
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */