fdo#52076 unittest
Change-Id: Iae10f9728db4c90c4a55ad692b32cddeb7adc48a
This commit is contained in:
119
dbaccess/CppunitTest_dbaccess_empty_stdlib_save.mk
Normal file
119
dbaccess/CppunitTest_dbaccess_empty_stdlib_save.mk
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
# -*- 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,dbaccess_empty_stdlib_save))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_add_exception_objects,dbaccess_empty_stdlib_save, \
|
||||||
|
dbaccess/qa/extras/empty-stdlib-save \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_externals,dbaccess_empty_stdlib_save,\
|
||||||
|
boost_headers \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_libraries,dbaccess_empty_stdlib_save, \
|
||||||
|
basegfx \
|
||||||
|
comphelper \
|
||||||
|
cppu \
|
||||||
|
cppuhelper \
|
||||||
|
dba \
|
||||||
|
dbu \
|
||||||
|
sdbt \
|
||||||
|
drawinglayer \
|
||||||
|
editeng \
|
||||||
|
for \
|
||||||
|
forui \
|
||||||
|
i18nlangtag \
|
||||||
|
msfilter \
|
||||||
|
oox \
|
||||||
|
sal \
|
||||||
|
salhelper \
|
||||||
|
sax \
|
||||||
|
sb \
|
||||||
|
sfx \
|
||||||
|
sot \
|
||||||
|
svl \
|
||||||
|
svt \
|
||||||
|
svx \
|
||||||
|
svxcore \
|
||||||
|
test \
|
||||||
|
subsequenttest \
|
||||||
|
tl \
|
||||||
|
tk \
|
||||||
|
ucbhelper \
|
||||||
|
unotest \
|
||||||
|
utl \
|
||||||
|
vbahelper \
|
||||||
|
vcl \
|
||||||
|
xo \
|
||||||
|
$(gb_UWINAPI) \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_set_include,dbaccess_empty_stdlib_save,\
|
||||||
|
$$(INCLUDE) \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_api,dbaccess_empty_stdlib_save,\
|
||||||
|
offapi \
|
||||||
|
oovbaapi \
|
||||||
|
udkapi \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_ure,dbaccess_empty_stdlib_save))
|
||||||
|
$(eval $(call gb_CppunitTest_use_vcl,dbaccess_empty_stdlib_save))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_components,dbaccess_empty_stdlib_save,\
|
||||||
|
basic/util/sb \
|
||||||
|
comphelper/util/comphelp \
|
||||||
|
configmgr/source/configmgr \
|
||||||
|
dbaccess/util/dba \
|
||||||
|
dbaccess/util/dbu \
|
||||||
|
dbaccess/util/sdbt \
|
||||||
|
dbaccess/source/filter/xml/dbaxml \
|
||||||
|
filter/source/config/cache/filterconfig1 \
|
||||||
|
forms/util/frm \
|
||||||
|
framework/util/fwk \
|
||||||
|
i18npool/util/i18npool \
|
||||||
|
linguistic/source/lng \
|
||||||
|
oox/util/oox \
|
||||||
|
package/source/xstor/xstor \
|
||||||
|
package/util/package2 \
|
||||||
|
sax/source/expatwrap/expwrap \
|
||||||
|
scripting/source/basprov/basprov \
|
||||||
|
scripting/util/scriptframe \
|
||||||
|
sfx2/util/sfx \
|
||||||
|
sot/util/sot \
|
||||||
|
svl/source/fsstor/fsstorage \
|
||||||
|
svl/util/svl \
|
||||||
|
toolkit/util/tk \
|
||||||
|
ucb/source/core/ucb1 \
|
||||||
|
ucb/source/ucp/file/ucpfile1 \
|
||||||
|
ucb/source/ucp/tdoc/ucptdoc1 \
|
||||||
|
unotools/util/utl \
|
||||||
|
unoxml/source/rdf/unordf \
|
||||||
|
unoxml/source/service/unoxml \
|
||||||
|
xmloff/util/xo \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_configuration,dbaccess_empty_stdlib_save))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_filter_configuration,dbaccess_empty_stdlib_save))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_unittest_configuration,dbaccess_empty_stdlib_save))
|
||||||
|
|
||||||
|
$(call gb_CppunitTest_get_target,dbaccess_empty_stdlib_save) : $(WORKDIR)/CppunitTest/testEmptyStdlibSave.odb
|
||||||
|
$(WORKDIR)/CppunitTest/testEmptyStdlibSave.odb : $(SRCDIR)/dbaccess/qa/extras/testdocuments/testDialogSave.odb
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
cp -P -f "$<" "$@"
|
||||||
|
.PHONY: $(WORKDIR)/CppunitTest/testEmptyStdlibSave.odb
|
||||||
|
|
||||||
|
$(call gb_CppunitTest_get_target,dbaccess_empty_stdlib_save): \
|
||||||
|
$(call gb_AllLangResTarget_get_target,ofa)
|
||||||
|
|
||||||
|
# vim: set noet sw=4 ts=4:
|
119
dbaccess/CppunitTest_dbaccess_nolib_save.mk
Normal file
119
dbaccess/CppunitTest_dbaccess_nolib_save.mk
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
# -*- 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,dbaccess_nolib_save))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_add_exception_objects,dbaccess_nolib_save, \
|
||||||
|
dbaccess/qa/extras/nolib-save \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_externals,dbaccess_nolib_save,\
|
||||||
|
boost_headers \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_libraries,dbaccess_nolib_save, \
|
||||||
|
basegfx \
|
||||||
|
comphelper \
|
||||||
|
cppu \
|
||||||
|
cppuhelper \
|
||||||
|
dba \
|
||||||
|
dbu \
|
||||||
|
sdbt \
|
||||||
|
drawinglayer \
|
||||||
|
editeng \
|
||||||
|
for \
|
||||||
|
forui \
|
||||||
|
i18nlangtag \
|
||||||
|
msfilter \
|
||||||
|
oox \
|
||||||
|
sal \
|
||||||
|
salhelper \
|
||||||
|
sax \
|
||||||
|
sb \
|
||||||
|
sfx \
|
||||||
|
sot \
|
||||||
|
svl \
|
||||||
|
svt \
|
||||||
|
svx \
|
||||||
|
svxcore \
|
||||||
|
test \
|
||||||
|
subsequenttest \
|
||||||
|
tl \
|
||||||
|
tk \
|
||||||
|
ucbhelper \
|
||||||
|
unotest \
|
||||||
|
utl \
|
||||||
|
vbahelper \
|
||||||
|
vcl \
|
||||||
|
xo \
|
||||||
|
$(gb_UWINAPI) \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_set_include,dbaccess_nolib_save,\
|
||||||
|
$$(INCLUDE) \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_api,dbaccess_nolib_save,\
|
||||||
|
offapi \
|
||||||
|
oovbaapi \
|
||||||
|
udkapi \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_ure,dbaccess_nolib_save))
|
||||||
|
$(eval $(call gb_CppunitTest_use_vcl,dbaccess_nolib_save))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_components,dbaccess_nolib_save,\
|
||||||
|
basic/util/sb \
|
||||||
|
comphelper/util/comphelp \
|
||||||
|
configmgr/source/configmgr \
|
||||||
|
dbaccess/util/dba \
|
||||||
|
dbaccess/util/dbu \
|
||||||
|
dbaccess/util/sdbt \
|
||||||
|
dbaccess/source/filter/xml/dbaxml \
|
||||||
|
filter/source/config/cache/filterconfig1 \
|
||||||
|
forms/util/frm \
|
||||||
|
framework/util/fwk \
|
||||||
|
i18npool/util/i18npool \
|
||||||
|
linguistic/source/lng \
|
||||||
|
oox/util/oox \
|
||||||
|
package/source/xstor/xstor \
|
||||||
|
package/util/package2 \
|
||||||
|
sax/source/expatwrap/expwrap \
|
||||||
|
scripting/source/basprov/basprov \
|
||||||
|
scripting/util/scriptframe \
|
||||||
|
sfx2/util/sfx \
|
||||||
|
sot/util/sot \
|
||||||
|
svl/source/fsstor/fsstorage \
|
||||||
|
svl/util/svl \
|
||||||
|
toolkit/util/tk \
|
||||||
|
ucb/source/core/ucb1 \
|
||||||
|
ucb/source/ucp/file/ucpfile1 \
|
||||||
|
ucb/source/ucp/tdoc/ucptdoc1 \
|
||||||
|
unotools/util/utl \
|
||||||
|
unoxml/source/rdf/unordf \
|
||||||
|
unoxml/source/service/unoxml \
|
||||||
|
xmloff/util/xo \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_configuration,dbaccess_nolib_save))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_filter_configuration,dbaccess_nolib_save))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_unittest_configuration,dbaccess_nolib_save))
|
||||||
|
|
||||||
|
$(call gb_CppunitTest_get_target,dbaccess_nolib_save) : $(WORKDIR)/CppunitTest/testNolibSave.odb
|
||||||
|
$(WORKDIR)/CppunitTest/testNolibSave.odb : $(SRCDIR)/dbaccess/qa/extras/testdocuments/testDialogSave.odb
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
cp -P -f "$<" "$@"
|
||||||
|
.PHONY: $(WORKDIR)/CppunitTest/testNolibSave.odb
|
||||||
|
|
||||||
|
$(call gb_CppunitTest_get_target,dbaccess_nolib_save): \
|
||||||
|
$(call gb_AllLangResTarget_get_target,ofa)
|
||||||
|
|
||||||
|
# vim: set noet sw=4 ts=4:
|
@@ -42,6 +42,8 @@ endif
|
|||||||
|
|
||||||
$(eval $(call gb_Module_add_check_targets,dbaccess,\
|
$(eval $(call gb_Module_add_check_targets,dbaccess,\
|
||||||
CppunitTest_dbaccess_dialog_save \
|
CppunitTest_dbaccess_dialog_save \
|
||||||
|
CppunitTest_dbaccess_empty_stdlib_save \
|
||||||
|
CppunitTest_dbaccess_nolib_save \
|
||||||
CppunitTest_dbaccess_macros_test \
|
CppunitTest_dbaccess_macros_test \
|
||||||
))
|
))
|
||||||
|
|
||||||
|
145
dbaccess/qa/extras/empty-stdlib-save.cxx
Normal file
145
dbaccess/qa/extras/empty-stdlib-save.cxx
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
/* -*- 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 <sal/config.h>
|
||||||
|
#include <test/bootstrapfixture.hxx>
|
||||||
|
#include <test/unoapi_test.hxx>
|
||||||
|
#include <rtl/strbuf.hxx>
|
||||||
|
#include <osl/file.hxx>
|
||||||
|
#include <com/sun/star/frame/Desktop.hpp>
|
||||||
|
#include <com/sun/star/lang/XComponent.hpp>
|
||||||
|
#include <com/sun/star/frame/XStorable.hpp>
|
||||||
|
#include <com/sun/star/document/XEmbeddedScripts.hpp>
|
||||||
|
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
|
||||||
|
#include <com/sun/star/script/XLibraryContainer.hpp>
|
||||||
|
#include <com/sun/star/util/XModifiable.hpp>
|
||||||
|
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
|
||||||
|
#include <com/sun/star/io/XStream.hpp>
|
||||||
|
#include <com/sun/star/io/XInputStream.hpp>
|
||||||
|
|
||||||
|
#include <sfx2/app.hxx>
|
||||||
|
#include <sfx2/docfilt.hxx>
|
||||||
|
#include <sfx2/docfile.hxx>
|
||||||
|
#include <sfx2/objsh.hxx>
|
||||||
|
#include <sfx2/sfxmodelfactory.hxx>
|
||||||
|
#include <svl/intitem.hxx>
|
||||||
|
#include <comphelper/processfactory.hxx>
|
||||||
|
|
||||||
|
#include <basic/sbxdef.hxx>
|
||||||
|
|
||||||
|
using namespace ::com::sun::star;
|
||||||
|
using namespace ::com::sun::star::uno;
|
||||||
|
|
||||||
|
|
||||||
|
class DialogSaveTest : public UnoApiTest
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DialogSaveTest();
|
||||||
|
|
||||||
|
void test();
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE(DialogSaveTest);
|
||||||
|
// Should we disable this test on MOX and WNT?
|
||||||
|
// #if !defined(MACOSX) && !defined(WNT)
|
||||||
|
CPPUNIT_TEST(test);
|
||||||
|
// #endif
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
DialogSaveTest::DialogSaveTest()
|
||||||
|
: UnoApiTest("/dbaccess/qa/extras/testdocuments")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogSaveTest::test()
|
||||||
|
{
|
||||||
|
// UnoApiTest::setUp (via InitVCL) puts each test under a locked SolarMutex,
|
||||||
|
// but at least the below xDocCloseable->close call could lead to a deadlock
|
||||||
|
// then, and it looks like none of the code here requires the SolarMutex to
|
||||||
|
// be locked anyway:
|
||||||
|
SolarMutexReleaser rel;
|
||||||
|
|
||||||
|
const OUString sStandard("Standard");
|
||||||
|
const OUString aFileName(getURLFromWorkdir("CppunitTest/testEmptyStdlibSave.odb"));
|
||||||
|
{
|
||||||
|
uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName);
|
||||||
|
CPPUNIT_ASSERT(xComponent.is());
|
||||||
|
uno::Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xDocStorable.is());
|
||||||
|
uno::Reference< document::XEmbeddedScripts > xDocScr(xComponent, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xDocScr.is());
|
||||||
|
uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries());
|
||||||
|
CPPUNIT_ASSERT(xStorBasLib.is());
|
||||||
|
uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xBasLib.is());
|
||||||
|
uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries());
|
||||||
|
CPPUNIT_ASSERT(xStorDlgLib.is());
|
||||||
|
uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xDlgLib.is());
|
||||||
|
xBasLib->loadLibrary(sStandard);
|
||||||
|
xDlgLib->loadLibrary(sStandard);
|
||||||
|
CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard));
|
||||||
|
CPPUNIT_ASSERT(xDlgLib->isLibraryLoaded(sStandard));
|
||||||
|
|
||||||
|
Any a;
|
||||||
|
uno::Reference< container::XNameContainer > xI;
|
||||||
|
|
||||||
|
a = xBasLib->getByName(sStandard);
|
||||||
|
a >>= xI;
|
||||||
|
CPPUNIT_ASSERT(xI.is());
|
||||||
|
xI->removeByName("Raralix");
|
||||||
|
|
||||||
|
a = xDlgLib->getByName(sStandard);
|
||||||
|
a >>= xI;
|
||||||
|
CPPUNIT_ASSERT(xI.is());
|
||||||
|
xI->removeByName("Dialog1");
|
||||||
|
|
||||||
|
// uno::Reference< util::XModifiable > xDlgMod(xDlgLib, UNO_QUERY_THROW);
|
||||||
|
// CPPUNIT_ASSERT(xDlgMod.is());
|
||||||
|
// xDlgMod->setModified(sal_True);
|
||||||
|
|
||||||
|
// uno::Reference< util::XModifiable > xScrMod(xDocScr, UNO_QUERY_THROW);
|
||||||
|
// CPPUNIT_ASSERT(xScrMod.is());
|
||||||
|
// xScrMod->setModified(sal_True);
|
||||||
|
|
||||||
|
// uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW);
|
||||||
|
// CPPUNIT_ASSERT(xDocMod.is());
|
||||||
|
// std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
|
||||||
|
// xDocMod->setModified(sal_True);
|
||||||
|
// std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
|
||||||
|
// CPPUNIT_ASSERT(xDocMod->isModified());
|
||||||
|
|
||||||
|
// now save; the code path to exercise in this test is the "store to same location"
|
||||||
|
// do *not* change to store(As|To|URL)!
|
||||||
|
xDocStorable->store();
|
||||||
|
|
||||||
|
// close
|
||||||
|
uno::Reference< util::XCloseable > xDocCloseable(xComponent, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xDocCloseable.is());
|
||||||
|
xDocCloseable->close(false);
|
||||||
|
|
||||||
|
// All our uno::References are (should?) be invalid now -> let them go out of scope
|
||||||
|
}
|
||||||
|
{
|
||||||
|
uno::Sequence<uno::Any> args(1);
|
||||||
|
args[0] <<= aFileName;
|
||||||
|
Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments("com.sun.star.packages.Package", args), UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xHNA.is());
|
||||||
|
CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Basic/Standard"));
|
||||||
|
CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Dialogs/Standard"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
|
||||||
|
|
||||||
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
135
dbaccess/qa/extras/nolib-save.cxx
Normal file
135
dbaccess/qa/extras/nolib-save.cxx
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/* -*- 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 <sal/config.h>
|
||||||
|
#include <test/bootstrapfixture.hxx>
|
||||||
|
#include <test/unoapi_test.hxx>
|
||||||
|
#include <rtl/strbuf.hxx>
|
||||||
|
#include <osl/file.hxx>
|
||||||
|
#include <com/sun/star/frame/Desktop.hpp>
|
||||||
|
#include <com/sun/star/lang/XComponent.hpp>
|
||||||
|
#include <com/sun/star/frame/XStorable.hpp>
|
||||||
|
#include <com/sun/star/document/XEmbeddedScripts.hpp>
|
||||||
|
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
|
||||||
|
#include <com/sun/star/script/XLibraryContainer.hpp>
|
||||||
|
#include <com/sun/star/util/XModifiable.hpp>
|
||||||
|
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
|
||||||
|
#include <com/sun/star/io/XStream.hpp>
|
||||||
|
#include <com/sun/star/io/XInputStream.hpp>
|
||||||
|
|
||||||
|
#include <sfx2/app.hxx>
|
||||||
|
#include <sfx2/docfilt.hxx>
|
||||||
|
#include <sfx2/docfile.hxx>
|
||||||
|
#include <sfx2/objsh.hxx>
|
||||||
|
#include <sfx2/sfxmodelfactory.hxx>
|
||||||
|
#include <svl/intitem.hxx>
|
||||||
|
#include <comphelper/processfactory.hxx>
|
||||||
|
|
||||||
|
#include <basic/sbxdef.hxx>
|
||||||
|
|
||||||
|
using namespace ::com::sun::star;
|
||||||
|
using namespace ::com::sun::star::uno;
|
||||||
|
|
||||||
|
|
||||||
|
class DialogSaveTest : public UnoApiTest
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DialogSaveTest();
|
||||||
|
|
||||||
|
void test();
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE(DialogSaveTest);
|
||||||
|
// Should we disable this test on MOX and WNT?
|
||||||
|
// #if !defined(MACOSX) && !defined(WNT)
|
||||||
|
CPPUNIT_TEST(test);
|
||||||
|
// #endif
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
DialogSaveTest::DialogSaveTest()
|
||||||
|
: UnoApiTest("/dbaccess/qa/extras/testdocuments")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogSaveTest::test()
|
||||||
|
{
|
||||||
|
// UnoApiTest::setUp (via InitVCL) puts each test under a locked SolarMutex,
|
||||||
|
// but at least the below xDocCloseable->close call could lead to a deadlock
|
||||||
|
// then, and it looks like none of the code here requires the SolarMutex to
|
||||||
|
// be locked anyway:
|
||||||
|
SolarMutexReleaser rel;
|
||||||
|
|
||||||
|
const OUString sStandard("Standard");
|
||||||
|
const OUString aFileName(getURLFromWorkdir("CppunitTest/testNolibSave.odb"));
|
||||||
|
{
|
||||||
|
uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName);
|
||||||
|
CPPUNIT_ASSERT(xComponent.is());
|
||||||
|
uno::Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xDocStorable.is());
|
||||||
|
uno::Reference< document::XEmbeddedScripts > xDocScr(xComponent, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xDocScr.is());
|
||||||
|
uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries());
|
||||||
|
CPPUNIT_ASSERT(xStorBasLib.is());
|
||||||
|
uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xBasLib.is());
|
||||||
|
uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries());
|
||||||
|
CPPUNIT_ASSERT(xStorDlgLib.is());
|
||||||
|
uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xDlgLib.is());
|
||||||
|
xBasLib->loadLibrary(sStandard);
|
||||||
|
xDlgLib->loadLibrary(sStandard);
|
||||||
|
CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard));
|
||||||
|
CPPUNIT_ASSERT(xDlgLib->isLibraryLoaded(sStandard));
|
||||||
|
|
||||||
|
xBasLib->removeLibrary(sStandard);
|
||||||
|
xDlgLib->removeLibrary(sStandard);
|
||||||
|
|
||||||
|
// uno::Reference< util::XModifiable > xDlgMod(xDlgLib, UNO_QUERY_THROW);
|
||||||
|
// CPPUNIT_ASSERT(xDlgMod.is());
|
||||||
|
// xDlgMod->setModified(sal_True);
|
||||||
|
|
||||||
|
// uno::Reference< util::XModifiable > xScrMod(xDocScr, UNO_QUERY_THROW);
|
||||||
|
// CPPUNIT_ASSERT(xScrMod.is());
|
||||||
|
// xScrMod->setModified(sal_True);
|
||||||
|
|
||||||
|
// uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW);
|
||||||
|
// CPPUNIT_ASSERT(xDocMod.is());
|
||||||
|
// std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
|
||||||
|
// xDocMod->setModified(sal_True);
|
||||||
|
// std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
|
||||||
|
// CPPUNIT_ASSERT(xDocMod->isModified());
|
||||||
|
|
||||||
|
// now save; the code path to exercise in this test is the "store to same location"
|
||||||
|
// do *not* change to store(As|To|URL)!
|
||||||
|
xDocStorable->store();
|
||||||
|
|
||||||
|
// close
|
||||||
|
uno::Reference< util::XCloseable > xDocCloseable(xComponent, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xDocCloseable.is());
|
||||||
|
xDocCloseable->close(false);
|
||||||
|
|
||||||
|
// All our uno::References are (should?) be invalid now -> let them go out of scope
|
||||||
|
}
|
||||||
|
{
|
||||||
|
uno::Sequence<uno::Any> args(1);
|
||||||
|
args[0] <<= aFileName;
|
||||||
|
Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments("com.sun.star.packages.Package", args), UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xHNA.is());
|
||||||
|
CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Basic/Standard"));
|
||||||
|
CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Dialogs/Standard"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
|
||||||
|
|
||||||
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
Reference in New Issue
Block a user