From 3a8124d5ce9c45a14edb88c5614d994e4dbfc225 Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Sun, 22 Sep 2019 13:21:46 +0200 Subject: sd lok: Test invalidation after adding\removing slide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://gerrit.libreoffice.org/79499 Reviewed-by: Tamás Zolnai Tested-by: Tamás Zolnai (cherry picked from commit 2984856798d8ad98b96e6a57bfcc701bc52876e8) Change-Id: I4677d78b1bfad36a7b3bde4651b9900e617b6422 Reviewed-on: https://gerrit.libreoffice.org/79625 Reviewed-by: Tamás Zolnai Tested-by: Tamás Zolnai --- sd/qa/unit/tiledrendering/tiledrendering.cxx | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'sd') diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index d9797587ae21..6a3837897bbb 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -117,6 +117,7 @@ public: void testTdf115873Group(); void testCutSelectionChange(); void testLanguageAllText(); + void testInsertDeletePageInvalidation(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -164,6 +165,7 @@ public: CPPUNIT_TEST(testTdf115873Group); CPPUNIT_TEST(testCutSelectionChange); CPPUNIT_TEST(testLanguageAllText); + CPPUNIT_TEST(testInsertDeletePageInvalidation); CPPUNIT_TEST_SUITE_END(); @@ -931,6 +933,7 @@ public: bool m_bCursorVisibleChanged; bool m_bViewLock; bool m_bTilesInvalidated; + std::vector m_aInvalidations; std::map m_aViewCursorInvalidations; std::map m_aViewCursorVisibilities; bool m_bViewSelectionSet; @@ -959,6 +962,18 @@ public: case LOK_CALLBACK_INVALIDATE_TILES: { m_bTilesInvalidated = true; + OString text(pPayload); + if (!text.startsWith("EMPTY")) + { + uno::Sequence aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload)); + CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); + tools::Rectangle aInvalidationRect; + aInvalidationRect.setX(aSeq[0].toInt32()); + aInvalidationRect.setY(aSeq[1].toInt32()); + aInvalidationRect.setWidth(aSeq[2].toInt32()); + aInvalidationRect.setHeight(aSeq[3].toInt32()); + m_aInvalidations.push_back(aInvalidationRect); + } } break; case LOK_CALLBACK_GRAPHIC_SELECTION: @@ -2168,6 +2183,34 @@ void SdTiledRenderingTest::testCutSelectionChange() CPPUNIT_ASSERT_EQUAL(static_cast(0), m_aSelection.size()); } +void SdTiledRenderingTest::testInsertDeletePageInvalidation() +{ + // Load the document. + comphelper::LibreOfficeKit::setActive(); + SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + CPPUNIT_ASSERT_EQUAL(8, pXImpressDocument->getParts()); + + // Insert slide + aView1.m_bTilesInvalidated = false; + aView1.m_aInvalidations.clear(); + comphelper::dispatchCommand(".uno:InsertPage", uno::Sequence()); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); + CPPUNIT_ASSERT_EQUAL(9, pXImpressDocument->getParts()); + CPPUNIT_ASSERT_EQUAL(size_t(9), aView1.m_aInvalidations.size()); + + // Delete slide + aView1.m_bTilesInvalidated = false; + aView1.m_aInvalidations.clear(); + comphelper::dispatchCommand(".uno:DeletePage", uno::Sequence()); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); + CPPUNIT_ASSERT_EQUAL(8, pXImpressDocument->getParts()); + CPPUNIT_ASSERT_EQUAL(size_t(8), aView1.m_aInvalidations.size()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit