From a21c6a3dd36aee21bf1536183dc8ccde2ff52672 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Thu, 21 Oct 2021 12:09:56 +0200 Subject: revert unittests to use plain text-based LibreOfficeKitCallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- test/source/lokcallback.cxx | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/source/lokcallback.cxx (limited to 'test/source') 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 + +#include +#include +#include +#include + +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(nPart)); + } + callCallback(LOK_CALLBACK_INVALIDATE_TILES, buf.makeStringAndClear().getStr()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit