From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- dbaccess/qa/extras/empty-stdlib-save.cxx | 114 +++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 dbaccess/qa/extras/empty-stdlib-save.cxx (limited to 'dbaccess/qa/extras/empty-stdlib-save.cxx') diff --git a/dbaccess/qa/extras/empty-stdlib-save.cxx b/dbaccess/qa/extras/empty-stdlib-save.cxx new file mode 100644 index 000000000..440fc19d4 --- /dev/null +++ b/dbaccess/qa/extras/empty-stdlib-save.cxx @@ -0,0 +1,114 @@ +/* -*- 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 +#include +#include +#include +#include + +#include + +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(_WIN32) + CPPUNIT_TEST(test); +// #endif + CPPUNIT_TEST_SUITE_END(); + +}; + + +DialogSaveTest::DialogSaveTest() + : UnoApiTest("/dbaccess/qa/extras/testdocuments") +{ +} + +void DialogSaveTest::test() +{ + const OUString aFileName(m_directories.getURLFromWorkdir(u"CppunitTest/testEmptyStdlibSave.odb")); + { + uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName); + uno::Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW); + uno::Reference< document::XEmbeddedScripts > xDocScr(xComponent, UNO_QUERY_THROW); + uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries()); + CPPUNIT_ASSERT(xStorBasLib.is()); + uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW); + uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries()); + CPPUNIT_ASSERT(xStorDlgLib.is()); + uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW); + static const OUStringLiteral sStandard(u"Standard"); + 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); + // xDlgMod->setModified(sal_True); + + // uno::Reference< util::XModifiable > xScrMod(xDocScr, UNO_QUERY_THROW); + // xScrMod->setModified(sal_True); + + // uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW); + // std::cerr << "** Modified: " << static_cast(xDocMod->isModified()) << std::endl; + // xDocMod->setModified(sal_True); + // std::cerr << "** Modified: " << static_cast(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); + xDocCloseable->close(false); + + // All our uno::References are (should?) be invalid now -> let them go out of scope + } + { + uno::Sequence args{ uno::Any(aFileName) }; + Reference xHNA(getMultiServiceFactory()->createInstanceWithArguments("com.sun.star.packages.Package", args), UNO_QUERY_THROW); + 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: */ -- cgit v1.2.3