[Libreoffice-commits] core.git: desktop/qa include/unotest sw/qa xmlsecurity/qa

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 6 07:30:01 UTC 2020


 desktop/qa/desktop_lib/test_desktop_lib.cxx |   24 ------------------------
 include/unotest/macros_test.hxx             |   25 +++++++++++++++++++++++++
 sw/qa/inc/swmodeltestbase.hxx               |   24 ------------------------
 xmlsecurity/qa/unit/signing/signing.cxx     |   27 ---------------------------
 4 files changed, 25 insertions(+), 75 deletions(-)

New commits:
commit f016f9016f5139791d544b5e5aa2ac438227b735
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Aug 5 21:12:44 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Aug 6 09:29:23 2020 +0200

    unotest: one Resetter is enough
    
    It seems all 3 places derive from unotest::MacrosTest, so extract the
    common code there.
    
    Change-Id: I71a2474a7d6b1623f50575f9e9c43580ba076330
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100185
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 5b6947f93eaf..68ce00bdfe84 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -60,30 +60,6 @@ using namespace desktop;
 
 class DesktopLOKTest : public UnoApiTest
 {
-    class Resetter
-    {
-    private:
-        std::function<void ()> m_Func;
-
-    public:
-        Resetter(std::function<void ()> const& rFunc)
-            : m_Func(rFunc)
-        {
-        }
-        ~Resetter()
-        {
-            try
-            {
-                m_Func();
-            }
-            catch (...) // has to be reliable
-            {
-                fprintf(stderr, "resetter failed with exception\n");
-                abort();
-            }
-        }
-    };
-
 public:
     DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"),
     m_nSelectionBeforeSearchResult(0),
diff --git a/include/unotest/macros_test.hxx b/include/unotest/macros_test.hxx
index 2960dc0fbb23..6f55e34e7c87 100644
--- a/include/unotest/macros_test.hxx
+++ b/include/unotest/macros_test.hxx
@@ -13,6 +13,7 @@
 #include <sal/config.h>
 
 #include <memory>
+#include <functional>
 #include <config_gpgme.h>
 #include <rtl/ustring.hxx>
 #include <unotest/detail/unotestdllapi.hxx>
@@ -38,6 +39,30 @@ namespace unotest {
 class OOO_DLLPUBLIC_UNOTEST MacrosTest
 {
 public:
+    class Resetter
+    {
+    private:
+        std::function<void ()> m_Func;
+
+    public:
+        Resetter(std::function<void ()> const& rFunc)
+            : m_Func(rFunc)
+        {
+        }
+        ~Resetter()
+        {
+            try
+            {
+                m_Func();
+            }
+            catch (...) // has to be reliable
+            {
+                fprintf(stderr, "resetter failed with exception\n");
+                abort();
+            }
+        }
+    };
+
     MacrosTest();
     ~MacrosTest();
 
diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx
index 6193be33afc3..c3d5033a8370 100644
--- a/sw/qa/inc/swmodeltestbase.hxx
+++ b/sw/qa/inc/swmodeltestbase.hxx
@@ -141,30 +141,6 @@ protected:
 
 protected:
 
-    class Resetter
-    {
-    private:
-        std::function<void ()> m_Func;
-
-    public:
-        Resetter(std::function<void ()> const& rFunc)
-            : m_Func(rFunc)
-        {
-        }
-        ~Resetter()
-        {
-            try
-            {
-                m_Func();
-            }
-            catch (...) // has to be reliable
-            {
-                fprintf(stderr, "resetter failed with exception\n");
-                abort();
-            }
-        }
-    };
-
     virtual OUString getTestName() { return OUString(); }
 
     /// Copy&paste helper.
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index ec17d7a82d78..a62dbd096aa0 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -1221,33 +1221,6 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testDropMacroTemplateSignature)
                    SignatureState::NOSIGNATURES, ODFVER_013_TEXT);
 }
 
-namespace
-{
-class Resetter
-{
-private:
-    std::function<void()> m_Func;
-
-public:
-    Resetter(std::function<void()> const& rFunc)
-        : m_Func(rFunc)
-    {
-    }
-    ~Resetter()
-    {
-        try
-        {
-            m_Func();
-        }
-        catch (...) // has to be reliable
-        {
-            fprintf(stderr, "resetter failed with exception\n");
-            abort();
-        }
-    }
-};
-}
-
 /// Test if a macro signature from a OTT 1.0 template is preserved for ODT 1.0
 CPPUNIT_TEST_FIXTURE(SigningTest, testPreserveMacroTemplateSignature10)
 {


More information about the Libreoffice-commits mailing list