diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-02-04 14:38:30 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-02-04 18:16:38 +0100 |
commit | 9f0d27c973323f522a4ca2bce557e1c095d32f77 (patch) | |
tree | 6bd0fd9cab8f77ccee6d53e44f3a2ab8545bde23 /sc | |
parent | 510d551669bb8c487ea7e2a4f5e4a7ab67d96033 (diff) |
tdf#146795: sc_uicalc: Add unittest
Change-Id: I37accef701ad1240572839170258b9f405409abd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129488
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/uicalc/data/tdf146795.ods | bin | 0 -> 9510 bytes | |||
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 46 |
2 files changed, 46 insertions, 0 deletions
diff --git a/sc/qa/unit/uicalc/data/tdf146795.ods b/sc/qa/unit/uicalc/data/tdf146795.ods Binary files differnew file mode 100644 index 000000000000..9c402b058345 --- /dev/null +++ b/sc/qa/unit/uicalc/data/tdf146795.ods diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 876a871ae965..b058ab29156e 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -262,6 +262,52 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf119155) pDoc->GetString(ScAddress(2, 13, 0))); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf146795) +{ + ScModelObj* pModelObj = createDoc("tdf146795.ods"); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + // Disable replace cell warning + ScModule* pMod = SC_MOD(); + ScInputOptions aInputOption = pMod->GetInputOptions(); + bool bOldStatus = aInputOption.GetReplaceCellsWarn(); + aInputOption.SetReplaceCellsWarn(false); + pMod->SetInputOptions(aInputOption); + + goToCell("B2"); + + dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + // Move to B3 + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN); + Scheduler::ProcessEventsToIdle(); + + // Select the three following cells + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_SHIFT | KEY_DOWN); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_SHIFT | KEY_DOWN); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_SHIFT | KEY_DOWN); + Scheduler::ProcessEventsToIdle(); + + // Without the fix in place, this test would have crashed here + dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString("a"), pDoc->GetString(ScAddress(1, 1, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("a"), pDoc->GetString(ScAddress(1, 2, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("a"), pDoc->GetString(ScAddress(1, 3, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("44"), pDoc->GetString(ScAddress(1, 4, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("44"), pDoc->GetString(ScAddress(1, 5, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("a"), pDoc->GetString(ScAddress(1, 6, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("a"), pDoc->GetString(ScAddress(1, 7, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("44"), pDoc->GetString(ScAddress(1, 8, 0))); + + // Restore previous status + aInputOption.SetReplaceCellsWarn(bOldStatus); + pMod->SetInputOptions(aInputOption); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf138432) { ScModelObj* pModelObj = createDoc("tdf138432.ods"); |