Hey,

so the attched version of the patch gets you past that problem. Now the
test fails actually in parsing which you should debug and check if there is
something missing or if there is a setup problem.

The problem that I fixed is that because you passed the filter version as
current it was trying to handle the file as a ODF file. I think there are
still a few wrong filter flags but that would need some more debugging and
checking which are used during a normal import.

Regards,
Markus

On Tue, Dec 9, 2014 at 5:58 AM, Markus Mohrhard <
markus.mohrh...@googlemail.com> wrote:

>
>
> On Tue, Dec 9, 2014 at 5:43 AM, Takeshi Abe <t...@fixedpoint.jp> wrote:
>
>> Hi Markus,
>>
>> Thank you for quick reply.
>>
>> On Tue, 9 Dec 2014 04:47:16 +0100, Markus Mohrhard <
>> markus.mohrh...@googlemail.com> wrote:
>> (snip)
>> > So this might be just a missing component file in the makefile. Could
>> you
>> > please attach your work in progress patch so we can easily reproduce the
>> > problem and help you?
>> That's the attached one with the previous mail.
>>
>
> Sorry, I missed that. I'll have a look at it.
>
>
>> Or, do you mean any other essential piece of new cppunit tests are missing
>> in the patch?
>>
>> Cheers,
>> -- Takeshi Abe
>>
>
>
From 342ae77c50c877870cfc9452acaee5edc2f6c542 Mon Sep 17 00:00:00 2001
From: Takeshi Abe <t...@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..cb25943
--- /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_31);
+
+        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: */
-- 
2.1.2

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to