summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-01-17 20:46:52 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-01-18 07:11:22 +0000
commit02f286271d4b44d995f8f2f8f30fbc10ed764b49 (patch)
treeafabdb177d3d296182ee57ca80b36f1ea776b873
parent7195e2740eb1c71f5bbc4322b3535d56b39e2817 (diff)
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 <vmiklos@collabora.com>
-rw-r--r--sw/qa/extras/rtfexport/rtfexport2.cxx37
1 files changed, 21 insertions, 16 deletions
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")