sw/qa/core/macros-test.cxx |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

New commits:
commit 4995a30bd0720c96ebe48e1f567e0386a9c80d42
Author:     Hannah Meeks <hmeeks4...@gmail.com>
AuthorDate: Mon Jul 4 16:56:54 2022 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Oct 24 15:05:13 2022 +0200

    Re-work extension handling to make tests easier to add.
    
    Change-Id: Idddbb99804bdc1354db7a1059c68c820ba6a98b3
    Signed-off-by: Hannah Meeks <hmeeks4...@gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136943
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141594
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 91c7a928a46a..f3b10af8a30d 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -64,7 +64,7 @@ class SwMacrosTest : public test::BootstrapFixture, public 
unotest::MacrosTest
 public:
     SwMacrosTest();
 
-    void createFileURL(std::u16string_view aFileBase, std::u16string_view 
aFileExtension, OUString& rFilePath);
+    void createFileURL(std::u16string_view aFile, OUString& rFilePath);
 
     virtual void setUp() override;
     virtual void tearDown() override;
@@ -94,24 +94,27 @@ private:
     OUString m_aBaseString;
 };
 
-void SwMacrosTest::createFileURL(std::u16string_view aFileBase, 
std::u16string_view aFileExtension, OUString& rFilePath)
+void SwMacrosTest::createFileURL(std::u16string_view aFile, OUString& 
rFilePath)
 {
-    rFilePath = m_directories.getSrcRootURL() + m_aBaseString + "/" + 
aFileExtension + "/"
-        + aFileBase + aFileExtension;
+    auto i = aFile.find_last_of('.');
+    CPPUNIT_ASSERT_MESSAGE("Missing Extension", i != std::string_view::npos);
+    std::u16string_view aFileExtension = aFile.substr(i+1);
+
+    rFilePath = m_directories.getSrcRootURL() + m_aBaseString + "/" + 
aFileExtension + "/" + aFile;
 }
 
 void SwMacrosTest::testVba()
 {
     TestMacroInfo testInfo[] = {
         {
-            OUString("testVba."),
+            OUString("testVba.doc"),
             
OUString("vnd.sun.Star.script:Project.NewMacros.Macro1?language=Basic&location=document")
         }
     };
     for ( size_t  i=0; i<SAL_N_ELEMENTS( testInfo ); ++i )
     {
         OUString aFileName;
-        createFileURL(testInfo[i].sFileBaseName, u"doc", aFileName);
+        createFileURL(testInfo[i].sFileBaseName, aFileName);
         uno::Reference< css::lang::XComponent > xComponent = 
loadFromDesktop(aFileName, "com.sun.star.text.TextDocument");
         OUString sUrl = testInfo[i].sMacroUrl;
         Any aRet;
@@ -203,7 +206,7 @@ void SwMacrosTest::testBookmarkDeleteTdf90816()
 void SwMacrosTest::testControlShapeGrouping()
 {
     OUString aFileName;
-    createFileURL(u"testControlShapeGrouping.", u"odt", aFileName);
+    createFileURL(u"testControlShapeGrouping.odt", aFileName);
     Reference< css::lang::XComponent > xComponent(
         loadFromDesktop(aFileName, "com.sun.star.text.TextDocument"));
 
@@ -343,7 +346,7 @@ void SwMacrosTest::testFdo55289()
 void SwMacrosTest::testFdo68983()
 {
     OUString aFileName;
-    createFileURL(u"fdo68983.", u"odt", aFileName);
+    createFileURL(u"fdo68983.odt", aFileName);
     Reference< css::lang::XComponent > xComponent =
         loadFromDesktop(aFileName, "com.sun.star.text.TextDocument");
     Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW);

Reply via email to