From 325d211aae0ef54c8e0b90ca594c4af336818259 Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Tue, 3 Jan 2017 11:56:05 +0100 Subject: LOK: Calc: unit test for invalidation on insert image Change-Id: Ie7c55c3a5c366618cafa51f9f1a102fb3cb26ec5 --- sc/qa/unit/tiledrendering/data/smile.png | Bin 0 -> 10903 bytes sc/qa/unit/tiledrendering/tiledrendering.cxx | 44 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 sc/qa/unit/tiledrendering/data/smile.png diff --git a/sc/qa/unit/tiledrendering/data/smile.png b/sc/qa/unit/tiledrendering/data/smile.png new file mode 100644 index 000000000000..ba0b89172b25 Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/smile.png differ diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 2510d161387a..06fda94ff40b 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -79,6 +79,7 @@ public: void testCommentCallback(); void testUndoLimiting(); void testUndoRepairDispatch(); + void testInsertGraphicInvalidations(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnSelections); @@ -103,6 +104,7 @@ public: CPPUNIT_TEST(testCommentCallback); CPPUNIT_TEST(testUndoLimiting); CPPUNIT_TEST(testUndoRepairDispatch); + CPPUNIT_TEST(testInsertGraphicInvalidations); CPPUNIT_TEST_SUITE_END(); private: @@ -1264,7 +1266,49 @@ void ScTiledRenderingTest::testUndoRepairDispatch() mxComponent->dispose(); mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + +void ScTiledRenderingTest::testInsertGraphicInvalidations() +{ + comphelper::LibreOfficeKit::setActive(); + + ScModelObj* pModelObj = createDoc("small.ods"); + CPPUNIT_ASSERT(pModelObj); + ScViewData* pViewData = ScDocShell::GetViewData(); + CPPUNIT_ASSERT(pViewData); + + // view + ViewCallback aView; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView); + + // we need to paint a tile in the view for triggering the tile invalidation solution + int nCanvasWidth = 256; + int nCanvasHeight = 256; + std::vector aBuffer(nCanvasWidth * nCanvasHeight * 4); + ScopedVclPtrInstance pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT); + pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), aBuffer.data()); + pModelObj->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/0, /*nTileWidth=*/3840, /*nTileHeight=*/3840); + Scheduler::ProcessEventsToIdle(); + + // insert an image in view and see if both views are invalidated + aView.m_bInvalidateTiles = false; + uno::Sequence aArgs(1); + aArgs[0].Name = OUString::fromUtf8("FileName"); + aArgs[0].Value <<= (m_directories.getURLFromSrc(DATA_DIRECTORY) + "smile.png"); + comphelper::dispatchCommand(".uno:InsertGraphic", aArgs); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(aView.m_bInvalidateTiles); + // undo image insertion in view and see if both views are invalidated + aView.m_bInvalidateTiles = false; + uno::Sequence aArgs2; + comphelper::dispatchCommand(".uno:Undo", aArgs2); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(aView.m_bInvalidateTiles); + + mxComponent->dispose(); + mxComponent.clear(); comphelper::LibreOfficeKit::setActive(false); } -- cgit v1.2.3