[Libreoffice-commits] core.git: 2 commits - chart2/qa dbaccess/CppunitTest_dbaccess_dialog_save.mk dbaccess/Module_dbaccess.mk dbaccess/qa unotest/source

Lionel Elie Mamane lionel at mamane.lu
Fri Sep 27 02:38:42 PDT 2013


 chart2/qa/extras/charttest.hxx                      |    3 
 dbaccess/CppunitTest_dbaccess_dialog_save.mk        |  117 ++++++++++++++++
 dbaccess/Module_dbaccess.mk                         |    5 
 dbaccess/qa/extras/dialog-save.cxx                  |  145 ++++++++++++++++++++
 dbaccess/qa/extras/testdocuments/testDialogSave.odb |binary
 unotest/source/cpp/bootstrapfixturebase.cxx         |    4 
 6 files changed, 268 insertions(+), 6 deletions(-)

New commits:
commit 70417fc19fb228ed6862f3e37ed837d0ec312b40
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Sep 27 11:35:23 2013 +0200

    janitorial: simplify code
    
    xStorable is obtained from a XComponent,
    so use the original instead of requerying
    a XComponent from the XStorable.
    
    Change-Id: Iec5ca6ddcf3eedd193ec04129ba9aa1d13af1d0e

diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 8fe76e2..8934ddb 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -66,8 +66,7 @@ void ChartTest::reload(const OUString& rFilterName)
     utl::TempFile aTempFile;
     aTempFile.EnableKillingFile();
     xStorable->storeToURL(aTempFile.GetURL(), aArgs);
-    uno::Reference<lang::XComponent> xComponent(xStorable, uno::UNO_QUERY);
-    xComponent->dispose();
+    mxComponent->dispose();
     mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.sheet.SpreadsheetDocument");
     std::cout << aTempFile.GetURL();
     CPPUNIT_ASSERT(mxComponent.is());
commit 92c53b9d94a5d51e2d507b7eeecfcf2b023cdd4b
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sat Aug 3 10:49:41 2013 +0200

    unittest for fdo#67685
    
    Change-Id: I44500717109a026d7c71e6494daacbea1f224263

diff --git a/dbaccess/CppunitTest_dbaccess_dialog_save.mk b/dbaccess/CppunitTest_dbaccess_dialog_save.mk
new file mode 100644
index 0000000..c24e14e
--- /dev/null
+++ b/dbaccess/CppunitTest_dbaccess_dialog_save.mk
@@ -0,0 +1,117 @@
+# -*- 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_dialog_save))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,dbaccess_dialog_save, \
+    dbaccess/qa/extras/dialog-save \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,dbaccess_dialog_save, \
+    avmedia \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    dba \
+    dbu \
+    sdbt \
+    drawinglayer \
+    editeng \
+    fileacc \
+    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_dialog_save,\
+    -I$(SRCDIR)/sc/source/ui/inc \
+    -I$(SRCDIR)/sc/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,dbaccess_dialog_save,\
+    offapi \
+    oovbaapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,dbaccess_dialog_save))
+
+$(eval $(call gb_CppunitTest_use_components,dbaccess_dialog_save,\
+    basic/util/sb \
+    comphelper/util/comphelp \
+    configmgr/source/configmgr \
+    dbaccess/util/dba \
+    dbaccess/util/dbu \
+    dbaccess/util/sdbt \
+    dbaccess/source/filter/xml/dbaxml \
+    fileaccess/source/fileacc \
+    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 \
+    sax/source/fastparser/fastsax \
+    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_dialog_save))
+
+$(eval $(call gb_CppunitTest_use_filter_configuration,dbaccess_dialog_save))
+
+$(eval $(call gb_CppunitTest_use_unittest_configuration,dbaccess_dialog_save))
+
+$(call gb_CppunitTest_get_target,dbaccess_dialog_save) : $(WORKDIR)/CppunitTest/testDialogSave.odb
+$(WORKDIR)/CppunitTest/testDialogSave.odb : $(SRCDIR)/dbaccess/qa/extras/testdocuments/testDialogSave.odb
+	mkdir -p $(dir $@)
+	$(call gb_Deliver_deliver,$<,$@)
+.PHONY: $(WORKDIR)/CppunitTest/testDialogSave.odb
+
+# vim: set noet sw=4 ts=4:
diff --git a/dbaccess/Module_dbaccess.mk b/dbaccess/Module_dbaccess.mk
index f6378a0..eb1dbbc 100644
--- a/dbaccess/Module_dbaccess.mk
+++ b/dbaccess/Module_dbaccess.mk
@@ -37,6 +37,11 @@ $(eval $(call gb_Module_add_check_targets,dbaccess,\
 ))
 endif
 
+$(eval $(call gb_Module_add_check_targets,dbaccess,\
+	CppunitTest_dbaccess_dialog_save \
+))
+
+
 # disable test because it still fails in some situations
 #    CppunitTest_dbaccess_macros_test \
 #
diff --git a/dbaccess/qa/extras/dialog-save.cxx b/dbaccess/qa/extras/dialog-save.cxx
new file mode 100644
index 0000000..38d5c61
--- /dev/null
+++ b/dbaccess/qa/extras/dialog-save.cxx
@@ -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();
+
+    virtual void setUp();
+    virtual void tearDown();
+
+    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")
+{
+}
+
+// TODO: use temporary copy; see example in chart2/qa/extras/charttest.hxx:65 (function reload)
+
+void DialogSaveTest::test()
+{
+    OUString aFileName;
+    aFileName = "file://" + getPathFromWorkdir("/CppunitTest/testDialogSave.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("Standard");
+        CPPUNIT_ASSERT(xBasLib->isLibraryLoaded("Standard"));
+        // the whole point of this test is to test the "save" operation
+        // when the Basic library is loaded, but not the Dialog library
+        CPPUNIT_ASSERT(!xDlgLib->isLibraryLoaded("Standard"));
+
+        // make some change to enable a save
+        // uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSuppl(xComponent, UNO_QUERY_THROW);
+        // CPPUNIT_ASSERT(xDocPropSuppl.is());
+        // uno::Reference< document::XDocumentPropertiesSupplier > xDocProps(xDocPropSuppl->getDocumentProperties());
+        // CPPUNIT_ASSERT(xDocProps.is());
+        // xDocProps.setTitle(xDocProps.getTitle() + " suffix");
+        uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW);
+        CPPUNIT_ASSERT(xDocMod.is());
+        xDocMod->setModified(sal_True);
+
+        // 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());
+        Reference< beans::XPropertySet > xPS(xHNA->getByHierarchicalName("Dialogs/Standard/Dialog1.xml"), UNO_QUERY_THROW);
+        CPPUNIT_ASSERT(xPS.is());
+        sal_Int64 nSize = 0;
+        CPPUNIT_ASSERT(xPS->getPropertyValue("Size") >>= nSize);
+        CPPUNIT_ASSERT(nSize != 0);
+    }
+}
+
+void DialogSaveTest::setUp()
+{
+    test::BootstrapFixture::setUp();
+
+    // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
+    // which is a private symbol to us, gets called
+    mxDesktop = com::sun::star::frame::Desktop::create( comphelper::getComponentContext(getMultiServiceFactory()) );
+    CPPUNIT_ASSERT(mxDesktop.is());
+}
+
+void DialogSaveTest::tearDown()
+{
+    test::BootstrapFixture::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/qa/extras/testdocuments/testDialogSave.odb b/dbaccess/qa/extras/testdocuments/testDialogSave.odb
new file mode 100644
index 0000000..d725312
Binary files /dev/null and b/dbaccess/qa/extras/testdocuments/testDialogSave.odb differ
diff --git a/unotest/source/cpp/bootstrapfixturebase.cxx b/unotest/source/cpp/bootstrapfixturebase.cxx
index 31a5d44..98f76f4 100644
--- a/unotest/source/cpp/bootstrapfixturebase.cxx
+++ b/unotest/source/cpp/bootstrapfixturebase.cxx
@@ -76,9 +76,6 @@ OUString test::BootstrapFixtureBase::getPathFromSrc( const char *pPath )
     return m_aSrcRootPath + OUString::createFromAscii( pPath );
 }
 
-// just temporarily ifdef this out as it's currently unused (callcatcher)
-// if you start using it on linux just remove the ifdef
-#ifndef LINUX
 OUString test::BootstrapFixtureBase::getURLFromWorkdir( const char *pPath )
 {
     return m_aWorkdirRootURL + OUString::createFromAscii( pPath );
@@ -89,7 +86,6 @@ OUString test::BootstrapFixtureBase::getPathFromWorkdir( const char *pPath )
     return m_aWorkdirRootPath + OUString::createFromAscii( pPath );
 
 }
-#endif
 
 void test::BootstrapFixtureBase::setUp()
 {


More information about the Libreoffice-commits mailing list