update credits
[LibreOffice.git] / dbaccess / qa / extras / nolib-save.cxx
blob5a12fcf99c49067e7b753e6bfe4c9a96fba72aa4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/config.h>
11 #include <test/unoapi_test.hxx>
12 #include <com/sun/star/frame/XStorable.hpp>
13 #include <com/sun/star/document/XEmbeddedScripts.hpp>
14 #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
15 #include <com/sun/star/script/XLibraryContainer.hpp>
16 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
18 using namespace ::com::sun::star;
19 using namespace ::com::sun::star::uno;
22 class DialogSaveTest : public UnoApiTest
24 public:
25 DialogSaveTest();
27 void test();
29 CPPUNIT_TEST_SUITE(DialogSaveTest);
30 // Should we disable this test on MOX and WNT?
31 // #if !defined(MACOSX) && !defined(_WIN32)
32 CPPUNIT_TEST(test);
33 // #endif
34 CPPUNIT_TEST_SUITE_END();
39 DialogSaveTest::DialogSaveTest()
40 : UnoApiTest(u"/dbaccess/qa/extras/testdocuments"_ustr)
44 void DialogSaveTest::test()
46 const OUString aFileName(m_directories.getURLFromWorkdir(u"CppunitTest/testNolibSave.odb"));
48 mxComponent = loadFromDesktop(aFileName);
49 uno::Reference< frame::XStorable > xDocStorable(mxComponent, UNO_QUERY_THROW);
50 uno::Reference< document::XEmbeddedScripts > xDocScr(mxComponent, UNO_QUERY_THROW);
51 uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries());
52 CPPUNIT_ASSERT(xStorBasLib.is());
53 uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW);
54 uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries());
55 CPPUNIT_ASSERT(xStorDlgLib.is());
56 uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW);
57 static constexpr OUString sStandard(u"Standard"_ustr);
58 xBasLib->loadLibrary(sStandard);
59 xDlgLib->loadLibrary(sStandard);
60 CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard));
61 CPPUNIT_ASSERT(xDlgLib->isLibraryLoaded(sStandard));
63 xBasLib->removeLibrary(sStandard);
64 xDlgLib->removeLibrary(sStandard);
66 // uno::Reference< util::XModifiable > xDlgMod(xDlgLib, UNO_QUERY_THROW);
67 // xDlgMod->setModified(sal_True);
69 // uno::Reference< util::XModifiable > xScrMod(xDocScr, UNO_QUERY_THROW);
70 // xScrMod->setModified(sal_True);
72 // uno::Reference< util::XModifiable > xDocMod(mxComponent, UNO_QUERY_THROW);
73 // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
74 // xDocMod->setModified(sal_True);
75 // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
76 // CPPUNIT_ASSERT(xDocMod->isModified());
78 // now save; the code path to exercise in this test is the "store to same location"
79 // do *not* change to store(As|To|URL)!
80 xDocStorable->store();
82 // All our uno::References are (should?) be invalid now -> let them go out of scope
85 uno::Sequence<uno::Any> args{ uno::Any(aFileName) };
86 Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments(u"com.sun.star.packages.Package"_ustr, args), UNO_QUERY_THROW);
87 CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName(u"Basic/Standard"_ustr));
88 CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName(u"Dialogs/Standard"_ustr));
92 CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
94 CPPUNIT_PLUGIN_IMPLEMENT();
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */