[Libreoffice-commits] core.git: starmath/CppunitTest_starmath_import.mk starmath/inc starmath/Library_sm.mk starmath/Module_starmath.mk starmath/qa

Takeshi Abe tabe at fixedpoint.jp
Tue Jan 13 04:12:38 PST 2015


 starmath/CppunitTest_starmath_import.mk |   88 ++++++++++++++++++++++++++++++
 starmath/Library_sm.mk                  |    4 +
 starmath/Module_starmath.mk             |    1 
 starmath/inc/document.hxx               |    3 -
 starmath/inc/smdll.hxx                  |    4 +
 starmath/inc/smdllapi.hxx               |   23 ++++++++
 starmath/qa/extras/data/simple.mml      |   13 ++++
 starmath/qa/extras/mmlimport-test.cxx   |   92 ++++++++++++++++++++++++++++++++
 8 files changed, 226 insertions(+), 2 deletions(-)

New commits:
commit 9b87116fa4c5873fa719468f775589edd6c8613c
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Mon Jan 12 00:45:17 2015 +0900

    fdo#70185: starmath: unit test writing
    
    This adds a unit test of importing a simple MathML file.
    New smdllapi.hxx defines a macro SM_DLLPUBLIC to turn on
    visibility of symbols required from a CppunitTest.
    
    Change-Id: I4f72d7d8f2766751580e5bde7dac4870e8dad62a
    Reviewed-on: https://gerrit.libreoffice.org/13861
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/starmath/CppunitTest_starmath_import.mk b/starmath/CppunitTest_starmath_import.mk
new file mode 100644
index 0000000..17a9f71
--- /dev/null
+++ b/starmath/CppunitTest_starmath_import.mk
@@ -0,0 +1,88 @@
+# -*- 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,starmath_import))
+
+$(eval $(call gb_CppunitTest_set_include,starmath_import,\
+    $$(INCLUDE) \
+    -I$(SRCDIR)/starmath/inc \
+))
+
+$(eval $(call gb_CppunitTest_use_external,starmath_import,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_api,starmath_import,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,starmath_import,\
+    starmath/qa/extras/mmlimport-test \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,starmath_import,\
+    comphelper \
+    cppu \
+    cppuhelper \
+    editeng \
+    i18nlangtag \
+    i18nutil \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sfx \
+    sm \
+    smd \
+    sot \
+    svl \
+    svt \
+    svx \
+    svxcore \
+    test \
+    tk \
+    tl \
+    unotest \
+    unoxml \
+    utl \
+    vcl \
+    xo \
+	$(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,starmath_import))
+$(eval $(call gb_CppunitTest_use_vcl,starmath_import))
+
+$(eval $(call gb_CppunitTest_use_components,starmath_import,\
+    configmgr/source/configmgr \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sfx2/util/sfx \
+    starmath/util/sm \
+    starmath/util/smd \
+    toolkit/util/tk \
+    ucb/source/core/ucb1 \
+    ucb/source/ucp/file/ucpfile1 \
+    unotools/util/utl \
+    comphelper/util/comphelp \
+    filter/source/config/cache/filterconfig1 \
+    oox/util/oox \
+    sax/source/expatwrap/expwrap \
+    svl/source/fsstor/fsstorage \
+    svl/util/svl \
+    svx/util/svx \
+    unoxml/source/service/unoxml \
+    xmloff/util/xo \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,starmath_import))
+
+# vim: set noet sw=4 ts=4:
diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk
index fc1d1e1..7208dcb 100644
--- a/starmath/Library_sm.mk
+++ b/starmath/Library_sm.mk
@@ -21,6 +21,10 @@ $(eval $(call gb_Library_set_include,sm,\
         $$(INCLUDE) \
 ))
 
+$(eval $(call gb_Library_add_defs,sm,\
+	-DSM_DLLIMPLEMENTATION \
+))
+
 $(eval $(call gb_Library_use_external,sm,boost_headers))
 
 $(eval $(call gb_Library_use_custom_headers,sm,oox/generated))
diff --git a/starmath/Module_starmath.mk b/starmath/Module_starmath.mk
index 2830a46..1a6af4c 100644
--- a/starmath/Module_starmath.mk
+++ b/starmath/Module_starmath.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_Module_add_l10n_targets,starmath,\
 ))
 
 $(eval $(call gb_Module_add_check_targets,starmath,\
+    CppunitTest_starmath_import \
     CppunitTest_starmath_qa_cppunit \
 ))
 
diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx
index e71a2f9..792bbb6 100644
--- a/starmath/inc/document.hxx
+++ b/starmath/inc/document.hxx
@@ -37,6 +37,7 @@
 #include "format.hxx"
 #include "parse.hxx"
 #include "smmod.hxx"
+#include "smdllapi.hxx"
 
 class SmNode;
 class SfxMenuBarManager;
@@ -84,7 +85,7 @@ void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool);
 
 
 
-class SmDocShell : public SfxObjectShell, public SfxListener
+class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener
 {
     friend class SmPrinterAccess;
     friend class SmModel;
diff --git a/starmath/inc/smdll.hxx b/starmath/inc/smdll.hxx
index 034e985..3408f2f 100644
--- a/starmath/inc/smdll.hxx
+++ b/starmath/inc/smdll.hxx
@@ -19,9 +19,11 @@
 #ifndef INCLUDED_STARMATH_INC_SMDLL_HXX
 #define INCLUDED_STARMATH_INC_SMDLL_HXX
 
+#include "smdllapi.hxx"
+
 namespace SmGlobals
 {
-    void ensure();
+    SM_DLLPUBLIC void ensure();
 }
 
 #endif
diff --git a/starmath/inc/smdllapi.hxx b/starmath/inc/smdllapi.hxx
new file mode 100644
index 0000000..ad18399
--- /dev/null
+++ b/starmath/inc/smdllapi.hxx
@@ -0,0 +1,23 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_STARMATH_INC_SMDLLAPI_HXX
+#define INCLUDED_STARMATH_INC_SMDLLAPI_HXX
+
+#include <sal/types.h>
+
+#if defined(SM_DLLIMPLEMENTATION)
+#define SM_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define SM_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/qa/extras/data/simple.mml b/starmath/qa/extras/data/simple.mml
new file mode 100644
index 0000000..822d1a7
--- /dev/null
+++ b/starmath/qa/extras/data/simple.mml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<math xmlns="http://www.w3.org/1998/Math/MathML">
+  <msup>
+    <mfenced>
+      <mrow>
+        <mi>a</mi>
+        <mo>+</mo>
+        <mi>b</mi>
+      </mrow>
+    </mfenced>
+    <mn>2</mn>
+  </msup>
+</math>
diff --git a/starmath/qa/extras/mmlimport-test.cxx b/starmath/qa/extras/mmlimport-test.cxx
new file mode 100644
index 0000000..2fbeda7
--- /dev/null
+++ b/starmath/qa/extras/mmlimport-test.cxx
@@ -0,0 +1,92 @@
+/* -*- 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 <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+
+#include <document.hxx>
+#include <smdll.hxx>
+
+namespace {
+
+using namespace ::com::sun::star;
+
+typedef tools::SvRef<SmDocShell> SmDocShellRef;
+
+class Test : public test::BootstrapFixture
+{
+public:
+    virtual void setUp() SAL_OVERRIDE;
+    virtual void tearDown() SAL_OVERRIDE;
+
+    void testSimple();
+
+    CPPUNIT_TEST_SUITE(Test);
+    CPPUNIT_TEST(testSimple);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    void loadURL(const OUString &rURL)
+    {
+        // Cf.
+        // filter/source/config/fragments/filters/MathML_XML__Math_.xcu
+        SfxFilter* pFilter = new SfxFilter(MATHML_XML,
+                                           OUString(),
+                                           SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_TEMPLATE,
+                                           SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS,
+                                           "MathML 1.01",
+                                           0,
+                                           OUString(),
+                                           OUString(),
+                                           "private:factory/smath*");
+        pFilter->SetVersion(SOFFICE_FILEFORMAT_60);
+
+        mxDocShell = new SmDocShell(SFXMODEL_STANDARD |
+                                    SFXMODEL_DISABLE_EMBEDDED_SCRIPTS |
+                                    SFXMODEL_DISABLE_DOCUMENT_RECOVERY);
+
+        SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
+        pSrcMed->SetFilter(pFilter);
+        pSrcMed->UseInteractionHandler(false);
+        bool bLoaded = mxDocShell->DoLoad(pSrcMed);
+        CPPUNIT_ASSERT_MESSAGE(OUStringToOString("failed to load " + rURL, RTL_TEXTENCODING_UTF8).getStr(),
+                               bLoaded);
+    }
+
+    SmDocShellRef mxDocShell;
+};
+
+void Test::setUp()
+{
+    BootstrapFixture::setUp();
+    SmGlobals::ensure();
+}
+
+void Test::tearDown()
+{
+    if (mxDocShell) mxDocShell->DoClose();
+    BootstrapFixture::tearDown();
+}
+
+void Test::testSimple()
+{
+    loadURL(getURLFromSrc("starmath/qa/extras/data/simple.mml"));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list