diff options
author | Henry Castro <hcastro@collabora.com> | 2021-01-15 16:13:29 -0400 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2021-01-20 14:55:25 +0100 |
commit | 08d45119cfb875fa8a5c03d6e946a47f0f680932 (patch) | |
tree | 648e12fd9bf5c94d6a53f1ddaf12ce526bf8e583 | |
parent | f7b31b02f2fe28f75d2a70c0261897aba4a7b72d (diff) |
lok: unit test incorrect cursor position
Test to not send client side cursor position (0,0)
due to:
mpOutlinerView->SetOutputArea( PixelToLogic( tools::Rectangle(0,0,1,1) ) );
Change-Id: Ib5cd7f1c0c45073c5d2039e8b889d3a6fd7ef70c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109417
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 6fc8affd77eb..4f708dfe76c5 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -226,6 +226,7 @@ public: void testControlState(); void testMetricField(); void testMultiDocuments(); + void testJumpCursor(); void testABI(); CPPUNIT_TEST_SUITE(DesktopLOKTest); @@ -289,6 +290,7 @@ public: CPPUNIT_TEST(testControlState); CPPUNIT_TEST(testMetricField); CPPUNIT_TEST(testMultiDocuments); + CPPUNIT_TEST(testJumpCursor); CPPUNIT_TEST(testABI); CPPUNIT_TEST_SUITE_END(); @@ -1947,13 +1949,15 @@ class ViewCallback public: OString m_aCellFormula; bool m_bTilesInvalidated; + bool m_bZeroCursor; tools::Rectangle m_aOwnCursor; boost::property_tree::ptree m_aCommentCallbackResult; boost::property_tree::ptree m_aCallbackWindowResult; ViewCallback(LibLODocument_Impl* pDocument) : mpDocument(pDocument), - m_bTilesInvalidated(false) + m_bTilesInvalidated(false), + m_bZeroCursor(false) { mnView = SfxLokHelper::getView(); mpDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, this); @@ -1990,6 +1994,9 @@ public: m_aOwnCursor.setY(aSeq[1].toInt32()); m_aOwnCursor.setWidth(aSeq[2].toInt32()); m_aOwnCursor.setHeight(aSeq[3].toInt32()); + + if (m_aOwnCursor.getX() == 0 && m_aOwnCursor.getY() == 0) + m_bZeroCursor = true; } break; case LOK_CALLBACK_COMMENT: @@ -3088,6 +3095,36 @@ void DesktopLOKTest::testMultiDocuments() } } +void DesktopLOKTest::testJumpCursor() +{ + comphelper::LibreOfficeKit::setTiledAnnotations(false); + + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); + pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'B', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'o', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'l', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'i', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'v', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'i', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'a', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 0, com::sun::star::awt::Key::ESCAPE); + Scheduler::ProcessEventsToIdle(); + + // There is a cursor jump to (0, 0) due to + // mpOutlinerView->SetOutputArea( PixelToLogic( tools::Rectangle(0,0,1,1) ) ); + // when creating a comment + ViewCallback aView1(pDocument); + + pDocument->pClass->postUnoCommand(pDocument, ".uno:InsertAnnotation", nullptr, true); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT(!aView1.m_bZeroCursor); + + comphelper::LibreOfficeKit::setTiledAnnotations(true); +} + namespace { constexpr size_t classOffset(int i) |