Make sure swui's pSwResMgr is initialized in CppunitTest_sw_dialogs_test
...to avoid -fsanitize=null at > sw/source/ui/misc/glossary.cxx:840:17: runtime error: reference binding to null pointer of type 'ResMgr' > #0 0x7f980fc6b73f in SwGlTreeListBox::SwGlTreeListBox(vcl::Window*, long) sw/source/ui/misc/glossary.cxx:840:17 > #1 0x7f980fc80d56 in VclPtr<SwGlTreeListBox> VclPtr<SwGlTreeListBox>::Create<VclPtr<vcl::Window>&, long>(VclPtr<vcl::Window>&, long&&) include/vcl/vclptr.hxx:138:46 > #2 0x7f980fc6c5d2 in makeSwGlTreeListBox sw/source/ui/misc/glossary.cxx:851:1 > #3 0x7f985da4c3c4 in VclBuilder::makeObject(vcl::Window*, rtl::OString const&, rtl::OString const&, std::__debug::map<rtl::OString, rtl::OString, std::less<rtl::OString>, std::allocator<std::pair<rtl::OString const, rtl::OString> > >&) vcl/source/window/builder.cxx:1793:17 Change-Id: Ieb0d0f6b561e93acbee8208e1ba445879e99adc1
This commit is contained in:
@@ -20,6 +20,7 @@ $(eval $(call gb_CppunitTest_use_sdk_api,sw_dialogs_test))
|
|||||||
$(eval $(call gb_CppunitTest_set_include,sw_dialogs_test,\
|
$(eval $(call gb_CppunitTest_set_include,sw_dialogs_test,\
|
||||||
-I$(SRCDIR)/sw/source/ui/inc \
|
-I$(SRCDIR)/sw/source/ui/inc \
|
||||||
-I$(SRCDIR)/sw/inc \
|
-I$(SRCDIR)/sw/inc \
|
||||||
|
-I$(SRCDIR)/sw/source/uibase/inc \
|
||||||
$$(INCLUDE) \
|
$$(INCLUDE) \
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@@ -9,17 +9,25 @@
|
|||||||
|
|
||||||
#include <sal/config.h>
|
#include <sal/config.h>
|
||||||
#include <test/screenshot_test.hxx>
|
#include <test/screenshot_test.hxx>
|
||||||
|
#include <rtl/bootstrap.hxx>
|
||||||
#include <rtl/strbuf.hxx>
|
#include <rtl/strbuf.hxx>
|
||||||
#include <osl/file.hxx>
|
#include <osl/file.hxx>
|
||||||
#include <sfx2/app.hxx>
|
#include <sfx2/app.hxx>
|
||||||
#include <vcl/abstdlg.hxx>
|
#include <vcl/abstdlg.hxx>
|
||||||
|
|
||||||
|
#include <swabstdlg.hxx>
|
||||||
|
|
||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
|
|
||||||
|
extern "C" { using Fn = SwAbstractDialogFactory * (*)(); }
|
||||||
|
// sw/source/ui/dialog/swuiexp.cxx
|
||||||
|
|
||||||
/// Test opening a dialog in sw
|
/// Test opening a dialog in sw
|
||||||
class SwDialogsTest : public ScreenshotTest
|
class SwDialogsTest : public ScreenshotTest
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
osl::Module libSwui_;
|
||||||
|
|
||||||
/// helper method to populate KnownDialogs, called in setUp(). Needs to be
|
/// helper method to populate KnownDialogs, called in setUp(). Needs to be
|
||||||
/// written and has to add entries to KnownDialogs
|
/// written and has to add entries to KnownDialogs
|
||||||
virtual void registerKnownDialogsByID(mapType& rKnownDialogs) override;
|
virtual void registerKnownDialogsByID(mapType& rKnownDialogs) override;
|
||||||
@@ -32,6 +40,8 @@ public:
|
|||||||
SwDialogsTest();
|
SwDialogsTest();
|
||||||
virtual ~SwDialogsTest() override;
|
virtual ~SwDialogsTest() override;
|
||||||
|
|
||||||
|
void setUp() override;
|
||||||
|
|
||||||
// try to open a dialog
|
// try to open a dialog
|
||||||
void openAnyDialog();
|
void openAnyDialog();
|
||||||
|
|
||||||
@@ -48,6 +58,22 @@ SwDialogsTest::~SwDialogsTest()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SwDialogsTest::setUp()
|
||||||
|
{
|
||||||
|
ScreenshotTest::setUp();
|
||||||
|
// Make sure the swui library's global pSwResMgr is initialized
|
||||||
|
// (alternatively to dynamically loading the library, SwCreateDialogFactory
|
||||||
|
// could be declared in an include file and this CppunitTest link against
|
||||||
|
// the swui library):
|
||||||
|
OUString url("${LO_LIB_DIR}/" SVLIBRARY("swui"));
|
||||||
|
rtl::Bootstrap::expandMacros(url); //TODO: detect failure
|
||||||
|
CPPUNIT_ASSERT(libSwui_.load(url, SAL_LOADMODULE_GLOBAL));
|
||||||
|
auto fn = reinterpret_cast<Fn>(
|
||||||
|
libSwui_.getFunctionSymbol("SwCreateDialogFactory"));
|
||||||
|
CPPUNIT_ASSERT(fn != nullptr);
|
||||||
|
(*fn)();
|
||||||
|
}
|
||||||
|
|
||||||
void SwDialogsTest::registerKnownDialogsByID(mapType& /*rKnownDialogs*/)
|
void SwDialogsTest::registerKnownDialogsByID(mapType& /*rKnownDialogs*/)
|
||||||
{
|
{
|
||||||
// fill map of known dialogs
|
// fill map of known dialogs
|
||||||
|
Reference in New Issue
Block a user