diff options
Diffstat (limited to 'sd/qa/unit/import-tests-smartart.cxx')
-rw-r--r-- | sd/qa/unit/import-tests-smartart.cxx | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 29f998ce6f43..b1ced877c00d 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -15,6 +15,7 @@ #include <com/sun/star/text/XText.hpp> #include <comphelper/sequenceashashmap.hxx> +#include <oox/drawingml/drawingmltypes.hxx> using namespace ::com::sun::star; @@ -52,6 +53,7 @@ public: void testContinuousBlockProcess(); void testOrgChart(); void testCycleMatrix(); + void testPictureStrip(); CPPUNIT_TEST_SUITE(SdImportTestSmartArt); @@ -69,6 +71,7 @@ public: CPPUNIT_TEST(testContinuousBlockProcess); CPPUNIT_TEST(testOrgChart); CPPUNIT_TEST(testCycleMatrix); + CPPUNIT_TEST(testPictureStrip); CPPUNIT_TEST_SUITE_END(); }; @@ -640,6 +643,88 @@ void SdImportTestSmartArt::testCycleMatrix() xDocShRef->DoClose(); } +void SdImportTestSmartArt::testPictureStrip() +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-picture-strip.pptx"), PPTX); + uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); + CPPUNIT_ASSERT(xGroup.is()); + + uno::Reference<beans::XPropertySet> xFirstImage(getChildShape(getChildShape(xGroup, 0), 1), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xFirstImage.is()); + drawing::FillStyle eFillStyle = drawing::FillStyle_NONE; + xFirstImage->getPropertyValue("FillStyle") >>= eFillStyle; + // Without the accompanying fix in place, this test would have failed: fill style was solid, not + // bitmap. + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, eFillStyle); + + uno::Reference<graphic::XGraphic> xGraphic; + xFirstImage->getPropertyValue("FillBitmap") >>= xGraphic; + Graphic aFirstGraphic(xGraphic); + + uno::Reference<beans::XPropertySet> xSecondImage(getChildShape(getChildShape(xGroup, 1), 1), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xSecondImage.is()); + eFillStyle = drawing::FillStyle_NONE; + xSecondImage->getPropertyValue("FillStyle") >>= eFillStyle; + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, eFillStyle); + + xSecondImage->getPropertyValue("FillBitmap") >>= xGraphic; + Graphic aSecondGraphic(xGraphic); + // Without the accompanying fix in place, this test would have failed: both xFirstImage and + // xSecondImage had the bitmap fill from the second shape. + CPPUNIT_ASSERT(aFirstGraphic.GetChecksum() != aSecondGraphic.GetChecksum()); + + // Test that the 3 images are in a single column, in 3 rows. + uno::Reference<drawing::XShape> xFirstImageShape(xFirstImage, uno::UNO_QUERY); + CPPUNIT_ASSERT(xFirstImage.is()); + uno::Reference<drawing::XShape> xSecondImageShape(xSecondImage, uno::UNO_QUERY); + CPPUNIT_ASSERT(xSecondImage.is()); + uno::Reference<drawing::XShape> xThirdImageShape(getChildShape(getChildShape(xGroup, 2), 1), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xThirdImageShape.is()); + // Without the accompanying fix in place, this test would have failed: the first and the second + // image were in the same row. + CPPUNIT_ASSERT_EQUAL(xFirstImageShape->getPosition().X, xSecondImageShape->getPosition().X); + CPPUNIT_ASSERT_EQUAL(xSecondImageShape->getPosition().X, xThirdImageShape->getPosition().X); + CPPUNIT_ASSERT_GREATER(xFirstImageShape->getPosition().Y, xSecondImageShape->getPosition().Y); + CPPUNIT_ASSERT_GREATER(xSecondImageShape->getPosition().Y, xThirdImageShape->getPosition().Y); + + // Make sure that the title shape doesn't overlap with the diagram. + // Note that real "no overlap" is asserted here, though in fact what we want is a less strict + // condition: that no text part of the title shape and the diagram overlaps. + uno::Reference<drawing::XShape> xTitle(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY); + CPPUNIT_ASSERT(xTitle.is()); + // Without the accompanying fix in place, this test would have failed with 'Expected greater + // than: 2873; Actual : 2320', i.e. the title shape and the diagram overlapped. + CPPUNIT_ASSERT_GREATER(xTitle->getPosition().Y + xTitle->getSize().Height, + xGroup->getPosition().Y); + + // Make sure that left margin is 60% of width (if you count width in points and margin in mms). + uno::Reference<beans::XPropertySet> xFirstText(getChildShape(getChildShape(xGroup, 0), 0), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xFirstText.is()); + sal_Int32 nTextLeftDistance = 0; + xFirstText->getPropertyValue("TextLeftDistance") >>= nTextLeftDistance; + uno::Reference<drawing::XShape> xFirstTextShape(xFirstText, uno::UNO_QUERY); + CPPUNIT_ASSERT(xFirstTextShape.is()); + sal_Int32 nWidth = xFirstTextShape->getSize().Width; + double fFactor = oox::drawingml::convertPointToMms(0.6); + // Without the accompanying fix in place, this test would have failed with 'Expected: 3440, + // Actual : 263', i.e. the left margin was too small. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(nWidth * fFactor), nTextLeftDistance); + + // Make sure that aspect ratio is not ignored, i.e. width is not larger than height 3 times. + uno::Reference<drawing::XShape> xFirstPair = getChildShape(xGroup, 0); + awt::Size aFirstPairSize = xFirstPair->getSize(); + // Without the accompanying fix in place, this test would have failed: bad width was 16932, good + // width is 12540, but let's accept 12541 as well. + CPPUNIT_ASSERT_LESSEQUAL(aFirstPairSize.Height * 3 + 1, aFirstPairSize.Width); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt); CPPUNIT_PLUGIN_IMPLEMENT(); |