summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-10-04 10:56:55 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-10-04 15:16:07 +0200
commitdfc9a744a536fb822ad067683c957143bc81c5b4 (patch)
treeb084f92e9d25b6a299bc04593e1aaf07334b813b /sw/qa/extras
parentb41b72139ee5a92260b5d8732a437106d31b1688 (diff)
comphelper: move setTiledPainting() from SfxViewShell
And make it a static one. The primary point of that member function is to prevent invalidations during paint, and since multiple views are allowed, it wasn't extended to filter out invalidations from all views, not just from the current one. (Same goes for other callback types.) (cherry picked from commit 59e38e946f19ab59370f8e52370b7a7b861cc558) Conflicts: include/sfx2/viewsh.hxx sfx2/source/view/viewsh.cxx Change-Id: I23e6b2c2ff94227f2b72c481148b2d8279ae2905
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx44
1 files changed, 43 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index e7b78b7ade82..eb64e9f69432 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -78,6 +78,7 @@ public:
void testRedlineColors();
void testCommentEndTextEdit();
void testCursorPosition();
+ void testPaintCallbacks();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -119,6 +120,7 @@ public:
CPPUNIT_TEST(testRedlineColors);
CPPUNIT_TEST(testCommentEndTextEdit);
CPPUNIT_TEST(testCursorPosition);
+ CPPUNIT_TEST(testPaintCallbacks);
CPPUNIT_TEST_SUITE_END();
private:
@@ -641,6 +643,8 @@ public:
bool m_bGraphicViewSelection;
bool m_bGraphicSelection;
bool m_bViewLock;
+ /// Set if any callback was invoked.
+ bool m_bCalled;
ViewCallback()
: m_bOwnCursorInvalidated(false),
@@ -652,7 +656,8 @@ public:
m_bViewCursorVisible(false),
m_bGraphicViewSelection(false),
m_bGraphicSelection(false),
- m_bViewLock(false)
+ m_bViewLock(false),
+ m_bCalled(false)
{
}
@@ -664,6 +669,7 @@ public:
void callbackImpl(int nType, const char* pPayload)
{
OString aPayload(pPayload);
+ m_bCalled = true;
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
@@ -1530,6 +1536,42 @@ void SwTiledRenderingTest::testCursorPosition()
comphelper::LibreOfficeKit::setActive(false);
}
+template<typename T>
+struct NoDelete
+{
+ void operator()(T* /* p */) {}
+};
+
+void SwTiledRenderingTest::testPaintCallbacks()
+{
+ // Test that paintTile() never results in callbacks, which can cause a
+ // paint <-> invalidate loop.
+
+ // Load a document and register a callback for the first view.
+ comphelper::LibreOfficeKit::setActive();
+ SwXTextDocument* pXTextDocument = createDoc();
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+
+ // Create a second view and paint a tile on that second view.
+ SfxLokHelper::createView();
+ int nCanvasWidth = 256;
+ int nCanvasHeight = 256;
+ std::vector<unsigned char> aBuffer(nCanvasWidth * nCanvasHeight * 4);
+ ScopedVclPtrInstance<VirtualDevice> pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
+ boost::shared_array<sal_uInt8> aSharedBuffer(aBuffer.data(), NoDelete<sal_uInt8>());
+ pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), aSharedBuffer);
+ // Make sure that painting a tile in the second view doesn't invoke
+ // callbacks on the first view.
+ aView1.m_bCalled = false;
+ pXTextDocument->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/0, /*nTileWidth=*/3840, /*nTileHeight=*/3840);
+ CPPUNIT_ASSERT(!aView1.m_bCalled);
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();