Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


Hi,

I am going to prepare a unit test for starmath's import filter, which is
proposed in https://bugs.freedesktop.org/show_bug.cgi?id=70185.
As a first step, I have made up the test case attached for importing a MathML
file. Running the test case named "starmath_import" seems to finish reading
the input .mml, but failed in the end with the following message.
---
[build CUT] starmath_import
warn:legacy.osl:5812:1:starmath/source/mathmlimport.cxx:537: So there *was* a uno problem after all
/home/tabe/core/starmath/qa/extras/mmlimport-test.cxx:63:(anonymous namespace)::Test::testSimple
assertion failed
- Expression: bLoaded
- failed to load file:///home/tabe/core/starmath/qa/extras/data/simple.mml

mmlimport-test.cxx:63:Assertion
Test name: (anonymous namespace)::Test::testSimple
assertion failed
- Expression: bLoaded
- failed to load file:///home/tabe/core/starmath/qa/extras/data/simple.mml

Failures !!!
Run: 1   Failure total: 1   Failures: 1   Errors: 0
warn:fwk:5812:1:framework/source/services/desktop.cxx:1020: Desktop disposed before terminating it
warn:tools.debug:5812:1:tools/source/debug/debug.cxx:297: no DbgTestSolarMutex function set
warn:fwk:5812:1:framework/source/services/desktop.cxx:185: Desktop not terminated before being 
destructed
warn:legacy.osl:5812:1:unotools/source/config/configmgr.cxx:167: OSL_ASSERT: items_.empty()

Error: a unit test failed, please do one of:

export DEBUGCPPUNIT=TRUE            # for exception catching
export CPPUNITTRACE="gdb --args"    # for interactive debugging on Linux
export CPPUNITTRACE="\"[full path to devenv.exe]\" /debugexe" # for interactive debugging in Visual 
Studio
export VALGRIND=memcheck            # for memory checking

and retry using: make CppunitTest_starmath_import

---

As far as I see, in the following code around line 508 of
starmath/source/mathmlimport.cxx
---
        uno::Reference <frame::XModel> xModel = GetModel();
        uno::Reference <lang::XUnoTunnel> xTunnel;
        xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
        SmModel *pModel = reinterpret_cast<SmModel *>
            (xTunnel->getSomething(SmModel::getUnoTunnelId()));
---
pModel ended up being NULL, but I have no idea what really happens.
Could you give me any clue?
Thank you for your attention.

Cheers,
-- Takeshi Abe
From f82e628f77151d118b555efc0d15a1a8e60c4e3b Mon Sep 17 00:00:00 2001
From: Takeshi Abe <tabe@fixedpoint.jp>
Date: Tue, 9 Dec 2014 11:40:54 +0900
Subject: [PATCH] prototype of unit test for importing a MathML file

Change-Id: I19f38c85b6475c15679653c31413e7d0f6aef309
---
 starmath/CppunitTest_starmath_import.mk |   93 +++++++++++++++++++++++++++++++
 starmath/Module_starmath.mk             |    1 +
 starmath/qa/extras/data/simple.mml      |   13 +++++
 starmath/qa/extras/mmlimport-test.cxx   |   92 ++++++++++++++++++++++++++++++
 4 files changed, 199 insertions(+)
 create mode 100644 starmath/CppunitTest_starmath_import.mk
 create mode 100644 starmath/qa/extras/data/simple.mml
 create mode 100644 starmath/qa/extras/mmlimport-test.cxx

diff --git a/starmath/CppunitTest_starmath_import.mk b/starmath/CppunitTest_starmath_import.mk
new file mode 100644
index 0000000..d570b9b
--- /dev/null
+++ b/starmath/CppunitTest_starmath_import.mk
@@ -0,0 +1,93 @@
+# -*- 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_use_library_objects,starmath_import,\
+    sm \
+    smd \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,starmath_import,\
+    comphelper \
+    cppu \
+    cppuhelper \
+    editeng \
+    i18nlangtag \
+    i18nutil \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sfx \
+    sot \
+    svl \
+    svt \
+    svx \
+    svxcore \
+    test \
+    tk \
+    tl \
+    unotest \
+    unoxml \
+    utl \
+    vcl \
+    xo \
+       $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,starmath_import,\
+    starmath/qa/extras/mmlimport-test \
+))
+
+$(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))
+
+$(eval $(call gb_CppunitTest_use_unittest_configuration,starmath_import))
+
+# vim: set noet sw=4 ts=4:
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/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..e960857
--- /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_CURRENT);
+
+        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: */
-- 
1.7.10.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.