include/test/lokcallback.hxx | 4 +++- sw/qa/extras/tiledrendering/tiledrendering.cxx | 12 +++--------- sw/source/core/view/viewsh.cxx | 6 ++++++ test/Library_test.mk | 1 + test/source/lokcallback.cxx | 19 ++++++++++++++++++- 5 files changed, 31 insertions(+), 11 deletions(-)
New commits: commit 62f47c26ad096cf088b545f10e14f9d81e2f2cc1 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Wed Oct 20 11:32:17 2021 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Fri Oct 22 15:54:02 2021 +0200 properly flush LOK invalidations in tests This should be done always before doing something with a flag related to the invalidations. Use an idle timer for simplicity, tests already usually process to idle. Change-Id: I979900da28061cc690ecbcce023dbb769239f205 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124003 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/include/test/lokcallback.hxx b/include/test/lokcallback.hxx index f7a619f68cb3..f7372bc7ec80 100644 --- a/include/test/lokcallback.hxx +++ b/include/test/lokcallback.hxx @@ -13,6 +13,7 @@ #include <test/testdllapi.hxx> #include <LibreOfficeKit/LibreOfficeKitTypes.h> #include <sfx2/lokcallback.hxx> +#include <vcl/idle.hxx> /** A helper to convert SfxLokCallbackInterface to a LIbreOfficeKitCallback for tests. @@ -21,7 +22,7 @@ It reimplements the specialized callbacks and converts them to the generic type/ callback. */ -class OOO_DLLPUBLIC_TEST TestLokCallbackWrapper : public SfxLokCallbackInterface +class OOO_DLLPUBLIC_TEST TestLokCallbackWrapper final : public SfxLokCallbackInterface, public Idle { public: TestLokCallbackWrapper(LibreOfficeKitCallback callback, void* data); @@ -30,6 +31,7 @@ public: int nViewId) override; virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) override; + virtual void Invoke() override; private: void callCallback(int nType, const char* pPayload); diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 2bc101923b41..7dab608c6323 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -444,7 +444,7 @@ void SwTiledRenderingTest::testRegisterCallback() pWrtShell->GetSfxViewShell()->setLibreOfficeKitViewCallback(&m_callbackWrapper); // Insert a character at the beginning of the document. pWrtShell->Insert("x"); - pWrtShell->GetSfxViewShell()->flushPendingLOKInvalidateTiles(); + Scheduler::ProcessEventsToIdle(); // Check that the top left 256x256px tile would be invalidated. CPPUNIT_ASSERT(!m_aInvalidation.IsEmpty()); @@ -863,11 +863,6 @@ namespace { mpViewShell->setLibreOfficeKitViewCallback(nullptr); } - void flushPendingLOKInvalidateTiles() - { - mpViewShell->flushPendingLOKInvalidateTiles(); - } - static void callback(int nType, const char* pPayload, void* pData) { static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload); @@ -1044,13 +1039,12 @@ void SwTiledRenderingTest::testMissingInvalidation() pWrtShell->SelWrd(); // Now delete the selected word and make sure both views are invalidated. + Scheduler::ProcessEventsToIdle(); aView1.m_bTilesInvalidated = false; aView2.m_bTilesInvalidated = false; pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DELETE); pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DELETE); Scheduler::ProcessEventsToIdle(); - aView1.flushPendingLOKInvalidateTiles(); - aView2.flushPendingLOKInvalidateTiles(); CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); CPPUNIT_ASSERT(aView2.m_bTilesInvalidated); } @@ -1262,6 +1256,7 @@ void SwTiledRenderingTest::testUndoInvalidations() CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb.c"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); // Undo and assert that both views are invalidated. + Scheduler::ProcessEventsToIdle(); aView1.m_bTilesInvalidated = false; aView2.m_bTilesInvalidated = false; comphelper::dispatchCommand(".uno:Undo", {}); @@ -1739,7 +1734,6 @@ void SwTiledRenderingTest::testCommentEndTextEdit() pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RETURN); pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_RETURN); Scheduler::ProcessEventsToIdle(); - aView1.flushPendingLOKInvalidateTiles(); CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); } diff --git a/test/Library_test.mk b/test/Library_test.mk index 8b1fd214490d..bee378ff34f5 100644 --- a/test/Library_test.mk +++ b/test/Library_test.mk @@ -33,6 +33,7 @@ $(eval $(call gb_Library_use_libraries,test,\ cppuhelper \ i18nlangtag \ sal \ + sfx \ svt \ test-setupvcl \ tl \ diff --git a/test/source/lokcallback.cxx b/test/source/lokcallback.cxx index 389219192a50..13d381f0b46a 100644 --- a/test/source/lokcallback.cxx +++ b/test/source/lokcallback.cxx @@ -13,16 +13,23 @@ #include <rtl/strbuf.hxx> #include <tools/gen.hxx> #include <comphelper/lok.hxx> +#include <sfx2/viewsh.hxx> TestLokCallbackWrapper::TestLokCallbackWrapper(LibreOfficeKitCallback callback, void* data) - : m_callback(callback) + : Idle("TestLokCallbackWrapper flush timer") + , m_callback(callback) , m_data(data) { + // Flushing timer needs to run with the lowest priority, so that all pending tasks + // such as invalidations are processed before it. + SetPriority(TaskPriority::LOWEST); } inline void TestLokCallbackWrapper::callCallback(int nType, const char* pPayload) { m_callback(nType, pPayload, m_data); + if (!IsActive()) + Start(); } void TestLokCallbackWrapper::libreOfficeKitViewCallback(int nType, const char* pPayload) @@ -52,4 +59,14 @@ void TestLokCallbackWrapper::libreOfficeKitViewInvalidateTilesCallback( callCallback(LOK_CALLBACK_INVALIDATE_TILES, buf.makeStringAndClear().getStr()); } +void TestLokCallbackWrapper::Invoke() +{ + // Timer timeout, flush any possibly pending data. + for (SfxViewShell* viewShell = SfxViewShell::GetFirst(false); viewShell != nullptr; + viewShell = SfxViewShell::GetNext(*viewShell, false)) + { + viewShell->flushPendingLOKInvalidateTiles(); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 9037e42ab3c3793341b583b181617185aefcbde5 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Thu Oct 21 15:07:27 2021 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Fri Oct 22 15:53:47 2021 +0200 ignore invalidations in Writer when doing tiled painting That's done by ignoreLibreOfficeKitViewCallback() called from SfxViewShell::libreOfficeKitViewInvalidateTilesCallback(), but in case Writer delays invalidations to compress them, the tiled painting flag may be already reset by the time flushPendingLOKInvalidateTiles() gets called, so handle that explicitly. SwTiledRenderingTest::testTablePaintInvalidate() would otherwise fail with my follow-up commit that makes TestLokCallbackWrapper flush the invalidations. Change-Id: I915ae4e40bc7a82b3e48498f7e5513420dd64522 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124002 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 5b372141f48a..20b4d0ac13a6 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -553,6 +553,12 @@ void SwViewShell::InvalidateWindows( const SwRect &rRect ) if(comphelper::LibreOfficeKit::isActive()) { + // If we are inside tiled painting, invalidations are ignored. + // Ignore them right now to save work, but also to avoid the problem + // that this state could be reset before FlushPendingLOKInvalidateTiles() + // gets called. + if(comphelper::LibreOfficeKit::isTiledPainting()) + return; // First collect all invalidations and perform them only later, // otherwise the number of Invalidate() calls would be at least // O(n^2) if not worse. The problem is that if any change in a document