CppunitTest_sd_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: Idb421db0a63dccee205a4092d368f6d48a093a10
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165163
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Miklos Vajna
2024-03-22 15:38:28 +01:00
parent d323976fd6
commit 14bc758fa1
5 changed files with 231 additions and 24 deletions
+71
View File
@@ -0,0 +1,71 @@
# -*- 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,sd_tiledrendering2))
$(eval $(call gb_CppunitTest_use_common_precompiled_header,sd_tiledrendering2))
$(eval $(call gb_CppunitTest_add_exception_objects,sd_tiledrendering2, \
sd/qa/unit/tiledrendering2/tiledrendering2 \
))
$(eval $(call gb_CppunitTest_use_libraries,sd_tiledrendering2, \
comphelper \
cppu \
cppuhelper \
drawinglayer \
editeng \
sal \
sfx \
subsequenttest \
svl \
svt \
svxcore \
sd \
test \
unotest \
vcl \
tl \
utl \
))
$(eval $(call gb_CppunitTest_use_externals,sd_tiledrendering2,\
boost_headers \
libxml2 \
))
$(eval $(call gb_CppunitTest_set_include,sd_tiledrendering2,\
-I$(SRCDIR)/sd/inc \
-I$(SRCDIR)/sd/source/ui/inc \
-I$(SRCDIR)/sd/qa/unit \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_sdk_api,sd_tiledrendering2))
$(eval $(call gb_CppunitTest_use_ure,sd_tiledrendering2))
$(eval $(call gb_CppunitTest_use_vcl,sd_tiledrendering2))
$(eval $(call gb_CppunitTest_use_rdb,sd_tiledrendering2,services))
$(eval $(call gb_CppunitTest_use_configuration,sd_tiledrendering2))
$(eval $(call gb_CppunitTest_use_uiconfigs,sd_tiledrendering2, \
modules/simpress \
svx \
))
$(eval $(call gb_CppunitTest_add_arguments,sd_tiledrendering2, \
-env:arg-env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \
))
# vim: set noet sw=4 ts=4:
+1
View File
@@ -60,6 +60,7 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Module_add_slowcheck_targets,sd,\
CppunitTest_sd_svg_export_tests \
CppunitTest_sd_tiledrendering \
CppunitTest_sd_tiledrendering2 \
))
endif
endif
@@ -2983,30 +2983,6 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSidebarHide)
CPPUNIT_ASSERT(it != aView.m_aStateChanges.end());
}
CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSidebarSwitchDeck)
{
// Given an impress document, with a visible sidebar (ModifyPage deck):
createDoc("dummy.odp");
ViewCallback aView;
sfx2::sidebar::Sidebar::Setup(u"");
Scheduler::ProcessEventsToIdle();
aView.m_aStateChanges.clear();
// When switching to the MasterSlidesPanel deck:
dispatchCommand(mxComponent, ".uno:MasterSlidesPanel", {});
// Then make sure notifications are sent for both the old and the new decks:
auto it = aView.m_aStateChanges.find(".uno:ModifyPage");
// Without the accompanying fix in place, this test would have failed, the notification for the
// old deck was missing.
CPPUNIT_ASSERT(it != aView.m_aStateChanges.end());
boost::property_tree::ptree aTree = it->second;
CPPUNIT_ASSERT(aTree.get_child_optional("state").has_value());
CPPUNIT_ASSERT_EQUAL(std::string("false"), aTree.get_child("state").get_value<std::string>());
it = aView.m_aStateChanges.find(".uno:MasterSlidesPanel");
CPPUNIT_ASSERT(it != aView.m_aStateChanges.end());
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Binary file not shown.
@@ -0,0 +1,159 @@
/* -*- 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 <sfx2/lokhelper.hxx>
#include <sfx2/sidebar/Sidebar.hxx>
#include <test/lokcallback.hxx>
#include <vcl/scheduler.hxx>
#include <unomodel.hxx>
using namespace css;
namespace
{
/// Impress tests with comphelper::LibreOfficeKit::isActive() enabled, part 2.
class Test : public UnoApiXmlTest
{
public:
Test();
virtual void setUp() override;
virtual void tearDown() override;
protected:
SdXImpressDocument* createDoc(const char* pName,
const uno::Sequence<beans::PropertyValue>& rArguments = {});
};
Test::Test()
: UnoApiXmlTest("/sd/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::setActive(false);
UnoApiXmlTest::tearDown();
}
SdXImpressDocument* Test::createDoc(const char* pName,
const uno::Sequence<beans::PropertyValue>& rArguments)
{
loadFromFile(OUString::createFromAscii(pName));
SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pImpressDocument);
pImpressDocument->initializeForTiledRendering(rArguments);
return pImpressDocument;
}
/// 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()
{
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, testSidebarSwitchDeck)
{
// Given an impress document, with a visible sidebar (ModifyPage deck):
createDoc("dummy.odp");
ViewCallback aView;
sfx2::sidebar::Sidebar::Setup(u"");
Scheduler::ProcessEventsToIdle();
aView.m_aStateChanges.clear();
// When switching to the MasterSlidesPanel deck:
dispatchCommand(mxComponent, ".uno:MasterSlidesPanel", {});
// Then make sure notifications are sent for both the old and the new decks:
auto it = aView.m_aStateChanges.find(".uno:ModifyPage");
// Without the accompanying fix in place, this test would have failed, the notification for the
// old deck was missing.
CPPUNIT_ASSERT(it != aView.m_aStateChanges.end());
boost::property_tree::ptree aTree = it->second;
CPPUNIT_ASSERT(aTree.get_child_optional("state").has_value());
CPPUNIT_ASSERT_EQUAL(std::string("false"), aTree.get_child("state").get_value<std::string>());
it = aView.m_aStateChanges.find(".uno:MasterSlidesPanel");
CPPUNIT_ASSERT(it != aView.m_aStateChanges.end());
}
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */