sc/qa/unit/tiledrendering/tiledrendering.cxx | 31 ++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-)
New commits: commit 9f4548198485779bd13ace7ec32d018dcbb3bec9 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Nov 30 09:13:53 2023 +0000 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Nov 30 14:53:14 2023 +0100 cppunit test for notification of note position changes on row/col changes Change-Id: I32ed5cd249400f71903e7aa848ba63d03abbd9b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160137 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 30eaaebf207a..1f18401a970c 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -1247,6 +1247,10 @@ void ScTiledRenderingTest::testCommentCallback() SfxLokHelper::setView(nView1); + ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); + if (pTabViewShell) + pTabViewShell->SetCursor(4, 4); + // Add a new comment uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence( { @@ -1267,15 +1271,32 @@ void ScTiledRenderingTest::testCommentCallback() CPPUNIT_ASSERT_EQUAL(std::string("LOK User1"), aView2.m_aCommentCallbackResult.get<std::string>("author")); CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView2.m_aCommentCallbackResult.get<std::string>("text")); - CPPUNIT_ASSERT_EQUAL(std::string("0 1 0 1"), aView1.m_aCommentCallbackResult.get<std::string>("cellRange")); - CPPUNIT_ASSERT_EQUAL(std::string("0 1 0 1"), aView2.m_aCommentCallbackResult.get<std::string>("cellRange")); + CPPUNIT_ASSERT_EQUAL(std::string("4 4 4 4"), aView1.m_aCommentCallbackResult.get<std::string>("cellRange")); + CPPUNIT_ASSERT_EQUAL(std::string("4 4 4 4"), aView2.m_aCommentCallbackResult.get<std::string>("cellRange")); + + // Ensure deleting rows updates comments + if (pTabViewShell) + pTabViewShell->SetCursor(2, 2); + + dispatchCommand(mxComponent, ".uno:DeleteRows", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(std::string("4 3 4 3"), aView1.m_aCommentCallbackResult.get<std::string>("cellRange")); + CPPUNIT_ASSERT_EQUAL(std::string("4 3 4 3"), aView2.m_aCommentCallbackResult.get<std::string>("cellRange")); + + // Ensure deleting columns updates comments + if (pTabViewShell) + pTabViewShell->SetCursor(2, 2); + + dispatchCommand(mxComponent, ".uno:DeleteColumns", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(std::string("3 3 3 3"), aView1.m_aCommentCallbackResult.get<std::string>("cellRange")); + CPPUNIT_ASSERT_EQUAL(std::string("3 3 3 3"), aView2.m_aCommentCallbackResult.get<std::string>("cellRange")); std::string aCommentId = aView1.m_aCommentCallbackResult.get<std::string>("id"); // Edit a comment // Select some random cell, we should be able to edit the cell note without // selecting the cell - ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); if (pTabViewShell) pTabViewShell->SetCursor(3, 100); aArgs = comphelper::InitPropertySequence( @@ -1296,8 +1317,8 @@ void ScTiledRenderingTest::testCommentCallback() CPPUNIT_ASSERT_EQUAL(std::string("LOK User2"), aView2.m_aCommentCallbackResult.get<std::string>("author")); CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView2.m_aCommentCallbackResult.get<std::string>("text")); - CPPUNIT_ASSERT_EQUAL(std::string("0 1 0 1"), aView1.m_aCommentCallbackResult.get<std::string>("cellRange")); - CPPUNIT_ASSERT_EQUAL(std::string("0 1 0 1"), aView2.m_aCommentCallbackResult.get<std::string>("cellRange")); + CPPUNIT_ASSERT_EQUAL(std::string("3 3 3 3"), aView1.m_aCommentCallbackResult.get<std::string>("cellRange")); + CPPUNIT_ASSERT_EQUAL(std::string("3 3 3 3"), aView2.m_aCommentCallbackResult.get<std::string>("cellRange")); // Delete the comment if (pTabViewShell)
