tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / test / unoapi_test.hxx
bloba7b12bc1026385318d457d10382bdb1a56edfc9e
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_UNOAPI_TEST_HXX
11 #define INCLUDED_TEST_UNOAPI_TEST_HXX
13 #include <sal/config.h>
15 #include <string_view>
17 #include <rtl/ref.hxx>
18 #include <test/bootstrapfixture.hxx>
19 #include <test/testinteractionhandler.hxx>
20 #include <unotest/macros_test.hxx>
21 #include <com/sun/star/lang/XComponent.hpp>
22 #include <osl/file.hxx>
23 #include <unotools/tempfile.hxx>
24 #include <vcl/filter/PDFiumLibrary.hxx>
26 // basic uno api test class
28 class OOO_DLLPUBLIC_TEST UnoApiTest : public test::BootstrapFixture, public unotest::MacrosTest
30 public:
31 UnoApiTest(OUString path);
33 virtual void setUp() override;
34 virtual void tearDown() override;
36 OUString createFileURL(std::u16string_view aFileBase);
37 OUString createFilePath(std::u16string_view aFileBase);
38 void loadFromURL(const OUString& rURL, const char* pPassword = nullptr);
39 void loadWithParams(const OUString& rURL,
40 const css::uno::Sequence<css::beans::PropertyValue>& rParams);
41 OUString loadFromFile(std::u16string_view aFileBase, const char* pPassword = nullptr);
43 css::uno::Any executeMacro(const OUString& rScriptURL,
44 const css::uno::Sequence<css::uno::Any>& rParams = {});
46 void save(const OUString& rFilter, const char* pPassword = nullptr);
47 void saveWithParams(const css::uno::Sequence<css::beans::PropertyValue>& rParams);
48 void saveAndReload(const OUString& rFilter, const char* pPassword = nullptr);
50 std::unique_ptr<vcl::pdf::PDFiumDocument> parsePDFExport(const OString& rPassword = OString());
52 void createTempCopy(std::u16string_view fileName);
54 void skipValidation() { mbSkipValidation = true; }
55 void setFilterOptions(const OUString& rFilterOptions) { maFilterOptions = rFilterOptions; }
57 void setImportFilterOptions(const OUString& rFilterOptions)
59 maImportFilterOptions = rFilterOptions;
62 void setImportFilterName(const OUString& rFilterName) { maImportFilterName = rFilterName; }
64 protected:
65 // reference to document component that we are testing
66 css::uno::Reference<css::lang::XComponent> mxComponent;
68 // In case the test needs to work with two documents at the same time
69 css::uno::Reference<css::lang::XComponent> mxComponent2;
71 utl::TempFileNamed maTempFile;
73 SvMemoryStream maMemory; // Underlying memory for parsed PDF files.
75 rtl::Reference<TestInteractionHandler> xInteractionHandler;
77 private:
78 void setTestInteractionHandler(const char* pPassword,
79 std::vector<css::beans::PropertyValue>& rFilterOptions);
81 bool mbSkipValidation;
82 OUString m_aBaseString;
83 OUString maFilterOptions;
85 OUString maImportFilterOptions;
86 OUString maImportFilterName;
89 inline void assertRectangleEqual(const tools::Rectangle& rExpected, const tools::Rectangle& rActual,
90 const sal_Int32 nTolerance, const CppUnit::SourceLine& rSourceLine)
92 CPPUNIT_NS::assertDoubleEquals(rExpected.Top(), rActual.Top(), nTolerance, rSourceLine,
93 "different Top");
94 CPPUNIT_NS::assertDoubleEquals(rExpected.Left(), rActual.Left(), nTolerance, rSourceLine,
95 "different Left");
96 CPPUNIT_NS::assertDoubleEquals(rExpected.GetWidth(), rActual.GetWidth(), nTolerance,
97 rSourceLine, "different Width");
98 CPPUNIT_NS::assertDoubleEquals(rExpected.GetHeight(), rActual.GetHeight(), nTolerance,
99 rSourceLine, "different Height");
102 #define CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aExpected, aActual, aTolerance) \
103 assertRectangleEqual(aExpected, aActual, aTolerance, CPPUNIT_SOURCELINE())
105 inline void assertPointEqual(const Point& rExpected, const Point& rActual,
106 const sal_Int32 nTolerance, const CppUnit::SourceLine& rSourceLine)
108 CPPUNIT_NS::assertDoubleEquals(rExpected.X(), rActual.X(), nTolerance, rSourceLine,
109 "different X");
110 CPPUNIT_NS::assertDoubleEquals(rExpected.Y(), rActual.Y(), nTolerance, rSourceLine,
111 "different Y");
114 #define CPPUNIT_ASSERT_POINT_EQUAL_WITH_TOLERANCE(aExpected, aActual, aTolerance) \
115 assertPointEqual(aExpected, aActual, aTolerance, CPPUNIT_SOURCELINE())
117 #endif // INCLUDED_TEST_UNOAPI_TEST_HXX
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */