summaryrefslogtreecommitdiff
path: root/test/source/unoapi_test.cxx
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-10-21 17:12:24 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-10-21 21:23:37 +0200
commit89c732913d6155db48c74dd7c2c0325468048aa5 (patch)
tree5a64c95d4c4be805e4873e0d4a91f327c64ae85a /test/source/unoapi_test.cxx
parent09dfee8a1cf7698a637f647f48750cf8d5722b7c (diff)
test: merge CalcUnoApiTest and UnoApiTest into one
Change-Id: I24ec4c2c1c6d83865ef78a6460cde68cef84fdb2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141638 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'test/source/unoapi_test.cxx')
-rw-r--r--test/source/unoapi_test.cxx52
1 files changed, 48 insertions, 4 deletions
diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx
index e27d17507c76..2241db77599e 100644
--- a/test/source/unoapi_test.cxx
+++ b/test/source/unoapi_test.cxx
@@ -9,9 +9,13 @@
#include <test/unoapi_test.hxx>
-#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
+
+#include <sfx2/app.hxx>
+#include <sfx2/objsh.hxx>
#include <utility>
using namespace css;
@@ -29,6 +33,18 @@ void UnoApiTest::setUp()
mxDesktop
= css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()));
CPPUNIT_ASSERT_MESSAGE("no desktop!", mxDesktop.is());
+ SfxApplication::GetOrCreate();
+}
+
+void UnoApiTest::tearDown()
+{
+ if (mxComponent.is())
+ {
+ mxComponent->dispose();
+ mxComponent.clear();
+ }
+
+ test::BootstrapFixture::tearDown();
}
void UnoApiTest::createFileURL(std::u16string_view aFileBase, OUString& rFilePath)
@@ -36,10 +52,38 @@ void UnoApiTest::createFileURL(std::u16string_view aFileBase, OUString& rFilePat
rFilePath = m_directories.getSrcRootURL() + m_aBaseString + "/" + aFileBase;
}
-void UnoApiTest::closeDocument(uno::Reference<lang::XComponent> const& xDocument)
+uno::Any UnoApiTest::executeMacro(const OUString& rScriptURL,
+ const uno::Sequence<uno::Any>& rParams)
{
- uno::Reference<util::XCloseable> xCloseable(xDocument, UNO_QUERY_THROW);
- xCloseable->close(false);
+ uno::Any aRet;
+ uno::Sequence<sal_Int16> aOutParamIndex;
+ uno::Sequence<uno::Any> aOutParam;
+
+ ErrCode result = SfxObjectShell::CallXScript(mxComponent, rScriptURL, rParams, aRet,
+ aOutParamIndex, aOutParam);
+ CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, result);
+
+ return aRet;
+}
+
+utl::TempFileNamed UnoApiTest::save(const OUString& rFilter)
+{
+ utl::TempFileNamed aTempFile;
+ aTempFile.EnableKillingFile();
+ uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName", rFilter) };
+ css::uno::Reference<frame::XStorable> xStorable(mxComponent, css::uno::UNO_QUERY_THROW);
+ xStorable->storeAsURL(aTempFile.GetURL(), aArgs);
+ mxComponent->dispose();
+ mxComponent.clear();
+
+ return aTempFile;
+}
+
+void UnoApiTest::saveAndReload(const OUString& rFilter)
+{
+ utl::TempFileNamed aTempFile = save(rFilter);
+
+ mxComponent = loadFromDesktop(aTempFile.GetURL());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */