[Libreoffice-commits] core.git: sc/CppunitTest_sc_uicalc.mk sc/qa

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 13 22:30:19 UTC 2021


 sc/CppunitTest_sc_uicalc.mk          |    3 ++
 sc/qa/unit/uicalc/data/tdf138432.ods |binary
 sc/qa/unit/uicalc/uicalc.cxx         |   45 +++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)

New commits:
commit 213430e0bdac0786b30a76a68b43d35647e93912
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Jul 12 19:39:10 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Wed Jul 14 00:29:46 2021 +0200

    tdf#123752, tdf#138432: sc_uicalc: Add unittest
    
    Change-Id: I9f40ab9198b52fdf3d402543d33c3043d6f45b53
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118789
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sc/CppunitTest_sc_uicalc.mk b/sc/CppunitTest_sc_uicalc.mk
index 82bfb875b05e..e0df316fe3ab 100644
--- a/sc/CppunitTest_sc_uicalc.mk
+++ b/sc/CppunitTest_sc_uicalc.mk
@@ -19,9 +19,12 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_uicalc, \
     comphelper \
     cppu \
     cppuhelper \
+    i18nlangtag \
     sal \
     sc \
     sfx \
+    svl \
+    svl \
     svx \
     svxcore \
     test \
diff --git a/sc/qa/unit/uicalc/data/tdf138432.ods b/sc/qa/unit/uicalc/data/tdf138432.ods
new file mode 100644
index 000000000000..31b2e2309dc1
Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf138432.ods differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 61707d5cb02a..c0825914e3fc 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -11,11 +11,13 @@
 #include <unotest/macros_test.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <svx/svdpage.hxx>
+#include <unotools/syslocaleoptions.hxx>
 #include <unotools/tempfile.hxx>
 #include <vcl/keycodes.hxx>
 #include <vcl/scheduler.hxx>
 
 #include <comphelper/propertysequence.hxx>
+#include <comphelper/scopeguard.hxx>
 #include <com/sun/star/awt/Key.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/text/XTextRange.hpp>
@@ -165,6 +167,49 @@ ScModelObj* ScUiCalcTest::saveAndReload(css::uno::Reference<css::lang::XComponen
     return pModelObj;
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf138432)
+{
+    ScModelObj* pModelObj = createDoc("tdf138432.ods");
+    ScDocument* pDoc = pModelObj->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+
+    // Set the system locale to Hungarian
+    SvtSysLocaleOptions aOptions;
+    OUString sLocaleConfigString = aOptions.GetLanguageTag().getBcp47();
+    aOptions.SetLocaleConfigString("hu-HU");
+    aOptions.Commit();
+    comphelper::ScopeGuard g([&aOptions, &sLocaleConfigString] {
+        aOptions.SetLocaleConfigString(sLocaleConfigString);
+        aOptions.Commit();
+    });
+
+    OUString sExpectedA1 = "12" + OUStringChar(u'\xa0') + "345,67";
+    CPPUNIT_ASSERT_EQUAL(sExpectedA1, pDoc->GetString(ScAddress(0, 0, 0)));
+
+    goToCell("A1");
+
+    dispatchCommand(mxComponent, ".uno:Copy", {});
+    Scheduler::ProcessEventsToIdle();
+
+    goToCell("A2");
+
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, '=', 0);
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, '=', 0);
+    Scheduler::ProcessEventsToIdle();
+
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+    Scheduler::ProcessEventsToIdle();
+
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+    Scheduler::ProcessEventsToIdle();
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 12345,67
+    // - Actual  : Err:509
+    CPPUNIT_ASSERT_EQUAL(OUString("12345,67"), pDoc->GetString(ScAddress(0, 1, 0)));
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf100582)
 {
     ScModelObj* pModelObj = createDoc("tdf100582.xls");


More information about the Libreoffice-commits mailing list