diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-10-20 11:32:17 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-10-22 15:54:02 +0200 |
commit | 62f47c26ad096cf088b545f10e14f9d81e2f2cc1 (patch) | |
tree | 3e3e70e924b4075adb9b351042f658e132d1c4bc /test | |
parent | 9037e42ab3c3793341b583b181617185aefcbde5 (diff) |
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.lunak@collabora.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/Library_test.mk | 1 | ||||
-rw-r--r-- | test/source/lokcallback.cxx | 19 |
2 files changed, 19 insertions, 1 deletions
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: */ |