sw/qa/extras/rtfexport/rtfexport5.cxx |   36 +++++++++++++++-------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

New commits:
commit a262ee4c4a682f844ef380d5e843be1b3ec78c98
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Jan 31 20:21:46 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Feb 1 07:03:38 2023 +0000

    CppunitTest_sw_rtfexport5: fold preTest() into its only user
    
    Avoid magic in preTest() based on the bugdoc name.
    
    Change-Id: I7642828480bb4f636956b966275d8c3e26919a50
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146421
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx 
b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 1104b9e4683b..fb020428ef03 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -38,6 +38,7 @@
 #include <vcl/settings.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 #include <i18nlangtag/languagetag.hxx>
+#include <comphelper/scopeguard.hxx>
 
 using namespace css;
 
@@ -48,24 +49,6 @@ public:
         : SwModelTestBase("/sw/qa/extras/rtfexport/data/", "Rich Text Format")
     {
     }
-
-    virtual std::unique_ptr<Resetter> preTest(const char* filename) override
-    {
-        m_aSavedSettings = Application::GetSettings();
-        if (filename == std::string_view("fdo72031.rtf"))
-        {
-            std::unique_ptr<Resetter> pResetter(
-                new Resetter([this]() { 
Application::SetSettings(this->m_aSavedSettings); }));
-            AllSettings aSettings(m_aSavedSettings);
-            aSettings.SetLanguageTag(LanguageTag("ru"));
-            Application::SetSettings(aSettings);
-            return pResetter;
-        }
-        return nullptr;
-    }
-
-protected:
-    AllSettings m_aSavedSettings;
 };
 
 DECLARE_RTFEXPORT_TEST(testFdo63023, "fdo63023.rtf")
@@ -756,9 +739,22 @@ DECLARE_RTFEXPORT_TEST(testFdo85889mac, "fdo85889-mac.rtf")
     CPPUNIT_ASSERT_EQUAL(OUString(u"\u00D2\u00DA\u00DB"), 
xTextRange->getString());
 }
 
-DECLARE_RTFEXPORT_TEST(testFdo72031, "fdo72031.rtf")
+CPPUNIT_TEST_FIXTURE(Test, testFdo72031)
 {
-    CPPUNIT_ASSERT_EQUAL(OUString(u"\uF0C5"), getRun(getParagraph(1), 
1)->getString());
+    auto verify = [this]() {
+        CPPUNIT_ASSERT_EQUAL(OUString(u"\uF0C5"), getRun(getParagraph(1), 
1)->getString());
+    };
+
+    AllSettings aSavedSettings = Application::GetSettings();
+    AllSettings aSettings(aSavedSettings);
+    aSettings.SetLanguageTag(LanguageTag("ru"));
+    Application::SetSettings(aSettings);
+    comphelper::ScopeGuard g([&aSavedSettings] { 
Application::SetSettings(aSavedSettings); });
+
+    createSwDoc("fdo72031.rtf");
+    verify();
+    reload(mpFilter, "fdo72031.rtf");
+    verify();
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo86750, "fdo86750.rtf")

Reply via email to