From 1b1a9c6c12ebe4cac19e34ff5e4818998bbb2537 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Wed, 21 Apr 2021 22:09:27 +0200 Subject: tdf#119793: sc_uicalc: Add unittest Change-Id: Ie676a88546bd7ee1a077aba4c3322307b14319a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114457 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sc/qa/unit/uicalc/data/tdf119793.ods | Bin 0 -> 8039 bytes sc/qa/unit/uicalc/uicalc.cxx | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 sc/qa/unit/uicalc/data/tdf119793.ods (limited to 'sc') diff --git a/sc/qa/unit/uicalc/data/tdf119793.ods b/sc/qa/unit/uicalc/data/tdf119793.ods new file mode 100644 index 000000000000..e303bed01891 Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf119793.ods differ diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 90a412d4588e..e42465402749 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -658,6 +658,47 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133326) CPPUNIT_ASSERT_EQUAL(static_cast(2), pDoc->GetTableCount()); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf119793) +{ + ScModelObj* pModelObj = createDoc("tdf119793.ods"); + + uno::Reference xPage(pModelObj->getDrawPages()->getByIndex(0), + uno::UNO_QUERY_THROW); + uno::Reference xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW); + + CPPUNIT_ASSERT_EQUAL(static_cast(4984), xShape->getPosition().X); + CPPUNIT_ASSERT_EQUAL(static_cast(1381), xShape->getPosition().Y); + + // Move the shape to the right + lcl_SelectObjectByName(u"Shape 1"); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RIGHT); + Scheduler::ProcessEventsToIdle(); + + //position has changed + CPPUNIT_ASSERT_EQUAL(static_cast(5084), xShape->getPosition().X); + CPPUNIT_ASSERT_EQUAL(static_cast(1381), xShape->getPosition().Y); + + // Type into the shape + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(static_cast(5084), xShape->getPosition().X); + CPPUNIT_ASSERT_EQUAL(static_cast(1381), xShape->getPosition().Y); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + // Without the fix in place, this test would have failed with + // - Expected: 4984 + // - Actual : 5084 + CPPUNIT_ASSERT_EQUAL(static_cast(4984), xShape->getPosition().X); + CPPUNIT_ASSERT_EQUAL(static_cast(1381), xShape->getPosition().Y); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf131455) { ScModelObj* pModelObj = createDoc("tdf131455.ods"); -- cgit