From 8ff18ded5970f8bb3e90b284081449235f515df4 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Thu, 22 Apr 2021 17:42:24 +0200 Subject: tdf#141703: sd_uiimpress: Add unittest Change-Id: Ic3351a833bf2244c95f7280176b7d56f85011901 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114514 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sd/qa/unit/uiimpress.cxx | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'sd') diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index 3b25844dca24..4f2501da991a 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -444,6 +445,69 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testmoveSlides) CPPUNIT_ASSERT_EQUAL(OUString("Test 2"), pViewShell->GetActualPage()->GetName()); } +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf141703) +{ + mxComponent = loadFromDesktop("private:factory/simpress", + "com.sun.star.presentation.PresentationDocument"); + + CPPUNIT_ASSERT(mxComponent.is()); + auto pXImpressDocument = dynamic_cast(mxComponent.get()); + + uno::Sequence aArgs(comphelper::InitPropertySequence( + { { "Rows", uno::makeAny(sal_Int32(2)) }, { "Columns", uno::makeAny(sal_Int32(2)) } })); + + dispatchCommand(mxComponent, ".uno:InsertTable", aArgs); + Scheduler::ProcessEventsToIdle(); + + // Move to A1 using Alt + Tab and write 'A' + for (int i = 0; i < 3; i++) + { + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_SHIFT | KEY_TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_SHIFT | KEY_TAB); + Scheduler::ProcessEventsToIdle(); + } + + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'A', 0); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'A', 0); + Scheduler::ProcessEventsToIdle(); + + // Move to A2 with Tab and write 'B' + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_TAB); + Scheduler::ProcessEventsToIdle(); + + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'B', 0); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'B', 0); + Scheduler::ProcessEventsToIdle(); + + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::ESCAPE); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::ESCAPE); + Scheduler::ProcessEventsToIdle(); + + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + SdPage* pActualPage = pViewShell->GetActualPage(); + auto pTableObject = dynamic_cast(pActualPage->GetObj(2)); + CPPUNIT_ASSERT(pTableObject); + + uno::Reference xTable(pTableObject->getTable(), uno::UNO_SET_THROW); + uno::Reference xCellA1(xTable->getCellByPosition(0, 0), + uno::UNO_QUERY_THROW); + uno::Reference xCellA2(xTable->getCellByPosition(1, 0), + uno::UNO_QUERY_THROW); + + uno::Reference xTextA1 + = uno::Reference(xCellA1, uno::UNO_QUERY_THROW)->getText(); + + // Without the fix in place, this test would have failed with + // - Expected: A + // - Actual : + CPPUNIT_ASSERT_EQUAL(OUString("A"), xTextA1->getString()); + + uno::Reference xTextA2 + = uno::Reference(xCellA2, uno::UNO_QUERY_THROW)->getText(); + CPPUNIT_ASSERT_EQUAL(OUString("B"), xTextA2->getString()); +} + CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf127481) { mxComponent = loadFromDesktop("private:factory/simpress", -- cgit