summaryrefslogtreecommitdiff
path: root/sc/qa
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 /sc/qa
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>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/extras/scriptforge.cxx55
1 files changed, 55 insertions, 0 deletions
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: */