diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2024-02-13 14:35:33 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-02-16 22:42:20 +0100 |
commit | 0a632d2c4dd681945af88398e2e27d1c0e3146a3 (patch) | |
tree | 37fa7f067547832b74b4a4fab251ebc56a5f29d6 /sw | |
parent | aa2a180220f68bbfbbfbe48b383da90cd8b75db1 (diff) |
UnoApiXmlTest: factor out common code
Change-Id: I5c7f76b61a0dab8b4ebd1ac4680a7c25f982680c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163307
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163376
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/fodfexport/fodfexport.cxx | 36 | ||||
-rw-r--r-- | sw/qa/inc/swmodeltestbase.hxx | 7 | ||||
-rw-r--r-- | sw/qa/unit/swmodeltestbase.cxx | 6 |
3 files changed, 20 insertions, 29 deletions
diff --git a/sw/qa/extras/fodfexport/fodfexport.cxx b/sw/qa/extras/fodfexport/fodfexport.cxx index 2cf5bf42a7c9..840b5d47ba8a 100644 --- a/sw/qa/extras/fodfexport/fodfexport.cxx +++ b/sw/qa/extras/fodfexport/fodfexport.cxx @@ -20,34 +20,38 @@ public: } }; -DECLARE_FODFEXPORT_TEST(testTdf113696, "tdf113696.odt") +CPPUNIT_TEST_FIXTURE(Test, testTdf113696) { + loadFromFile(u"tdf113696.odt"); + CPPUNIT_ASSERT_EQUAL(1, getShapes()); CPPUNIT_ASSERT_EQUAL(1, getPages()); + + save("OpenDocument Text Flat XML"); // Test that an image which is written in svm format (image/x-vclgraphic) // is accompanied by a png fallback graphic. - if (xmlDocUniquePtr pXmlDoc = parseExportedFile()) - { - assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" - "draw:image[@draw:mime-type='image/x-vclgraphic']"_ostr); - assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" - "draw:image[@draw:mime-type='image/png']"_ostr); - } + xmlDocUniquePtr pXmlDoc = parseExportedFile(); + assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" + "draw:image[@draw:mime-type='image/x-vclgraphic']"_ostr); + assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" + "draw:image[@draw:mime-type='image/png']"_ostr); } -DECLARE_FODFEXPORT_TEST(testTdf113696WriterImage, "tdf113696-writerimage.odt") +CPPUNIT_TEST_FIXTURE(Test, testTdf113696WriterImage) { + loadFromFile(u"tdf113696-writerimage.odt"); + CPPUNIT_ASSERT_EQUAL(1, getShapes()); CPPUNIT_ASSERT_EQUAL(1, getPages()); + + save("OpenDocument Text Flat XML"); // Same as testTdf113696, but with a writer image instead of a draw image // (they use different code paths). - if (xmlDocUniquePtr pXmlDoc = parseExportedFile()) - { - assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" - "draw:image[@draw:mime-type='image/x-vclgraphic']"_ostr); - assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" - "draw:image[@draw:mime-type='image/png']"_ostr); - } + xmlDocUniquePtr pXmlDoc = parseExportedFile(); + assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" + "draw:image[@draw:mime-type='image/x-vclgraphic']"_ostr); + assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" + "draw:image[@draw:mime-type='image/png']"_ostr); } DECLARE_FODFEXPORT_TEST(testSvgImageRoundtrip, "SvgImageTest.fodt") diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx index 950136e66eba..669fd6dea4ea 100644 --- a/sw/qa/inc/swmodeltestbase.hxx +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -273,13 +273,6 @@ protected: int getShapes() const; /** - * Returns an xml stream of an exported file. - * To be used when the exporter doesn't create zip archives, but single files - * (like Flat ODF Export) - */ - xmlDocUniquePtr parseExportedFile(); - - /** * Creates a new document to be used with the internal sw/ API. * * Examples: diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx index d5248bd414fb..730ece0596b8 100644 --- a/sw/qa/unit/swmodeltestbase.cxx +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -517,12 +517,6 @@ int SwModelTestBase::getShapes() const return xDraws->getCount(); } -xmlDocUniquePtr SwModelTestBase::parseExportedFile() -{ - auto stream(SvFileStream(maTempFile.GetURL(), StreamMode::READ | StreamMode::TEMPORARY)); - return parseXmlStream(&stream); -} - void SwModelTestBase::createSwDoc(const char* pName, const char* pPassword) { if (!pName) |