summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2017-01-03 11:56:05 +0100
committerJan Holesovsky <kendy@collabora.com>2017-03-31 19:22:54 +0200
commit325d211aae0ef54c8e0b90ca594c4af336818259 (patch)
tree8837b3023a38f42ba752e6e29d3912e015e5f8ad
parent83487c28d3e2d0b331dd161b97a804be8e9bc1b9 (diff)
LOK: Calc: unit test for invalidation on insert image
Change-Id: Ie7c55c3a5c366618cafa51f9f1a102fb3cb26ec5
-rw-r--r--sc/qa/unit/tiledrendering/data/smile.pngbin0 -> 10903 bytes
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx44
2 files changed, 44 insertions, 0 deletions
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
--- /dev/null
+++ b/sc/qa/unit/tiledrendering/data/smile.png
Binary files 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<unsigned char> aBuffer(nCanvasWidth * nCanvasHeight * 4);
+ ScopedVclPtrInstance<VirtualDevice> 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<beans::PropertyValue> 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<beans::PropertyValue> aArgs2;
+ comphelper::dispatchCommand(".uno:Undo", aArgs2);
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT(aView.m_bInvalidateTiles);
+
+ mxComponent->dispose();
+ mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
}