summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-04-22 17:42:24 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-04-22 21:26:49 +0200
commit8ff18ded5970f8bb3e90b284081449235f515df4 (patch)
tree17f9bbb0e6b3f0db7f048954e84cf8fa4787e1e1 /sd
parenta7d862560e273442891432a88dff9a320c80575a (diff)
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 <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/uiimpress.cxx64
1 files changed, 64 insertions, 0 deletions
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 <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/XDrawView.hpp>
#include <com/sun/star/frame/DispatchHelper.hpp>
+#include <com/sun/star/table/XMergeableCell.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
@@ -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<SdXImpressDocument*>(mxComponent.get());
+
+ uno::Sequence<beans::PropertyValue> 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<sdr::table::SdrTableObj*>(pActualPage->GetObj(2));
+ CPPUNIT_ASSERT(pTableObject);
+
+ uno::Reference<css::table::XTable> xTable(pTableObject->getTable(), uno::UNO_SET_THROW);
+ uno::Reference<css::table::XMergeableCell> xCellA1(xTable->getCellByPosition(0, 0),
+ uno::UNO_QUERY_THROW);
+ uno::Reference<css::table::XMergeableCell> xCellA2(xTable->getCellByPosition(1, 0),
+ uno::UNO_QUERY_THROW);
+
+ uno::Reference<text::XText> xTextA1
+ = uno::Reference<text::XTextRange>(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<text::XText> xTextA2
+ = uno::Reference<text::XTextRange>(xCellA2, uno::UNO_QUERY_THROW)->getText();
+ CPPUNIT_ASSERT_EQUAL(OUString("B"), xTextA2->getString());
+}
+
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf127481)
{
mxComponent = loadFromDesktop("private:factory/simpress",