[Libreoffice-commits] core.git: embeddedobj/CppunitTest_embeddedobj_general.mk embeddedobj/Module_embeddedobj.mk embeddedobj/qa

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 14 17:40:03 UTC 2019


 embeddedobj/CppunitTest_embeddedobj_general.mk     |   44 ++++++++++
 embeddedobj/Module_embeddedobj.mk                  |    6 +
 embeddedobj/qa/cppunit/data/insert-file-config.doc |binary
 embeddedobj/qa/cppunit/general.cxx                 |   90 +++++++++++++++++++++
 4 files changed, 140 insertions(+)

New commits:
commit 85a7bc13fed5020441d772816d73a932f67ad377
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Aug 14 15:09:47 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Aug 14 19:38:59 2019 +0200

    embeddedobj: add initial CppunitTest_embeddedobj_general
    
    Fails with commit 88afec70112c95a016e92e26c1d06d7dd002e4e8 (embeddedobj:
    respect config for Insert -> Object -> OLE Object -> from file,
    2019-08-14) reverted.
    
    Change-Id: I64f81642260f6eab5a86219d94553f09b67b3555
    Reviewed-on: https://gerrit.libreoffice.org/77461
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/embeddedobj/CppunitTest_embeddedobj_general.mk b/embeddedobj/CppunitTest_embeddedobj_general.mk
new file mode 100644
index 000000000000..32fea16fb2b2
--- /dev/null
+++ b/embeddedobj/CppunitTest_embeddedobj_general.mk
@@ -0,0 +1,44 @@
+# -*- 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,embeddedobj_general))
+
+$(eval $(call gb_CppunitTest_use_externals,embeddedobj_general,\
+	boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,embeddedobj_general, \
+    embeddedobj/qa/cppunit/general \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,embeddedobj_general, \
+    comphelper \
+    cppu \
+    embobj \
+    sal \
+    test \
+    unotest \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,embeddedobj_general))
+
+$(eval $(call gb_CppunitTest_use_ure,embeddedobj_general))
+$(eval $(call gb_CppunitTest_use_vcl,embeddedobj_general))
+
+$(eval $(call gb_CppunitTest_use_rdb,embeddedobj_general,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,embeddedobj_general,\
+	officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,embeddedobj_general))
+
+# vim: set noet sw=4 ts=4:
diff --git a/embeddedobj/Module_embeddedobj.mk b/embeddedobj/Module_embeddedobj.mk
index f344565192f6..394112a13b7d 100644
--- a/embeddedobj/Module_embeddedobj.mk
+++ b/embeddedobj/Module_embeddedobj.mk
@@ -15,4 +15,10 @@ $(eval $(call gb_Module_add_targets,embeddedobj,\
 	Library_emboleobj \
 ))
 
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Module_add_slowcheck_targets,embeddedobj,\
+    CppunitTest_embeddedobj_general \
+))
+endif
+
 # vim: set noet sw=4 ts=4:
diff --git a/embeddedobj/qa/cppunit/data/insert-file-config.doc b/embeddedobj/qa/cppunit/data/insert-file-config.doc
new file mode 100644
index 000000000000..182a70c34265
Binary files /dev/null and b/embeddedobj/qa/cppunit/data/insert-file-config.doc differ
diff --git a/embeddedobj/qa/cppunit/general.cxx b/embeddedobj/qa/cppunit/general.cxx
new file mode 100644
index 000000000000..43b8dd9f4c1b
--- /dev/null
+++ b/embeddedobj/qa/cppunit/general.cxx
@@ -0,0 +1,90 @@
+/* -*- 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 <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+
+#include <comphelper/embeddedobjectcontainer.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <comphelper/scopeguard.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <officecfg/Office/Common.hxx>
+
+using namespace ::com::sun::star;
+
+/// embeddedobj general tests.
+class EmbeddedobjGeneralTest : public test::BootstrapFixture, public unotest::MacrosTest
+{
+private:
+    uno::Reference<uno::XComponentContext> mxComponentContext;
+    uno::Reference<lang::XComponent> mxComponent;
+
+public:
+    void setUp() override;
+    void tearDown() override;
+    uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+};
+
+void EmbeddedobjGeneralTest::setUp()
+{
+    test::BootstrapFixture::setUp();
+
+    mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
+    mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void EmbeddedobjGeneralTest::tearDown()
+{
+    if (mxComponent.is())
+        mxComponent->dispose();
+
+    test::BootstrapFixture::tearDown();
+}
+
+CPPUNIT_TEST_FIXTURE(EmbeddedobjGeneralTest, testInsertFileConfig)
+{
+    // Explicitly disable Word->Writer mapping for this test.
+    std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+        comphelper::ConfigurationChanges::create());
+    officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::set(false, pBatch);
+    pBatch->commit();
+    comphelper::ScopeGuard g([]() {
+        std::shared_ptr<comphelper::ConfigurationChanges> pBatchReset(
+            comphelper::ConfigurationChanges::create());
+        officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::set(true,
+                                                                                   pBatchReset);
+        pBatchReset->commit();
+    });
+    getComponent().set(
+        loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"));
+
+    // Insert a file as an embedded object.
+    uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
+    comphelper::EmbeddedObjectContainer aContainer(xStorage);
+    OUString aFileName
+        = m_directories.getURLFromSrc("embeddedobj/qa/cppunit/data/insert-file-config.doc");
+    uno::Sequence<beans::PropertyValue> aMedium{ comphelper::makePropertyValue("URL", aFileName) };
+    OUString aName("Object 1");
+    uno::Reference<embed::XEmbeddedObject> xObject
+        = aContainer.InsertEmbeddedObject(aMedium, aName);
+
+    // Make sure that the insertion fails:
+    // 1) the user explicitly requested that the data is not loaded into Writer
+    // 2) this is non-Windows, so OLE embedding is not an option
+    // so silently still loading the data into Writer would be bad.
+    CPPUNIT_ASSERT(!xObject.is());
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list