GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / dbaccess / qa / extras / dialog-save.cxx
blobaaa7593a890ef98959c2e548f29f24f88ee78ebc
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/bootstrapfixture.hxx>
12 #include <test/unoapi_test.hxx>
13 #include <rtl/strbuf.hxx>
14 #include <osl/file.hxx>
15 #include <com/sun/star/frame/Desktop.hpp>
16 #include <com/sun/star/lang/XComponent.hpp>
17 #include <com/sun/star/frame/XStorable.hpp>
18 #include <com/sun/star/document/XEmbeddedScripts.hpp>
19 #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
20 #include <com/sun/star/script/XLibraryContainer.hpp>
21 #include <com/sun/star/util/XModifiable.hpp>
22 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
23 #include <com/sun/star/io/XStream.hpp>
24 #include <com/sun/star/io/XInputStream.hpp>
26 #include <sfx2/app.hxx>
27 #include <sfx2/docfilt.hxx>
28 #include <sfx2/docfile.hxx>
29 #include <sfx2/objsh.hxx>
30 #include <sfx2/sfxmodelfactory.hxx>
31 #include <svl/intitem.hxx>
32 #include <comphelper/processfactory.hxx>
34 #include <basic/sbxdef.hxx>
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::uno;
40 class DialogSaveTest : public UnoApiTest
42 public:
43 DialogSaveTest();
45 void test();
47 CPPUNIT_TEST_SUITE(DialogSaveTest);
48 // Should we disable this test on MOX and WNT?
49 // #if !defined(MACOSX) && !defined(WNT)
50 CPPUNIT_TEST(test);
51 // #endif
52 CPPUNIT_TEST_SUITE_END();
57 DialogSaveTest::DialogSaveTest()
58 : UnoApiTest("/dbaccess/qa/extras/testdocuments")
62 void DialogSaveTest::test()
64 OUString aFileName;
65 aFileName = getURLFromWorkdir("CppunitTest/testDialogSave.odb");
67 uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName);
68 CPPUNIT_ASSERT(xComponent.is());
69 uno::Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW);
70 CPPUNIT_ASSERT(xDocStorable.is());
71 uno::Reference< document::XEmbeddedScripts > xDocScr(xComponent, UNO_QUERY_THROW);
72 CPPUNIT_ASSERT(xDocScr.is());
73 uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries());
74 CPPUNIT_ASSERT(xStorBasLib.is());
75 uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW);
76 CPPUNIT_ASSERT(xBasLib.is());
77 uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries());
78 CPPUNIT_ASSERT(xStorDlgLib.is());
79 uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW);
80 CPPUNIT_ASSERT(xDlgLib.is());
81 xBasLib->loadLibrary("Standard");
82 CPPUNIT_ASSERT(xBasLib->isLibraryLoaded("Standard"));
83 // the whole point of this test is to test the "save" operation
84 // when the Basic library is loaded, but not the Dialog library
85 CPPUNIT_ASSERT(!xDlgLib->isLibraryLoaded("Standard"));
87 // make some change to enable a save
88 // uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSuppl(xComponent, UNO_QUERY_THROW);
89 // CPPUNIT_ASSERT(xDocPropSuppl.is());
90 // uno::Reference< document::XDocumentPropertiesSupplier > xDocProps(xDocPropSuppl->getDocumentProperties());
91 // CPPUNIT_ASSERT(xDocProps.is());
92 // xDocProps.setTitle(xDocProps.getTitle() + " suffix");
93 uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW);
94 CPPUNIT_ASSERT(xDocMod.is());
95 xDocMod->setModified(sal_True);
97 // now save; the code path to exercise in this test is the "store to same location"
98 // do *not* change to store(As|To|URL)!
99 xDocStorable->store();
101 // close
102 uno::Reference< util::XCloseable > xDocCloseable(xComponent, UNO_QUERY_THROW);
103 CPPUNIT_ASSERT(xDocCloseable.is());
104 xDocCloseable->close(false);
106 // All our uno::References are (should?) be invalid now -> let them go out of scope
109 uno::Sequence<uno::Any> args(1);
110 args[0] <<= aFileName;
111 Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments("com.sun.star.packages.Package", args), UNO_QUERY_THROW);
112 CPPUNIT_ASSERT(xHNA.is());
113 Reference< beans::XPropertySet > xPS(xHNA->getByHierarchicalName("Dialogs/Standard/Dialog1.xml"), UNO_QUERY_THROW);
114 CPPUNIT_ASSERT(xPS.is());
115 sal_Int64 nSize = 0;
116 CPPUNIT_ASSERT(xPS->getPropertyValue("Size") >>= nSize);
117 CPPUNIT_ASSERT(nSize != 0);
121 CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
123 CPPUNIT_PLUGIN_IMPLEMENT();
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */