include/unotest/macros_test.hxx |    6 
 sc/qa/extras/vba-macro-test.cxx |  340 +++++++++++++++++++++++++++-------------
 2 files changed, 231 insertions(+), 115 deletions(-)

New commits:
commit a72b10f8901142bc4a9edb5ddff22997e2747b5b
Author:     Xisco Fauli <[email protected]>
AuthorDate: Thu Feb 5 11:13:53 2026 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Thu Feb 5 15:46:47 2026 +0100

    CppunitTest_sc_vba_macro_test: split single test into different ones
    
    so every document is loaded in different tests
    
    Removing the IsDefaultDPI() for now. it should be added only to
    those test failing but since I don't have hi-dpi I don't know
    which are those
    
    Change-Id: I64393d10e093f5a1b034cfcc0d964a38ea136ed7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198741
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/include/unotest/macros_test.hxx b/include/unotest/macros_test.hxx
index 63d0ccf8a948..1c08af92681b 100644
--- a/include/unotest/macros_test.hxx
+++ b/include/unotest/macros_test.hxx
@@ -23,12 +23,6 @@
 #include <com/sun/star/uno/Any.h>
 #include <utility>
 
-struct TestMacroInfo
-{
-    OUString sFileBaseName;
-    OUString sMacroUrl;
-};
-
 class BasicDLL;
 class SvStream;
 
diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx
index d4d059f68602..282f877521b2 100644
--- a/sc/qa/extras/vba-macro-test.cxx
+++ b/sc/qa/extras/vba-macro-test.cxx
@@ -45,8 +45,48 @@ public:
         : UnoApiTest(u"/sc/qa/extras/testdocuments"_ustr)
     {
     }
+
+    void testMacro(std::u16string_view aFileName, const OUString& rScriptURL);
 };
 
+void VBAMacroTest::testMacro(std::u16string_view aFileName, const OUString& 
rScriptURL)
+{
+    loadFromFile(aFileName);
+    OUString sTempDir;
+    OUString sTempDirURL;
+    osl::FileBase::getTempDirURL(sTempDirURL);
+    osl::FileBase::getSystemPathFromFileURL(sTempDirURL, sTempDir);
+    sTempDir += OUStringChar(SAL_PATHDELIMITER);
+    OUString sTestFileName(u"My Test WorkBook.xls"_ustr);
+    uno::Sequence<uno::Any> aParams;
+
+    // process all events such as OnLoad events etc.  otherwise they tend
+    // to arrive later at a random time - while processing other StarBasic
+    // methods.
+    Scheduler::ProcessEventsToIdle();
+
+    bool bWorkbooksHandling = aFileName == u"Workbooks.xls" && 
!sTempDir.isEmpty();
+
+    if (bWorkbooksHandling)
+    {
+        aParams = { uno::Any(sTempDir), uno::Any(sTestFileName) };
+    }
+
+    uno::Any aRet = executeMacro(rScriptURL, aParams);
+    OUString aStringRes;
+    CPPUNIT_ASSERT(aRet >>= aStringRes);
+    CPPUNIT_ASSERT_EQUAL(u"OK"_ustr, aStringRes);
+
+    if (bWorkbooksHandling)
+    {
+        OUString sFileUrl;
+        OUString sFilePath = sTempDir + sTestFileName;
+        osl::FileBase::getFileURLFromSystemPath(sFilePath, sFileUrl);
+        if (!sFileUrl.isEmpty())
+            osl::File::remove(sFileUrl);
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(VBAMacroTest, testSimpleCopyAndPaste)
 {
     // Copy-paste values in the same sheet
@@ -321,33 +361,69 @@ CPPUNIT_TEST_FIXTURE(VBAMacroTest, testMacroKeyBinding)
         xAccelerator->getCommandByKeyEvent(aCtrlT));
 }
 
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testAdress)
+{
+    testMacro(
+        u"TestAddress.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
 CPPUNIT_TEST_FIXTURE(VBAMacroTest, testVba)
 {
-    // FIXME: the DPI check should be removed when either (1) the test is 
fixed to work with
-    // non-default DPI; or (2) unit tests on Windows are made to use svp VCL 
plugin.
-    if (!IsDefaultDPI())
-        return;
-    TestMacroInfo testInfo[] = {
-        { u"TestAddress.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        {
-            u"vba.xls"_ustr,
-            
u"vnd.sun.Star.script:VBAProject.Modul1.Modul1?language=Basic&location=document"_ustr,
-        },
-        { u"MiscRangeTests.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"bytearraystring.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacro.test?language=Basic&location=document"_ustr
 },
-        { u"AutoFilter.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"CalcFont.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"TestIntersection.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"TestUnion.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"range-4.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
+    testMacro(
+        u"vba.xls",
+        
u"vnd.sun.Star.script:VBAProject.Modul1.Modul1?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testMiscRangeTests)
+{
+    testMacro(
+        u"MiscRangeTests.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testByteArrayString)
+{
+    testMacro(
+        u"bytearraystring.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacro.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testAutoFilter)
+{
+    testMacro(
+        u"AutoFilter.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testFont)
+{
+    testMacro(
+        u"CalcFont.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testIntersection)
+{
+    testMacro(
+        u"TestIntersection.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testUnion)
+{
+    testMacro(
+        u"TestUnion.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testRanges4)
+{
+    testMacro(
+        u"range-4.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
 // FIXME: sometimes it fails on Windows with
 // Failed:  : Test change event for Range.Clear set:
 // Failed:  : Test change event for Range.ClearContents set:
@@ -356,91 +432,137 @@ CPPUNIT_TEST_FIXTURE(VBAMacroTest, testVba)
 // Tests passed: 4
 // Tests failed: 4
 #if !defined(_WIN32)
-        { u"Ranges-3.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testRanges3)
+{
+    testMacro(
+        u"Ranges-3.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
 #endif
-        { u"TestCalc_Rangetest.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"TestCalc_Rangetest2.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"Ranges-2.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"pagesetup.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"Window.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"window2.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"PageBreaks.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"Shapes.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"Ranges.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"CheckOptionToggleValue.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"GeneratedEventTest.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"MiscControlTests.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"Workbooks.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"Names.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"NamesSheetLocal.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"vba_endFunction.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"vba_findFunction.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr
 },
-        { u"BGR-RGBTest.xls"_ustr,
-          
u"vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document"_ustr
 }
-    };
-    OUString sTempDir;
-    OUString sTempDirURL;
-    osl::FileBase::getTempDirURL(sTempDirURL);
-    osl::FileBase::getSystemPathFromFileURL(sTempDirURL, sTempDir);
-    sTempDir += OUStringChar(SAL_PATHDELIMITER);
-    OUString sTestFileName(u"My Test WorkBook.xls"_ustr);
-    uno::Sequence<uno::Any> aParams;
-    for (const auto& rTestInfo : testInfo)
-    {
-        OUString aFileName = loadFromFile(rTestInfo.sFileBaseName);
-
-        // process all events such as OnLoad events etc.  otherwise they tend
-        // to arrive later at a random time - while processing other StarBasic
-        // methods.
-        Scheduler::ProcessEventsToIdle();
-
-        bool bWorkbooksHandling = rTestInfo.sFileBaseName == "Workbooks.xls" 
&& !sTempDir.isEmpty();
-
-        if (bWorkbooksHandling)
-        {
-            aParams = { uno::Any(sTempDir), uno::Any(sTestFileName) };
-        }
-
-        SAL_INFO("sc.qa", "about to invoke vba test in " << aFileName << " 
with url "
-                                                         << 
rTestInfo.sMacroUrl);
-
-        uno::Any aRet = executeMacro(rTestInfo.sMacroUrl, aParams);
-        OUString aStringRes;
-        aRet >>= aStringRes;
-
-        CPPUNIT_ASSERT_EQUAL_MESSAGE(
-            OUString("script reported failure in file " + 
rTestInfo.sFileBaseName)
-                .toUtf8()
-                .getStr(),
-            u"OK"_ustr, aStringRes);
-
-        if (bWorkbooksHandling)
-        {
-            OUString sFileUrl;
-            OUString sFilePath = sTempDir + sTestFileName;
-            osl::FileBase::getFileURLFromSystemPath(sFilePath, sFileUrl);
-            if (!sFileUrl.isEmpty())
-                osl::File::remove(sFileUrl);
-        }
-    }
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testRanges6)
+{
+    testMacro(
+        u"TestCalc_Rangetest.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testRanges5)
+{
+    testMacro(
+        u"TestCalc_Rangetest2.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testRanges2)
+{
+    testMacro(
+        u"Ranges-2.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testPageSetup)
+{
+    testMacro(
+        u"pagesetup.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testWindows)
+{
+    testMacro(
+        u"Window.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testWindows2)
+{
+    testMacro(
+        u"window2.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testPageBreaks)
+{
+    testMacro(
+        u"PageBreaks.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testShapes)
+{
+    testMacro(
+        u"Shapes.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testRanges)
+{
+    testMacro(
+        u"Ranges.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testCheckOptionToggleValue)
+{
+    testMacro(
+        u"CheckOptionToggleValue.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testGeneratedEventTest)
+{
+    testMacro(
+        u"GeneratedEventTest.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testMiscControlTests)
+{
+    testMacro(
+        u"MiscControlTests.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testWorkbooks)
+{
+    testMacro(
+        u"Workbooks.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testNames)
+{
+    testMacro(
+        u"Names.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testNamesSheetLocal)
+{
+    testMacro(
+        u"NamesSheetLocal.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testendFunction)
+{
+    testMacro(
+        u"vba_endFunction.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testfindFunction)
+{
+    testMacro(
+        u"vba_findFunction.xls",
+        
u"vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document"_ustr);
+}
+
+CPPUNIT_TEST_FIXTURE(VBAMacroTest, testBGR_RGB)
+{
+    testMacro(u"BGR-RGBTest.xls",
+              
u"vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document"_ustr);
 }
 
 CPPUNIT_TEST_FIXTURE(VBAMacroTest, testTdf149579)

Reply via email to