From 1c1fe7afb77e0538cdc4081ee266a7bda80f7b05 Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Wed, 17 Sep 2014 20:42:22 +0200 Subject: HTML import test for image inlined in 'src' attribute (related: fdo#50763) Fixed in 72703173066a2db5c977d422ace59d60b998bbfc Unfortunately the test does not really ensure it works now :-/ but still probably better than nothing and can be fixed potentially. Change-Id: I563b46c62d256c58a63f36443a5431603169c3f6 --- sw/CppunitTest_sw_htmlimport.mk | 1 + sw/qa/extras/htmlimport/data/inlined_image.html | 21 +++++++++++++ sw/qa/extras/htmlimport/htmlimport.cxx | 42 +++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 sw/qa/extras/htmlimport/data/inlined_image.html (limited to 'sw') diff --git a/sw/CppunitTest_sw_htmlimport.mk b/sw/CppunitTest_sw_htmlimport.mk index 30360763d9cc..425674b36621 100644 --- a/sw/CppunitTest_sw_htmlimport.mk +++ b/sw/CppunitTest_sw_htmlimport.mk @@ -38,6 +38,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_htmlimport,\ $(eval $(call gb_CppunitTest_set_include,sw_htmlimport,\ -I$(SRCDIR)/sw/inc \ -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/source/uibase/inc \ -I$(SRCDIR)/sw/qa/extras/inc \ $$(INCLUDE) \ )) diff --git a/sw/qa/extras/htmlimport/data/inlined_image.html b/sw/qa/extras/htmlimport/data/inlined_image.html new file mode 100644 index 000000000000..7ce2a29da350 --- /dev/null +++ b/sw/qa/extras/htmlimport/data/inlined_image.html @@ -0,0 +1,21 @@ + + + + + + + + + + + +

Simple document with a picture.

+

+


+
+ +

+ + \ No newline at end of file diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 86b7b86372b8..791c68f0fcfb 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -8,10 +8,14 @@ #include +#include +#include +#include #include #include #include +#include class HtmlImportTest : public SwModelTestBase { @@ -30,6 +34,44 @@ DECLARE_HTMLIMPORT_TEST(testPictureImport, "picture.html") CPPUNIT_ASSERT_EQUAL(size_t(1), rLinkManager.GetLinks().size()); } +DECLARE_HTMLIMPORT_TEST(testInlinedImage, "inlined_image.html") +{ + SwXTextDocument* pTxtDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTxtDoc); + // The document contains only one embeded picture inlined in img's src attribute. + + SwDoc* pDoc = pTxtDoc->GetDocShell()->GetDoc(); + SwEditShell* pEditShell = pDoc->GetEditShell(); + CPPUNIT_ASSERT(pEditShell); + + // This was 1 before 1ef778072763a539809c74804ef074c556efe501 + const sfx2::LinkManager& rLinkManager = pEditShell->GetLinkManager(); + CPPUNIT_ASSERT_EQUAL(size_t(0), rLinkManager.GetLinks().size()); + + uno::Reference xShape = getShape(1); + uno::Reference const xNamed(xShape, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(OUString("Image1"), xNamed->getName()); + + uno::Reference xGraphic = + getProperty< uno::Reference >(xShape, "Graphic"); + CPPUNIT_ASSERT(xGraphic.is()); + CPPUNIT_ASSERT(xGraphic->getType() != graphic::GraphicType::EMPTY); + + for (int n = 0; ; n++) + { + SwNode* pNode = pDoc->GetNodes()[ n ]; + if (SwGrfNode *pGrfNode = pNode->GetGrfNode()) + { + // FIXME? For some reason without the fix in 72703173066a2db5c977d422ace + // I was getting GRAPHIC_NONE from SwEditShell::GetGraphicType() when + // running LibreOffice but cannot reproduce that in a unit test here. :-( + // So, this does not really test anything. + CPPUNIT_ASSERT(pGrfNode->GetGrfObj().GetType() != GRAPHIC_NONE); + break; + } + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit