starmath/qa/extras/mmlexport-test.cxx | 59 +++++++++++++++------------------- 1 file changed, 27 insertions(+), 32 deletions(-)
New commits: commit 8cf26e739797fdceddf5e805f02c63179d17b70e Author: Xisco Fauli <[email protected]> AuthorDate: Thu Mar 16 14:13:25 2023 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Thu Mar 16 15:51:58 2023 +0000 CppunitTest_starmath_export: move code to method Change-Id: I460ffc51d82ff8b727813228e93a6e0c95c8569a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148993 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/starmath/qa/extras/mmlexport-test.cxx b/starmath/qa/extras/mmlexport-test.cxx index f74c0c76c851..262ed6907b83 100644 --- a/starmath/qa/extras/mmlexport-test.cxx +++ b/starmath/qa/extras/mmlexport-test.cxx @@ -48,6 +48,8 @@ public: protected: virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override; + void checkMathVariant(bool bCapital, bool bSmall); + private: xmlDocUniquePtr exportAndParse(); @@ -107,44 +109,37 @@ void MathMLExportTest::testTdf97049() CPPUNIT_ASSERT_EQUAL(u'\x222B', aContent[0]); } +void MathMLExportTest::checkMathVariant(bool bCapital, bool bSmall) +{ + mxDocShell->SetText("%GAMMA %iGAMMA {ital %GAMMA} {nitalic %iGAMMA} " + "%gamma %igamma {ital %gamma} {nitalic %igamma}"); + xmlDocUniquePtr pDoc = exportAndParse(); + if (bCapital) + assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]", "mathvariant"); + else + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]", "mathvariant", "normal"); + assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[1]/m:mi[1]", "mathvariant"); + assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[2]", "mathvariant"); + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[2]/m:mi[1]", "mathvariant", "normal"); + if (bSmall) + assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[3]", "mathvariant"); + else + assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mi[3]", "mathvariant", "normal"); + 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(""); +} + void MathMLExportTest::testTdf101022() { -#define CHECK_MATHVARIANT(capital, small) \ - do \ - { \ - mxDocShell->SetText("%GAMMA %iGAMMA {ital %GAMMA} {nitalic %iGAMMA} " \ - "%gamma %igamma {ital %gamma} {nitalic %igamma}"); \ - xmlDocUniquePtr pDoc = exportAndParse(); \ - if (capital) \ - assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]", "mathvariant"); \ - else \ - assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]", "mathvariant", "normal"); \ - assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[1]/m:mi[1]", \ - "mathvariant"); \ - assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[2]", "mathvariant"); \ - assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mstyle[2]/m:mi[1]", "mathvariant", \ - "normal"); \ - if (small) \ - assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[3]", "mathvariant"); \ - else \ - assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mi[3]", "mathvariant", "normal"); \ - 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(""); \ - } while (false) - - CHECK_MATHVARIANT(false, true); // default mode 2 + checkMathVariant(false, true); // default mode 2 mxDocShell->SetGreekCharStyle(1); // mode 1 - CHECK_MATHVARIANT(true, true); + checkMathVariant(true, true); mxDocShell->SetGreekCharStyle(0); // mode 0 - CHECK_MATHVARIANT(false, false); - -#undef CHECK_MATHVARIANT + checkMathVariant(false, false); } CPPUNIT_TEST_SUITE_REGISTRATION(MathMLExportTest);
