sc/CppunitTest_sc_tiledrendering2.mk           |   75 +++++++++++
 sc/Module_sc.mk                                |    1 
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   26 ---
 sc/qa/unit/tiledrendering2/tiledrendering2.cxx |  166 +++++++++++++++++++++++++
 4 files changed, 242 insertions(+), 26 deletions(-)

New commits:
commit a2763fe7b6f22e3e65d7e0db62b6ada967ccdd61
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Jan 23 17:08:44 2024 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Jan 25 08:16:26 2024 +0100

    CppunitTest_sc_tiledrendering2: extract one test from the old, large suite
    
    Not a split, to avoid too many conflicts while cherry-picking, but at
    least create a new suite where next tests can be added without too much
    build time after source code edits.
    
    Change-Id: I494df6e23941845a433aab6ec5ecef040feab30e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162473
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sc/CppunitTest_sc_tiledrendering2.mk 
b/sc/CppunitTest_sc_tiledrendering2.mk
new file mode 100644
index 000000000000..d360780428a6
--- /dev/null
+++ b/sc/CppunitTest_sc_tiledrendering2.mk
@@ -0,0 +1,75 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_tiledrendering2))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sc_tiledrendering2))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_tiledrendering2, \
+    sc/qa/unit/tiledrendering2/tiledrendering2 \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_tiledrendering2, \
+    comphelper \
+    cppu \
+    cppuhelper \
+    editeng \
+    sal \
+    sfx \
+    sot \
+    svl \
+    svt \
+    svxcore \
+    sc \
+    scfilt \
+    scui \
+    subsequenttest \
+    test \
+    unotest \
+    $(call gb_Helper_optional,SCRIPTING, \
+        vbahelper) \
+    vcl \
+    tl \
+    utl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sc_tiledrendering2,\
+    boost_headers \
+    libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_tiledrendering2,\
+    -I$(SRCDIR)/sc/source/ui/inc \
+    -I$(SRCDIR)/sc/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_tiledrendering2))
+$(eval $(call gb_CppunitTest_use_api,sc_tiledrendering2,oovbaapi))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_tiledrendering2))
+$(eval $(call gb_CppunitTest_use_vcl,sc_tiledrendering2))
+
+$(eval $(call gb_CppunitTest_use_rdb,sc_tiledrendering2,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_tiledrendering2))
+
+$(eval $(call gb_CppunitTest_add_arguments,sc_tiledrendering2, \
+    
-env:arg-env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}"
 \
+))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sc_tiledrendering2, \
+    modules/scalc \
+    sfx \
+    svt \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index af2450d9d14d..a159c957d988 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -70,6 +70,7 @@ ifneq ($(DISABLE_GUI),TRUE)
 ifeq ($(OS),LINUX)
 $(eval $(call gb_Module_add_check_targets,sc,\
        CppunitTest_sc_tiledrendering \
+       CppunitTest_sc_tiledrendering2 \
 ))
 endif
 endif
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 702194664eb5..14b80dde4ca7 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -3594,32 +3594,6 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testStatusBarLocale)
     CPPUNIT_ASSERT_EQUAL(std::string("de-DE"), aLocale);
 }
 
-CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testSidebarLocale)
-{
-    ScModelObj* pModelObj = createDoc("chart.ods");
-    int nView1 = SfxLokHelper::getView();
-    ViewCallback aView1;
-    SfxViewShell* pView1 = SfxViewShell::Current();
-    pView1->SetLOKLocale("en-US");
-    SfxLokHelper::createView();
-    ViewCallback aView2;
-    SfxViewShell* pView2 = SfxViewShell::Current();
-    pView2->SetLOKLocale("de-DE");
-    TestLokCallbackWrapper::InitializeSidebar();
-    Scheduler::ProcessEventsToIdle();
-    aView2.m_aStateChanges.clear();
-
-    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, 
/*x=*/1,/*y=*/1,/*count=*/2, /*buttons=*/1, /*modifier=*/0);
-    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, /*x=*/1, /*y=*/1, 
/*count=*/2, /*buttons=*/1, /*modifier=*/0);
-    SfxLokHelper::setView(nView1);
-    Scheduler::ProcessEventsToIdle();
-
-    auto it = aView2.m_aStateChanges.find(".uno:Sidebar");
-    CPPUNIT_ASSERT(it != aView2.m_aStateChanges.end());
-    std::string aLocale = it->second.get<std::string>("locale");
-    CPPUNIT_ASSERT_EQUAL(std::string("de-DE"), aLocale);
-}
-
 CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testLongFirstColumnMouseClick)
 {
     // Document has a long first column. We want to mouse-click on the column 
and
diff --git a/sc/qa/unit/tiledrendering/data/chart.ods 
b/sc/qa/unit/tiledrendering2/data/chart.ods
similarity index 100%
rename from sc/qa/unit/tiledrendering/data/chart.ods
rename to sc/qa/unit/tiledrendering2/data/chart.ods
diff --git a/sc/qa/unit/tiledrendering2/tiledrendering2.cxx 
b/sc/qa/unit/tiledrendering2/tiledrendering2.cxx
new file mode 100644
index 000000000000..058e7deb0883
--- /dev/null
+++ b/sc/qa/unit/tiledrendering2/tiledrendering2.cxx
@@ -0,0 +1,166 @@
+/* -*- 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/unoapixml_test.hxx>
+
+#include <boost/property_tree/json_parser.hpp>
+
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/lok.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <sfx2/lokhelper.hxx>
+#include <test/lokcallback.hxx>
+#include <vcl/scheduler.hxx>
+
+#include <docuno.hxx>
+
+using namespace com::sun::star;
+
+namespace
+{
+class Test : public UnoApiXmlTest
+{
+public:
+    Test();
+    void setUp() override;
+    void tearDown() override;
+
+    ScModelObj* createDoc(const char* pName);
+};
+
+Test::Test()
+    : UnoApiXmlTest("/sc/qa/unit/tiledrendering2/data/")
+{
+}
+
+void Test::setUp()
+{
+    UnoApiXmlTest::setUp();
+
+    comphelper::LibreOfficeKit::setActive(true);
+}
+
+void Test::tearDown()
+{
+    if (mxComponent.is())
+    {
+        mxComponent->dispose();
+        mxComponent.clear();
+    }
+
+    comphelper::LibreOfficeKit::resetCompatFlag();
+
+    comphelper::LibreOfficeKit::setActive(false);
+
+    UnoApiXmlTest::tearDown();
+}
+
+ScModelObj* Test::createDoc(const char* pName)
+{
+    loadFromFile(OUString::createFromAscii(pName));
+
+    ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
+    CPPUNIT_ASSERT(pModelObj);
+    
pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+    return pModelObj;
+}
+
+/// A view callback tracks callbacks invoked on one specific view.
+class ViewCallback final
+{
+    SfxViewShell* mpViewShell;
+    int mnView;
+
+public:
+    std::map<std::string, boost::property_tree::ptree> m_aStateChanges;
+    TestLokCallbackWrapper m_callbackWrapper;
+
+    ViewCallback()
+        : m_callbackWrapper(&callback, this)
+    {
+        mpViewShell = SfxViewShell::Current();
+        mpViewShell->setLibreOfficeKitViewCallback(&m_callbackWrapper);
+        mnView = SfxLokHelper::getView();
+        m_callbackWrapper.setLOKViewId(mnView);
+    }
+
+    ~ViewCallback()
+    {
+        if (mpViewShell)
+        {
+            SfxLokHelper::setView(mnView);
+            mpViewShell->setLibreOfficeKitViewCallback(nullptr);
+        }
+    }
+
+    static void callback(int nType, const char* pPayload, void* pData)
+    {
+        static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
+    }
+
+    void callbackImpl(int nType, const char* pPayload)
+    {
+        switch (nType)
+        {
+            case LOK_CALLBACK_STATE_CHANGED:
+            {
+                std::stringstream aStream(pPayload);
+                if (!aStream.str().starts_with("{"))
+                {
+                    break;
+                }
+
+                boost::property_tree::ptree aTree;
+                boost::property_tree::read_json(aStream, aTree);
+                auto it = aTree.find("commandName");
+                if (it == aTree.not_found())
+                {
+                    break;
+                }
+
+                std::string aCommandName = it->second.get_value<std::string>();
+                m_aStateChanges[aCommandName] = aTree;
+            }
+            break;
+        }
+    }
+};
+
+CPPUNIT_TEST_FIXTURE(Test, testSidebarLocale)
+{
+    ScModelObj* pModelObj = createDoc("chart.ods");
+    int nView1 = SfxLokHelper::getView();
+    ViewCallback aView1;
+    SfxViewShell* pView1 = SfxViewShell::Current();
+    pView1->SetLOKLocale("en-US");
+    SfxLokHelper::createView();
+    ViewCallback aView2;
+    SfxViewShell* pView2 = SfxViewShell::Current();
+    pView2->SetLOKLocale("de-DE");
+    TestLokCallbackWrapper::InitializeSidebar();
+    Scheduler::ProcessEventsToIdle();
+    aView2.m_aStateChanges.clear();
+
+    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, /*x=*/1, 
/*y=*/1, /*count=*/2,
+                              /*buttons=*/1, /*modifier=*/0);
+    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, /*x=*/1, /*y=*/1, 
/*count=*/2,
+                              /*buttons=*/1, /*modifier=*/0);
+    SfxLokHelper::setView(nView1);
+    Scheduler::ProcessEventsToIdle();
+
+    auto it = aView2.m_aStateChanges.find(".uno:Sidebar");
+    CPPUNIT_ASSERT(it != aView2.m_aStateChanges.end());
+    std::string aLocale = it->second.get<std::string>("locale");
+    CPPUNIT_ASSERT_EQUAL(std::string("de-DE"), aLocale);
+}
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to