diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-10-21 17:12:24 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-10-21 21:23:37 +0200 |
commit | 89c732913d6155db48c74dd7c2c0325468048aa5 (patch) | |
tree | 5a64c95d4c4be805e4873e0d4a91f327c64ae85a /test | |
parent | 09dfee8a1cf7698a637f647f48750cf8d5722b7c (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')
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/calc_unoapi_test.cxx | 69 | ||||
-rw-r--r-- | test/source/unoapi_test.cxx | 52 |
3 files changed, 48 insertions, 74 deletions
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index 4e179080c70a..1476d00997aa 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -42,7 +42,6 @@ $(eval $(call gb_Library_use_externals,subsequenttest,\ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/unoapi_test \ - test/source/calc_unoapi_test \ test/source/a11y/AccessibilityTools \ test/source/a11y/accessibletestbase \ test/source/a11y/swaccessibletestbase \ diff --git a/test/source/calc_unoapi_test.cxx b/test/source/calc_unoapi_test.cxx deleted file mode 100644 index a0423cbc7e67..000000000000 --- a/test/source/calc_unoapi_test.cxx +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include <test/calc_unoapi_test.hxx> -#include <sfx2/objsh.hxx> - -#include <com/sun/star/frame/XStorable.hpp> -#include <comphelper/propertyvalue.hxx> - -using namespace css; -using namespace css::uno; - -CalcUnoApiTest::CalcUnoApiTest(const OUString& path) - : UnoApiTest(path) -{ -} - -void CalcUnoApiTest::tearDown() -{ - if (mxComponent.is()) - { - mxComponent->dispose(); - mxComponent.clear(); - } - - test::BootstrapFixture::tearDown(); -} - -uno::Any CalcUnoApiTest::executeMacro(const OUString& rScriptURL, const uno::Sequence<uno::Any>& rParams) -{ - 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 CalcUnoApiTest::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 CalcUnoApiTest::saveAndReload(const OUString& rFilter) -{ - utl::TempFileNamed aTempFile = save(rFilter); - - mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.sheet.SpreadsheetDocument"); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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: */ |