Simplify using designated initializers
[LibreOffice.git] / include / unotest / macros_test.hxx
blob646bddd12f52a915771f9b2c62710baafc9e954a
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_UNOTEST_MACROS_TEST_HXX
11 #define INCLUDED_UNOTEST_MACROS_TEST_HXX
13 #include <sal/config.h>
15 #include <memory>
16 #include <functional>
17 #include <config_gpgme.h>
18 #include <rtl/ustring.hxx>
19 #include <unotest/detail/unotestdllapi.hxx>
21 #include <com/sun/star/lang/XComponent.hpp>
22 #include <com/sun/star/frame/XDesktop2.hpp>
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <com/sun/star/uno/Any.h>
25 #include <utility>
27 struct TestMacroInfo
29 OUString sFileBaseName;
30 OUString sMacroUrl;
33 class BasicDLL;
34 class SvStream;
36 namespace test
38 class Directories;
41 namespace com::sun::star::security
43 class XCertificate;
45 namespace com::sun::star::xml::crypto
47 class XSecurityEnvironment;
50 namespace unotest
52 class OOO_DLLPUBLIC_UNOTEST MacrosTest
54 public:
55 class Resetter
57 private:
58 std::function<void()> m_Func;
60 public:
61 Resetter(std::function<void()> aFunc)
62 : m_Func(std::move(aFunc))
65 ~Resetter()
67 try
69 m_Func();
71 catch (...) // has to be reliable
73 fprintf(stderr, "resetter failed with exception\n");
74 abort();
79 MacrosTest();
80 ~MacrosTest();
82 css::uno::Reference<css::lang::XComponent>
83 loadFromDesktop(const OUString& rURL, const OUString& rDocService = OUString(),
84 const css::uno::Sequence<css::beans::PropertyValue>& rExtra_args
85 = css::uno::Sequence<css::beans::PropertyValue>());
87 static css::uno::Any
88 dispatchCommand(const css::uno::Reference<css::lang::XComponent>& xComponent,
89 const OUString& rCommand,
90 const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues);
92 static css::uno::Any
93 queryDispatchStatus(css::uno::Reference<css::lang::XComponent> const& xComponent,
94 css::uno::Reference<css::uno::XComponentContext> const& xContext,
95 OUString const& rURL);
97 /// Opens rStreamName from rTempFile, assuming it's a ZIP storage.
98 static std::unique_ptr<SvStream> parseExportStream(const OUString& url,
99 const OUString& rStreamName);
101 // note: there is no tearDownX509
102 void setUpX509(const test::Directories& rDirectories, const OUString& rTestName);
103 static void setUpGpg(const test::Directories& rDirectories, std::u16string_view rTestName);
104 static void tearDownGpg();
106 static bool IsValid(const css::uno::Reference<css::security::XCertificate>& cert,
107 const css::uno::Reference<css::xml::crypto::XSecurityEnvironment>& env);
108 static css::uno::Reference<css::security::XCertificate> GetValidCertificate(
109 const css::uno::Sequence<css::uno::Reference<css::security::XCertificate>>& certs,
110 const css::uno::Reference<css::xml::crypto::XSecurityEnvironment>& env,
111 const css::uno::Sequence<css::beans::PropertyValue>& rFilterData = {});
113 protected:
114 css::uno::Reference<css::frame::XDesktop2> mxDesktop;
116 private:
117 std::unique_ptr<BasicDLL> mpDll;
121 #endif
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */