sc: Add simple unittest for ScriptForge

Change-Id: Ief1808219862273643a3bfae212b1d0e454b3e86
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174763
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli 2024-10-10 13:33:43 +02:00
parent 4059c6351d
commit c0e792cc6e
3 changed files with 120 additions and 0 deletions

View file

@ -0,0 +1,64 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
$(eval $(call gb_CppunitTest_CppunitTest,sc_scriptforge_test))
$(eval $(call gb_CppunitTest_use_externals,sc_scriptforge_test, \
boost_headers \
mdds_headers \
libxml2 \
))
$(eval $(call gb_CppunitTest_use_common_precompiled_header,sc_scriptforge_test))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_scriptforge_test, \
sc/qa/extras/scriptforge \
))
$(eval $(call gb_CppunitTest_use_libraries,sc_scriptforge_test, \
sal \
sc \
scqahelper \
cppu \
cppuhelper \
subsequenttest \
svl \
svt \
svx \
svxcore \
test \
tk \
tl \
ucbhelper \
unotest \
utl \
xo \
))
$(eval $(call gb_CppunitTest_set_include,sc_scriptforge_test,\
-I$(SRCDIR)/sc/source/ui/inc \
-I$(SRCDIR)/sc/inc \
-I$(SRCDIR)/sc/qa/unit \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_api,sc_scriptforge_test,\
offapi \
oovbaapi \
udkapi \
))
$(eval $(call gb_CppunitTest_use_ure,sc_scriptforge_test))
$(eval $(call gb_CppunitTest_use_vcl,sc_scriptforge_test))
$(eval $(call gb_CppunitTest_use_rdb,sc_scriptforge_test,services))
$(eval $(call gb_CppunitTest_use_configuration,sc_scriptforge_test))
# vim: set noet sw=4 ts=4:

View file

@ -87,6 +87,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sc, \
CppunitTest_sc_pdf_export \
CppunitTest_sc_pivottable_filters_test \
CppunitTest_sc_pivottable_formats_import_export_test \
CppunitTest_sc_scriptforge_test \
CppunitTest_sc_sparkline_test \
CppunitTest_sc_subsequent_filters_test \
CppunitTest_sc_subsequent_filters_test2 \

View file

@ -0,0 +1,55 @@
/* -*- 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 <sal/config.h>
#include <helper/qahelper.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
/* Implementation of Macros test */
class ScScriptForgeTest : public ScModelTestBase
{
public:
ScScriptForgeTest();
};
CPPUNIT_TEST_FIXTURE(ScScriptForgeTest, testSetValue)
{
createScDoc();
// insert initial library
css::uno::Reference<css::document::XEmbeddedScripts> xDocScr(mxComponent, UNO_QUERY_THROW);
auto xLibs = xDocScr->getBasicLibraries();
auto xLibrary = xLibs->createLibrary(u"TestLibrary"_ustr);
xLibrary->insertByName(
u"TestModule"_ustr,
uno::Any(u"Function Main\n"
" GlobalScope.BasicLibraries.LoadLibrary(\"ScriptForge\")\n"
" Dim oDoc : oDoc = CreateScriptService(\"Calc\", ThisComponent)\n"
" oDoc.setValue(\"A1\", 10)\n"
"End Function\n"_ustr));
// Without the fix in place, this test would have crashed
executeMacro(
u"vnd.sun.Star.script:TestLibrary.TestModule.Main?language=Basic&location=document"_ustr);
ScDocument* pDoc = getScDoc();
CPPUNIT_ASSERT_EQUAL(u"10"_ustr, pDoc->GetString(ScAddress(0, 0, 0)));
}
ScScriptForgeTest::ScScriptForgeTest()
: ScModelTestBase(u"/sc/qa/extras/testdocuments"_ustr)
{
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */