summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-10-10 13:33:43 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2024-10-10 23:29:40 +0200
commitc0e792cc6ed3eedd05f483e95415b996992a3b15 (patch)
treef62774d65d4f38f06288e0c920fc21c7589c1a0d
parent4059c6351d9dc07ef2ab88149079cb2c59e22c32 (diff)
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>
-rw-r--r--sc/CppunitTest_sc_scriptforge_test.mk64
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/qa/extras/scriptforge.cxx55
3 files changed, 120 insertions, 0 deletions
diff --git a/sc/CppunitTest_sc_scriptforge_test.mk b/sc/CppunitTest_sc_scriptforge_test.mk
new file mode 100644
index 000000000000..4aa19ba1086b
--- /dev/null
+++ b/sc/CppunitTest_sc_scriptforge_test.mk
@@ -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:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 88172016d52b..4d9f7c9618a6 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -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 \
diff --git a/sc/qa/extras/scriptforge.cxx b/sc/qa/extras/scriptforge.cxx
new file mode 100644
index 000000000000..4f6b1b5dc2c6
--- /dev/null
+++ b/sc/qa/extras/scriptforge.cxx
@@ -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: */