summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-10-21 12:09:56 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-10-22 15:53:21 +0200
commita21c6a3dd36aee21bf1536183dc8ccde2ff52672 (patch)
tree4362424f8ba2e52eb7c9c971d51d0ce797594cf4 /test
parent71a24a911bb091885fb03d124d3936d955b13399 (diff)
revert unittests to use plain text-based LibreOfficeKitCallback
At least for now it seems that the more complex SfxLokCallbackInterface is just an unnecessary complication for unit tests. The performance doesn't matter, and handling all the specialized callbacks makes things more complicated. In the future it'd be also useful to make the tests (optionally?) use also CallbackFlushHandler as the provider of the messages, in order to test CallbackFlushHandler more thoroughly, so perhaps in the end it makes more sense to keep unit tests using the plain text interface. This reverts unittest-related parts of 3b729db05553c1a6d461fb41c89 and adds a smaller wrapper callback class that converts messages from SfxLokCallbackInterface to LibreOfficeKitCallback format. Change-Id: I6c14f0be4ed7b777444b131140be54188d309cca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124000 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'test')
-rw-r--r--test/Library_test.mk1
-rw-r--r--test/source/lokcallback.cxx55
2 files changed, 56 insertions, 0 deletions
diff --git a/test/Library_test.mk b/test/Library_test.mk
index 4be059857a84..8b1fd214490d 100644
--- a/test/Library_test.mk
+++ b/test/Library_test.mk
@@ -50,6 +50,7 @@ $(eval $(call gb_Library_add_exception_objects,test,\
test/source/htmltesttools \
test/source/screenshot_test \
test/source/unoapi_property_testers \
+ test/source/lokcallback \
test/source/helper/form \
test/source/helper/shape \
test/source/helper/transferable \
diff --git a/test/source/lokcallback.cxx b/test/source/lokcallback.cxx
new file mode 100644
index 000000000000..912fe2d8c807
--- /dev/null
+++ b/test/source/lokcallback.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/lokcallback.hxx>
+
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <rtl/strbuf.hxx>
+#include <tools/gen.hxx>
+#include <comphelper/lok.hxx>
+
+TestLokCallbackWrapper::TestLokCallbackWrapper(LibreOfficeKitCallback callback, void* data)
+ : m_callback(callback)
+ , m_data(data)
+{
+}
+
+inline void TestLokCallbackWrapper::callCallback(int nType, const char* pPayload)
+{
+ m_callback(nType, pPayload, m_data);
+}
+
+void TestLokCallbackWrapper::libreOfficeKitViewCallback(int nType, const char* pPayload)
+{
+ callCallback(nType, pPayload);
+}
+
+void TestLokCallbackWrapper::libreOfficeKitViewCallback(int nType, const char* pPayload,
+ int /*nViewId*/)
+{
+ callCallback(nType, pPayload); // the view id is also included in payload
+}
+
+void TestLokCallbackWrapper::libreOfficeKitViewInvalidateTilesCallback(
+ const tools::Rectangle* pRect, int nPart)
+{
+ OStringBuffer buf(64);
+ if (pRect)
+ buf.append(pRect->toString());
+ else
+ buf.append("EMPTY");
+ if (comphelper::LibreOfficeKit::isPartInInvalidation())
+ {
+ buf.append(", ");
+ buf.append(static_cast<sal_Int32>(nPart));
+ }
+ callCallback(LOK_CALLBACK_INVALIDATE_TILES, buf.makeStringAndClear().getStr());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */