From 4c17c2303d2475aa080bbc10a0c5d0e9f253d505 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Thu, 10 Oct 2024 16:44:15 +0200 Subject: [PATCH] tdf#163219: sc_scriptforge_test: Add unittest Change-Id: I045f9e8ae8805c81f455e4171be95e1222ee908f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174765 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sc/qa/extras/scriptforge.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sc/qa/extras/scriptforge.cxx b/sc/qa/extras/scriptforge.cxx index 4f6b1b5dc2c6..32a8b0cd7687 100644 --- a/sc/qa/extras/scriptforge.cxx +++ b/sc/qa/extras/scriptforge.cxx @@ -45,6 +45,30 @@ CPPUNIT_TEST_FIXTURE(ScScriptForgeTest, testSetValue) CPPUNIT_ASSERT_EQUAL(u"10"_ustr, pDoc->GetString(ScAddress(0, 0, 0))); } +CPPUNIT_TEST_FIXTURE(ScScriptForgeTest, testShowProgressBar) +{ + createScDoc(); + + // insert initial library + css::uno::Reference 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 Test as String\n" + " GlobalScope.BasicLibraries.LoadLibrary(\"ScriptForge\")\n" + " ui = CreateScriptService(\"UI\")\n" + " ui.ShowProgressBar\n" + " Test = \"OK\"\n" + "End Function\n"_ustr)); + + // Without the fix in place, this test would have crashed + Any aRet = executeMacro( + u"vnd.sun.Star.script:TestLibrary.TestModule.Test?language=Basic&location=document"_ustr); + OUString sResult; + aRet >>= sResult; + CPPUNIT_ASSERT_EQUAL(u"OK"_ustr, sResult); +} + ScScriptForgeTest::ScScriptForgeTest() : ScModelTestBase(u"/sc/qa/extras/testdocuments"_ustr) {