sw/qa/inc/swmodeltestbase.hxx  |    5 ++-
 sw/qa/unit/swmodeltestbase.cxx |   58 ++++++++++-------------------------------
 2 files changed, 18 insertions(+), 45 deletions(-)

New commits:
commit dd18bd455d5aa3cbfbf794c718ef60c1cf02a4e7
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Nov 8 19:05:57 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Nov 9 08:39:42 2022 +0100

    SwModelTestBase: remove more duplicated code
    
    Change-Id: Idf29e7202e777c1fe673f6fdc4f70ff1c2b3b469
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142466
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx
index dbd601002ddb..c7875c09c2c8 100644
--- a/sw/qa/inc/swmodeltestbase.hxx
+++ b/sw/qa/inc/swmodeltestbase.hxx
@@ -318,6 +318,7 @@ protected:
     {
         return 
loadURLWithComponent(createFileURL(OUString::createFromAscii(pName)),
                                     "com.sun.star.text.TextDocument", pName, 
pPassword);
+
     }
 
     void load_web(const char* pName, const char* pPassword = nullptr)
@@ -337,10 +338,10 @@ protected:
 
     void loadURL(OUString const& rURL, const char* pName, const char* 
pPassword = nullptr);
 
-    void reload(const char* pFilter, const char* filename, const char* 
pPassword = nullptr);
+    void reload(const char* pFilter, const char* pName, const char* pPassword 
= nullptr);
 
     /// Save the loaded document to a tempfile. Can be used to check the 
resulting docx/odt directly as a ZIP file.
-    void save(const OUString& aFilterName, const char* filename = nullptr, 
const char* pPassword = nullptr);
+    void save(const OUString& aFilterName, const char* pName = nullptr, const 
char* pPassword = nullptr);
 
     /// Combines load() and save().
     void loadAndSave(const char* pName);
diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx
index e341d5038821..a9cd21c4d1ce 100644
--- a/sw/qa/unit/swmodeltestbase.cxx
+++ b/sw/qa/unit/swmodeltestbase.cxx
@@ -516,10 +516,14 @@ void SwModelTestBase::loadURLWithComponent(OUString 
const& rURL, OUString const&
         aFilterOptions.push_back(aValue);
     }
 
-    // Output name early, so in the case of a hang, the name of the hanging 
input file is visible.
-    if (pName)
-        std::cout << pName << ":\n";
-    mnStartTime = osl_getGlobalTimer();
+    // Output name at load time, so in the case of a hang, the name of the 
hanging input file is visible.
+    if (!isExported())
+    {
+        if (pName)
+            std::cout << pName << ":\n";
+        mnStartTime = osl_getGlobalTimer();
+    }
+
     mxComponent
         = loadFromDesktop(rURL, rComponent, 
comphelper::containerToSequence(aFilterOptions));
 
@@ -539,46 +543,14 @@ void SwModelTestBase::loadURL(OUString const& rURL, const 
char* pName, const cha
     loadURLWithComponent(rURL, "com.sun.star.text.TextDocument", pName, 
pPassword);
 }
 
-void SwModelTestBase::reload(const char* pFilter, const char* filename, const 
char* pPassword)
+void SwModelTestBase::reload(const char* pFilter, const char* pName, const 
char* pPassword)
 {
-    save(OUString::createFromAscii(pFilter), filename, pPassword);
-    mxComponent->dispose();
-
-    std::vector<beans::PropertyValue> aFilterOptions;
-    if (pPassword)
-    {
-        setTestInteractionHandler(pPassword, aFilterOptions);
-    }
-
-    if (!maImportFilterOptions.isEmpty())
-    {
-        beans::PropertyValue aValue;
-        aValue.Name = "FilterOptions";
-        aValue.Value <<= maImportFilterOptions;
-        aFilterOptions.push_back(aValue);
-    }
-
-    if (!maImportFilterName.isEmpty())
-    {
-        beans::PropertyValue aValue;
-        aValue.Name = "FilterName";
-        aValue.Value <<= maImportFilterName;
-        aFilterOptions.push_back(aValue);
-    }
+    save(OUString::createFromAscii(pFilter), pName, pPassword);
 
-    mxComponent = loadFromDesktop(maTempFile.GetURL(), 
"com.sun.star.text.TextDocument",
-                                  
comphelper::containerToSequence(aFilterOptions));
-    if (pPassword)
-    {
-        CPPUNIT_ASSERT_MESSAGE("Password set but not requested",
-                               xInteractionHandler->wasPasswordRequested());
-    }
-    discardDumpedLayout();
-    if (mustCalcLayoutOf(filename))
-        calcLayout();
+    loadURLWithComponent(maTempFile.GetURL(), 
"com.sun.star.text.TextDocument", pName, pPassword);
 }
 
-void SwModelTestBase::save(const OUString& aFilterName, const char* filename, 
const char* pPassword)
+void SwModelTestBase::save(const OUString& aFilterName, const char* pName, 
const char* pPassword)
 {
     uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
     utl::MediaDescriptor aMediaDescriptor;
@@ -604,7 +576,7 @@ void SwModelTestBase::save(const OUString& aFilterName, 
const char* filename, co
     xStorable->storeToURL(maTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
 
     // TODO: for now, validate only ODF here
-    if (mustValidate(filename) || aFilterName == "writer8"
+    if (mustValidate(pName) || aFilterName == "writer8"
         || aFilterName == "OpenDocument Text Flat XML")
     {
         if (aFilterName == "Office Open XML Text")
@@ -623,8 +595,8 @@ void SwModelTestBase::save(const OUString& aFilterName, 
const char* filename, co
         else
         {
             OString aMessage
-                = OString::Concat("validation requested, but don't know how to 
validate ")
-                  + filename + " (" + OUStringToOString(aFilterName, 
RTL_TEXTENCODING_UTF8) + ")";
+                = OString::Concat("validation requested, but don't know how to 
validate ") + pName
+                  + " (" + OUStringToOString(aFilterName, 
RTL_TEXTENCODING_UTF8) + ")";
             CPPUNIT_FAIL(aMessage.getStr());
         }
     }

Reply via email to