sw/qa/extras/ooxmlexport/ooxmlexport4.cxx |   26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

New commits:
commit b36026381d46bf07fc891cdb1c06789ad3bc40f3
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Oct 9 20:02:07 2023 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Oct 10 08:03:11 2023 +0200

    CppunitTest_sw_ooxmlexport4: rework to avoid preTest()
    
    ImportComboBoxAsDropDown is on by default, so all we need is to turn it
    off at a single place + restore it at the test case end.
    
    Change-Id: I399aa60e5bf89817baa226de090625fd89fbbac9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157734
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index ce1645007d85..999a144cde60 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -26,6 +26,7 @@
 #include <config_fonts.h>
 #include <officecfg/Office/Writer.hxx>
 #include <vcl/svapp.hxx>
+#include <comphelper/scopeguard.hxx>
 
 class Test : public SwModelTestBase
 {
@@ -33,17 +34,6 @@ public:
     Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open 
XML Text") {}
 
 protected:
-    virtual std::unique_ptr<Resetter> preTest(const char* filename) override
-    {
-        if (filename == std::string_view("combobox-control.docx") )
-        {
-            std::shared_ptr< comphelper::ConfigurationChanges > 
batch(comphelper::ConfigurationChanges::create());
-            
officecfg::Office::Writer::Filter::Import::DOCX::ImportComboBoxAsDropDown::set(true,
 batch);
-            batch->commit();
-        }
-        return nullptr;
-    }
-
     void verifyComboBoxExport(bool aComboBoxAsDropDown);
 };
 
@@ -793,19 +783,23 @@ CPPUNIT_TEST_FIXTURE(Test, testComboBoxControl)
 
 CPPUNIT_TEST_FIXTURE(Test, tdf134043_ImportComboBoxAsDropDown_true)
 {
-    std::shared_ptr< comphelper::ConfigurationChanges > 
batch(comphelper::ConfigurationChanges::create());
-    
officecfg::Office::Writer::Filter::Import::DOCX::ImportComboBoxAsDropDown::set(true,
 batch);
-    batch->commit();
-
     createSwDoc("combobox-control.docx");
     verifyComboBoxExport(true);
 }
 
 CPPUNIT_TEST_FIXTURE(Test, tdf134043_ImportComboBoxAsDropDown_false)
 {
-    std::shared_ptr< comphelper::ConfigurationChanges > 
batch(comphelper::ConfigurationChanges::create());
+    std::shared_ptr<comphelper::ConfigurationChanges> batch(
+        comphelper::ConfigurationChanges::create());
     
officecfg::Office::Writer::Filter::Import::DOCX::ImportComboBoxAsDropDown::set(false,
 batch);
     batch->commit();
+    comphelper::ScopeGuard g(
+        [batch]
+        {
+            
officecfg::Office::Writer::Filter::Import::DOCX::ImportComboBoxAsDropDown::set(true,
+                                                                               
            batch);
+            batch->commit();
+        });
 
     createSwDoc("combobox-control.docx");
     verifyComboBoxExport(false);

Reply via email to