starmath/CppunitTest_starmath_export.mk |   26 --------
 starmath/qa/extras/mmlexport-test.cxx   |  104 +++++++++++---------------------
 2 files changed, 40 insertions(+), 90 deletions(-)

New commits:
commit 40d717c7bea493a24b9fd888bc71647d8793323b
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Mar 16 14:19:57 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Mar 16 16:17:35 2023 +0000

    CppunitTest_starmath_export: inherit from UnoApiXmlTest
    
    Change-Id: Ib84525664ff8456b4eb8e100aaaea2783babaf30
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148994
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/starmath/CppunitTest_starmath_export.mk 
b/starmath/CppunitTest_starmath_export.mk
index 3ea437c20aa1..442a90718352 100644
--- a/starmath/CppunitTest_starmath_export.mk
+++ b/starmath/CppunitTest_starmath_export.mk
@@ -41,6 +41,7 @@ $(eval $(call gb_CppunitTest_use_libraries,starmath_export,\
     sm \
     smd \
     sot \
+    subsequenttest \
     svl \
     svt \
     svx \
@@ -58,30 +59,7 @@ $(eval $(call gb_CppunitTest_use_libraries,starmath_export,\
 $(eval $(call gb_CppunitTest_use_ure,starmath_export))
 $(eval $(call gb_CppunitTest_use_vcl,starmath_export))
 
-$(eval $(call gb_CppunitTest_use_components,starmath_export,\
-    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 \
-    uui/util/uui \
-    xmloff/util/xo \
-))
+$(eval $(call gb_CppunitTest_use_rdb,starmath_export,services))
 
 $(eval $(call gb_CppunitTest_use_configuration,starmath_export))
 
diff --git a/starmath/qa/extras/mmlexport-test.cxx 
b/starmath/qa/extras/mmlexport-test.cxx
index 262ed6907b83..9eb0cae9f4f2 100644
--- a/starmath/qa/extras/mmlexport-test.cxx
+++ b/starmath/qa/extras/mmlexport-test.cxx
@@ -8,32 +8,24 @@
  */
 
 #include <sal/config.h>
+#include <test/unoapixml_test.hxx>
 
-#include <o3tl/cppunittraitshelper.hxx>
-#include <test/bootstrapfixture.hxx>
-#include <test/xmltesttools.hxx>
-#include <unotools/tempfile.hxx>
-
-#include <sfx2/docfile.hxx>
-#include <sfx2/docfilt.hxx>
-#include <sfx2/sfxmodelfactory.hxx>
+#include <sfx2/sfxbasemodel.hxx>
 
 #include <document.hxx>
 #include <smdll.hxx>
 
 #include <memory>
 
-namespace
-{
 using namespace ::com::sun::star;
 
-typedef tools::SvRef<SmDocShell> SmDocShellRef;
-
-class MathMLExportTest : public test::BootstrapFixture, public XmlTestTools
+class MathMLExportTest : public UnoApiXmlTest
 {
 public:
-    virtual void setUp() override;
-    virtual void tearDown() override;
+    MathMLExportTest()
+        : UnoApiXmlTest("starmath/qa/extras/data/")
+    {
+    }
 
     void testBlank();
     void testTdf97049();
@@ -48,72 +40,49 @@ public:
 protected:
     virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override;
 
-    void checkMathVariant(bool bCapital, bool bSmall);
-
-private:
-    xmlDocUniquePtr exportAndParse();
-
-    SmDocShellRef mxDocShell;
+    void checkMathVariant(SmDocShell& rDocShell, bool bCapital, bool bSmall);
 };
 
-void MathMLExportTest::setUp()
-{
-    BootstrapFixture::setUp();
-    SmGlobals::ensure();
-    mxDocShell
-        = new SmDocShell(SfxModelFlags::EMBEDDED_OBJECT | 
SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS
-                         | SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
-}
-
-void MathMLExportTest::tearDown()
-{
-    if (mxDocShell.is())
-        mxDocShell->DoClose();
-    BootstrapFixture::tearDown();
-}
-
 void MathMLExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx)
 {
     xmlXPathRegisterNs(pXmlXPathCtx, BAD_CAST("m"), 
BAD_CAST("http://www.w3.org/1998/Math/MathML";));
 }
 
-xmlDocUniquePtr MathMLExportTest::exportAndParse()
-{
-    utl::TempFileNamed aTempFile;
-    aTempFile.EnableKillingFile();
-    SfxMedium aStoreMedium(aTempFile.GetURL(), StreamMode::STD_WRITE);
-    std::shared_ptr<const SfxFilter> pExportFilter = 
SfxFilter::GetFilterByName(MATHML_XML);
-    aStoreMedium.SetFilter(pExportFilter);
-    CPPUNIT_ASSERT(mxDocShell->ConvertTo(aStoreMedium));
-    aStoreMedium.Commit();
-    xmlDocUniquePtr pDoc = parseXml(aTempFile);
-    CPPUNIT_ASSERT(pDoc);
-    return pDoc;
-}
-
 void MathMLExportTest::testBlank()
 {
-    mxDocShell->SetText("x`y~~z");
-    xmlDocUniquePtr pDoc = exportAndParse();
+    mxComponent = loadFromDesktop("private:factory/smath");
+    SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
+    SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
+    pDocShell->SetText("x`y~~z");
+    save("MathML XML (Math)");
+    xmlDocUniquePtr pDoc = parseXml(maTempFile);
+    CPPUNIT_ASSERT(pDoc);
     assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mspace[1]", "width", 
"0.5em");
     assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mspace[2]", "width", 
"4em");
 }
 
 void MathMLExportTest::testTdf97049()
 {
-    mxDocShell->SetText("intd {{1 over x} dx}");
-    xmlDocUniquePtr pDoc = exportAndParse();
+    mxComponent = loadFromDesktop("private:factory/smath");
+    SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
+    SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
+    pDocShell->SetText("intd {{1 over x} dx}");
+    save("MathML XML (Math)");
+    xmlDocUniquePtr pDoc = parseXml(maTempFile);
+    CPPUNIT_ASSERT(pDoc);
     assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mo[1]", "stretchy", 
"true");
     auto aContent = getXPathContent(pDoc, 
"/m:math/m:semantics/m:mrow/m:mo[1]");
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aContent.getLength());
     CPPUNIT_ASSERT_EQUAL(u'\x222B', aContent[0]);
 }
 
-void MathMLExportTest::checkMathVariant(bool bCapital, bool bSmall)
+void MathMLExportTest::checkMathVariant(SmDocShell& rDocShell, bool bCapital, 
bool bSmall)
 {
-    mxDocShell->SetText("%GAMMA %iGAMMA {ital %GAMMA} {nitalic %iGAMMA} "
-                        "%gamma %igamma {ital %gamma} {nitalic %igamma}");
-    xmlDocUniquePtr pDoc = exportAndParse();
+    rDocShell.SetText("%GAMMA %iGAMMA {ital %GAMMA} {nitalic %iGAMMA} "
+                      "%gamma %igamma {ital %gamma} {nitalic %igamma}");
+    save("MathML XML (Math)");
+    xmlDocUniquePtr pDoc = parseXml(maTempFile);
+    CPPUNIT_ASSERT(pDoc);
     if (bCapital)
         assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]", 
"mathvariant");
     else
@@ -128,22 +97,25 @@ void MathMLExportTest::checkMathVariant(bool bCapital, 
bool bSmall)
     assertXPathNoAttribute(pDoc, 
"/m:math/m:semantics/m:mrow/m:mstyle[3]/m:mi[1]", "mathvariant");
     assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[4]", 
"mathvariant");
     assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[4]/m:mi[1]", 
"mathvariant", "normal");
-    mxDocShell->SetText("");
+    rDocShell.SetText("");
 }
 
 void MathMLExportTest::testTdf101022()
 {
-    checkMathVariant(false, true); // default mode 2
+    mxComponent = loadFromDesktop("private:factory/smath");
+    SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
+    SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
 
-    mxDocShell->SetGreekCharStyle(1); // mode 1
-    checkMathVariant(true, true);
+    checkMathVariant(*pDocShell, false, true); // default mode 2
 
-    mxDocShell->SetGreekCharStyle(0); // mode 0
-    checkMathVariant(false, false);
+    pDocShell->SetGreekCharStyle(1); // mode 1
+    checkMathVariant(*pDocShell, true, true);
+
+    pDocShell->SetGreekCharStyle(0); // mode 0
+    checkMathVariant(*pDocShell, false, false);
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(MathMLExportTest);
-}
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 

Reply via email to