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 14:34:57 +0200
commit59e38e946f19ab59370f8e52370b7a7b861cc558 (patch)
tree6f8dc52f6951996fa25a5f229f8b65f7b5fcc916 /sw/qa/extras
parentac9373e65ed7908a19edc6f5c758af9b8232820b (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.) Change-Id: I23e6b2c2ff94227f2b72c481148b2d8279ae2905
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx37
1 files changed, 36 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 82f5b11d139e..7b441d67648a 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -77,6 +77,7 @@ public:
void testRedlineColors();
void testCommentEndTextEdit();
void testCursorPosition();
+ void testPaintCallbacks();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -118,6 +119,7 @@ public:
CPPUNIT_TEST(testRedlineColors);
CPPUNIT_TEST(testCommentEndTextEdit);
CPPUNIT_TEST(testCursorPosition);
+ CPPUNIT_TEST(testPaintCallbacks);
CPPUNIT_TEST_SUITE_END();
private:
@@ -640,6 +642,8 @@ public:
bool m_bGraphicViewSelection;
bool m_bGraphicSelection;
bool m_bViewLock;
+ /// Set if any callback was invoked.
+ bool m_bCalled;
ViewCallback()
: m_bOwnCursorInvalidated(false),
@@ -651,7 +655,8 @@ public:
m_bViewCursorVisible(false),
m_bGraphicViewSelection(false),
m_bGraphicSelection(false),
- m_bViewLock(false)
+ m_bViewLock(false),
+ m_bCalled(false)
{
}
@@ -663,6 +668,7 @@ public:
void callbackImpl(int nType, const char* pPayload)
{
OString aPayload(pPayload);
+ m_bCalled = true;
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
@@ -1529,6 +1535,35 @@ void SwTiledRenderingTest::testCursorPosition()
comphelper::LibreOfficeKit::setActive(false);
}
+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);
+ pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), aBuffer.data());
+ // 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();