sw/qa/extras/rtfexport/rtfexport2.cxx |   37 +++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 16 deletions(-)

New commits:
commit 02f286271d4b44d995f8f2f8f30fbc10ed764b49
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Jan 17 20:46:52 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Jan 18 07:11:22 2023 +0000

    CppunitTest_sw_rtfexport2: make testFdo48023() more self-contained
    
    Avoid magic in preTest() based on the bugdoc name.
    
    Change-Id: I40e3d58230e8e815bcea067cfc0ecca4ebeca98e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145683
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx 
b/sw/qa/extras/rtfexport/rtfexport2.cxx
index e840a0d2ad4f..b2a8bca644db 100644
--- a/sw/qa/extras/rtfexport/rtfexport2.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport2.cxx
@@ -30,6 +30,7 @@
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
 #include <i18nlangtag/languagetag.hxx>
+#include <comphelper/scopeguard.hxx>
 
 #include <bordertest.hxx>
 
@@ -44,16 +45,7 @@ public:
     virtual std::unique_ptr<Resetter> preTest(const char* filename) override
     {
         m_aSavedSettings = Application::GetSettings();
-        if (filename == std::string_view("fdo48023.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;
-        }
-        else if (filename == std::string_view("fdo44211.rtf"))
+        if (filename == std::string_view("fdo44211.rtf"))
         {
             std::unique_ptr<Resetter> pResetter(
                 new Resetter([this]() { 
Application::SetSettings(this->m_aSavedSettings); }));
@@ -314,14 +306,27 @@ DECLARE_RTFEXPORT_TEST(testFdo48356, "fdo48356.rtf")
     CPPUNIT_ASSERT_EQUAL(1, i);
 }
 
-DECLARE_RTFEXPORT_TEST(testFdo48023, "fdo48023.rtf")
+CPPUNIT_TEST_FIXTURE(Test, testFdo48023)
 {
-    uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
+    auto verify = [this]() {
+        uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 
1);
 
-    // Implicit encoding detection based on locale was missing
-    CPPUNIT_ASSERT_EQUAL(
-        
OUString(u"\u041F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0438\u0441\u0442"),
-        xTextRange->getString());
+        // Implicit encoding detection based on locale was missing
+        CPPUNIT_ASSERT_EQUAL(
+            
OUString(u"\u041F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0438\u0441\u0442"),
+            xTextRange->getString());
+    };
+
+    AllSettings aSavedSettings = Application::GetSettings();
+    AllSettings aSettings(aSavedSettings);
+    aSettings.SetLanguageTag(LanguageTag("ru"));
+    Application::SetSettings(aSettings);
+    comphelper::ScopeGuard g([&aSavedSettings] { 
Application::SetSettings(aSavedSettings); });
+
+    createSwDoc("fdo48023.rtf");
+    verify();
+    reload(mpFilter, "fdo48023.rtf");
+    verify();
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo48876, "fdo48876.rtf")

Reply via email to