a11y: Simplify OCommonAccessibleComponent::getAccessibleIndexInParent
[LibreOffice.git] / dbaccess / qa / extras / dialog-save.cxx
blob02a706e7d7e3985a82e9ef41833e208d65a6e270
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/beans/XPropertySet.hpp>
13 #include <com/sun/star/frame/XStorable.hpp>
14 #include <com/sun/star/document/XEmbeddedScripts.hpp>
15 #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
16 #include <com/sun/star/script/XLibraryContainer.hpp>
17 #include <com/sun/star/util/XModifiable.hpp>
18 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
20 using namespace ::com::sun::star;
21 using namespace ::com::sun::star::uno;
24 class DialogSaveTest : public UnoApiTest
26 public:
27 DialogSaveTest();
29 void test();
31 CPPUNIT_TEST_SUITE(DialogSaveTest);
32 CPPUNIT_TEST(test);
33 CPPUNIT_TEST_SUITE_END();
38 DialogSaveTest::DialogSaveTest()
39 : UnoApiTest(u"/dbaccess/qa/extras/testdocuments"_ustr)
43 void DialogSaveTest::test()
45 createTempCopy(u"testDialogSave.odb");
47 loadFromURL(maTempFile.GetURL());
48 uno::Reference< frame::XStorable > xDocStorable(mxComponent, UNO_QUERY_THROW);
49 uno::Reference< document::XEmbeddedScripts > xDocScr(mxComponent, UNO_QUERY_THROW);
50 uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries());
51 CPPUNIT_ASSERT(xStorBasLib.is());
52 uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW);
53 uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries());
54 CPPUNIT_ASSERT(xStorDlgLib.is());
55 uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW);
56 static constexpr OUString sStandard(u"Standard"_ustr);
57 xBasLib->loadLibrary(sStandard);
58 CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard));
59 // the whole point of this test is to test the "save" operation
60 // when the Basic library is loaded, but not the Dialog library
61 CPPUNIT_ASSERT(!xDlgLib->isLibraryLoaded(sStandard));
63 // make some change to enable a save
64 // uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSuppl(mxComponent, UNO_QUERY_THROW);
65 // uno::Reference< document::XDocumentPropertiesSupplier > xDocProps(xDocPropSuppl->getDocumentProperties());
66 // CPPUNIT_ASSERT(xDocProps.is());
67 // xDocProps.setTitle(xDocProps.getTitle() + " suffix");
68 uno::Reference< util::XModifiable > xDocMod(mxComponent, UNO_QUERY_THROW);
69 xDocMod->setModified(true);
71 // now save; the code path to exercise in this test is the "store to same location"
72 // do *not* change to store(As|To|URL)!
73 xDocStorable->store();
75 // All our uno::References are (should?) be invalid now -> let them go out of scope
78 uno::Sequence<uno::Any> args{ uno::Any(maTempFile.GetURL()) };
79 Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments(u"com.sun.star.packages.Package"_ustr, args), UNO_QUERY_THROW);
80 Reference< beans::XPropertySet > xPS(xHNA->getByHierarchicalName(u"Dialogs/Standard/Dialog1.xml"_ustr), UNO_QUERY_THROW);
81 sal_Int64 nSize = 0;
82 CPPUNIT_ASSERT(xPS->getPropertyValue(u"Size"_ustr) >>= nSize);
83 CPPUNIT_ASSERT(nSize != 0);
87 CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
89 CPPUNIT_PLUGIN_IMPLEMENT();
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */