diff options
author | Henry Castro <hcastro@collabora.com> | 2021-01-15 16:13:29 -0400 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2021-04-10 15:49:32 +0100 |
commit | b67a7a34393061d4f84850ec423a38ba01f67785 (patch) | |
tree | 0ab2cf250c0630e3dd9175dd7566e37b1a8be5d1 /desktop | |
parent | aab35b69548155ae65e4cf7ac3ab02c8561082ca (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>
(cherry picked from commit 08d45119cfb875fa8a5c03d6e946a47f0f680932)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109733
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'desktop')
-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 701f624038c5..ce99a9356d11 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -196,6 +196,7 @@ public: void testControlState(); void testMetricField(); void testMultiDocuments(); + void testJumpCursor(); void testABI(); CPPUNIT_TEST_SUITE(DesktopLOKTest); @@ -259,6 +260,7 @@ public: CPPUNIT_TEST(testControlState); CPPUNIT_TEST(testMetricField); CPPUNIT_TEST(testMultiDocuments); + CPPUNIT_TEST(testJumpCursor); CPPUNIT_TEST(testABI); CPPUNIT_TEST_SUITE_END(); @@ -1923,6 +1925,7 @@ 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; @@ -1930,7 +1933,8 @@ public: 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); @@ -1967,6 +1971,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: @@ -3077,6 +3084,36 @@ void DesktopLOKTest::testMetricField() CPPUNIT_ASSERT_EQUAL(aMap["VALUE"], aRet["Value"]); } +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) |