sc/qa/unit/uicalc/uicalc.cxx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
New commits: commit 0cda0b47b171671b2d4d081c02e039dfda89839b Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Nov 30 11:22:16 2021 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Nov 30 18:49:17 2021 +0100 tdf#144308: sc_uicalc: Add unittest Change-Id: Ia37d19722fc7a4ef46cf6f17fa0e45a12db0e7b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126111 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index beaf837bf1a4..9c7ac09a9285 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -16,11 +16,13 @@ #include <vcl/keycodes.hxx> #include <vcl/scheduler.hxx> +#include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/scopeguard.hxx> #include <com/sun/star/awt/Key.hpp> #include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/sheet/GlobalSheetSettings.hpp> #include <com/sun/star/text/XTextRange.hpp> #include <conditio.hxx> #include <dbfunc.hxx> @@ -171,6 +173,39 @@ ScModelObj* ScUiCalcTest::saveAndReload(css::uno::Reference<css::lang::XComponen return pModelObj; } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf144308) +{ + mxComponent = loadFromDesktop("private:factory/scalc"); + ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + css::uno::Reference<css::sheet::XGlobalSheetSettings> xGlobalSheetSettings + = css::sheet::GlobalSheetSettings::create(::comphelper::getProcessComponentContext()); + bool bOldValue = xGlobalSheetSettings->getDoAutoComplete(); + + xGlobalSheetSettings->setDoAutoComplete(true); + + pDoc->SetString(ScAddress(0, 0, 0), "ABC"); + + insertStringToCell(*pModelObj, "A2", "A"); + + CPPUNIT_ASSERT_EQUAL(OUString("ABC"), pDoc->GetString(ScAddress(0, 1, 0))); + + xGlobalSheetSettings->setDoAutoComplete(false); + + insertStringToCell(*pModelObj, "A3", "A"); + + // Without the fix in place, this test would have failed with + // - Expected: A + // - Actual : ABC + CPPUNIT_ASSERT_EQUAL(OUString("A"), pDoc->GetString(ScAddress(0, 2, 0))); + + // Restore the previous value + xGlobalSheetSettings->setDoAutoComplete(bOldValue); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf119162) { mxComponent = loadFromDesktop("private:factory/scalc");