summaryrefslogtreecommitdiff
path: root/starmath/qa
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2015-01-12 00:45:17 +0900
committerMichael Stahl <mstahl@redhat.com>2015-01-13 12:12:13 +0000
commit9b87116fa4c5873fa719468f775589edd6c8613c (patch)
treec495ae1adf2f009ee065b5c7c0f5466e1c9dc104 /starmath/qa
parent5e4a7a95027d979b3bdd729d7ebe950da1129b2b (diff)
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@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'starmath/qa')
-rw-r--r--starmath/qa/extras/data/simple.mml13
-rw-r--r--starmath/qa/extras/mmlimport-test.cxx92
2 files changed, 105 insertions, 0 deletions
diff --git a/starmath/qa/extras/data/simple.mml b/starmath/qa/extras/data/simple.mml
new file mode 100644
index 000000000000..822d1a709668
--- /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 000000000000..2fbeda7928dc
--- /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: */