LibreOffice Module unotest (master) 1
macros_test.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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
10#ifndef INCLUDED_UNOTEST_MACROS_TEST_HXX
11#define INCLUDED_UNOTEST_MACROS_TEST_HXX
12
13#include <sal/config.h>
14
15#include <memory>
16#include <functional>
17#include <config_gpgme.h>
18#include <rtl/ustring.hxx>
20
21#include <com/sun/star/lang/XComponent.hpp>
22#include <com/sun/star/frame/XDesktop2.hpp>
23#include <com/sun/star/uno/Any.h>
24#include <utility>
25
27{
28 OUString sFileBaseName;
29 OUString sMacroUrl;
30};
31
32class BasicDLL;
33class SvStream;
34
35namespace test
36{
37class Directories;
38}
39namespace utl
40{
41class TempFileNamed;
42}
43
45{
46class XCertificate;
47}
49{
50class XSecurityEnvironment;
51}
52
53namespace unotest
54{
56{
57public:
59 {
60 private:
61 std::function<void()> m_Func;
62
63 public:
64 Resetter(std::function<void()> aFunc)
65 : m_Func(std::move(aFunc))
66 {
67 }
69 {
70 try
71 {
72 m_Func();
73 }
74 catch (...) // has to be reliable
75 {
76 fprintf(stderr, "resetter failed with exception\n");
77 abort();
78 }
79 }
80 };
81
82 MacrosTest();
84
85 css::uno::Reference<css::lang::XComponent>
86 loadFromDesktop(const OUString& rURL, const OUString& rDocService = OUString(),
87 const css::uno::Sequence<css::beans::PropertyValue>& rExtra_args
88 = css::uno::Sequence<css::beans::PropertyValue>());
89
90 static css::uno::Any
91 dispatchCommand(const css::uno::Reference<css::lang::XComponent>& xComponent,
92 const OUString& rCommand,
93 const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues);
94
96 static std::unique_ptr<SvStream> parseExportStream(const OUString& url,
97 const OUString& rStreamName);
98
99 void setUpNssGpg(const test::Directories& rDirectories, const OUString& rTestName);
100 void tearDownNssGpg();
101
102 static bool IsValid(const css::uno::Reference<css::security::XCertificate>& cert,
103 const css::uno::Reference<css::xml::crypto::XSecurityEnvironment>& env);
104 static css::uno::Reference<css::security::XCertificate> GetValidCertificate(
105 const css::uno::Sequence<css::uno::Reference<css::security::XCertificate>>& certs,
106 const css::uno::Reference<css::xml::crypto::XSecurityEnvironment>& env,
107 const css::uno::Sequence<css::beans::PropertyValue>& rFilterData = {});
108
109protected:
110 css::uno::Reference<css::frame::XDesktop2> mxDesktop;
111
112private:
113 std::unique_ptr<BasicDLL> mpDll;
114#if HAVE_GPGCONF_SOCKETDIR
115 OString m_gpgconfCommandPrefix;
116#endif
117};
118}
119
120#endif
121
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Resetter(std::function< void()> aFunc)
Definition: macros_test.hxx:64
std::function< void()> m_Func
Definition: macros_test.hxx:61
css::uno::Reference< css::frame::XDesktop2 > mxDesktop
std::unique_ptr< BasicDLL > mpDll
const css::uno::Reference< css::xml::crypto::XSecurityEnvironment > & env
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
OUString sFileBaseName
Definition: macros_test.hxx:28
OUString sMacroUrl
Definition: macros_test.hxx:29
#define OOO_DLLPUBLIC_UNOTEST