summaryrefslogtreecommitdiff
path: root/sc/qa/unit
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:25:43 +0200
commit6b6b99bad355185169a87d724538cb9074285c65 (patch)
tree3bb30a02f24871e5b5d82fcf06fd8c9d04719e8c /sc/qa/unit
parent437612237aa31437dfcb639c72e349edd3ccef27 (diff)
LOK: Calc: unit test for invalidation on insert image
Change-Id: Ie7c55c3a5c366618cafa51f9f1a102fb3cb26ec5
Diffstat (limited to 'sc/qa/unit')
-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 5e1ba9b3cec1..cb0f5aea7b9b 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -74,6 +74,7 @@ public:
void testCommentCallback();
void testUndoLimiting();
void testUndoRepairDispatch();
+ void testInsertGraphicInvalidations();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections);
@@ -98,6 +99,7 @@ public:
CPPUNIT_TEST(testCommentCallback);
CPPUNIT_TEST(testUndoLimiting);
CPPUNIT_TEST(testUndoRepairDispatch);
+ CPPUNIT_TEST(testInsertGraphicInvalidations);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1259,7 +1261,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);
}