diff options
author | Muthu Subramanian <sumuthu@collabora.com> | 2013-11-06 15:37:20 +0530 |
---|---|---|
committer | Muthu Subramanian <sumuthu@collabora.com> | 2013-11-06 15:40:30 +0530 |
commit | 3752d67c050f369f683ca60e50e0a30f59166449 (patch) | |
tree | bfd93aaebdc4a916f753fa18b0dd682565b9b35b /sd/qa | |
parent | 16c31e90f791c5a690ca1901c0fa40369023658b (diff) |
fdo#71075: Adding unit test for chart import (odp)
Diffstat (limited to 'sd/qa')
-rw-r--r-- | sd/qa/unit/data/fdo71075.odp | bin | 0 -> 15574 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 56 |
2 files changed, 56 insertions, 0 deletions
diff --git a/sd/qa/unit/data/fdo71075.odp b/sd/qa/unit/data/fdo71075.odp Binary files differnew file mode 100644 index 000000000000..b418faf39a72 --- /dev/null +++ b/sd/qa/unit/data/fdo71075.odp diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 6581726624b6..2a7de2de4257 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -24,6 +24,14 @@ #include <com/sun/star/animations/XAnimationNode.hpp> #include <com/sun/star/animations/XAnimate.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/chart/XChartDocument.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> +#include <com/sun/star/chart2/data/XDataSequence.hpp> +#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> using namespace ::com::sun::star; @@ -36,6 +44,7 @@ public: void testN759180(); void testN778859(); void testFdo64512(); + void testFdo71075(); CPPUNIT_TEST_SUITE(SdFiltersTest); CPPUNIT_TEST(testDocumentLayout); @@ -43,6 +52,8 @@ public: CPPUNIT_TEST(testN759180); CPPUNIT_TEST(testN778859); CPPUNIT_TEST(testFdo64512); + CPPUNIT_TEST(testFdo71075); + CPPUNIT_TEST_SUITE_END(); }; @@ -227,6 +238,51 @@ void SdFiltersTest::testFdo64512() xTargetShape != xSvgShape ); } +// Unit test for importing charts +void SdFiltersTest::testFdo71075() +{ + double values[] = { 12.0, 13.0, 14.0 }; + ::com::sun::star::uno::Any aAny; + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71075.odp")); + CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() ); + CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() ); + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW ); + uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW ); + uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW ); + CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape.is() ); + + uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY ); + aAny = xPropSet->getPropertyValue( OUString("Model") ); + CPPUNIT_ASSERT_MESSAGE( "failed to load shape", aAny.hasValue() ); + + uno::Reference< chart::XChartDocument > xChartDoc; + aAny >>= xChartDoc; + CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc.is() ); + uno::Reference< chart2::XChartDocument > xChart2Doc( xChartDoc, uno::UNO_QUERY ); + CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc.is() ); + + uno::Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xChart2Doc->getFirstDiagram(), uno::UNO_QUERY ); + uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xBCooSysCnt->getCoordinateSystems()); + uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[0], uno::UNO_QUERY ); + + uno::Reference< chart2::XDataSeriesContainer > xDSCnt( xCTCnt->getChartTypes()[0], uno::UNO_QUERY ); + CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt.is() ); + uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries()); + CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aSeriesSeq.getLength() == 1); + uno::Reference< chart2::data::XDataSource > xSource( aSeriesSeq[0], uno::UNO_QUERY ); + uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(xSource->getDataSequences()); + CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aSeqCnt.getLength() == 1); + uno::Reference< chart2::data::XDataSequence > xValueSeq( aSeqCnt[0]->getValues() ); + CPPUNIT_ASSERT_MESSAGE( "Invalid Data count", xValueSeq->getData().getLength() == sizeof(values)/(sizeof(double))); + uno::Reference< chart2::data::XNumericalDataSequence > xNumSeq( xValueSeq, uno::UNO_QUERY ); + uno::Sequence< double > aValues( xNumSeq->getNumericalData()); + for(sal_Int32 i=0;i<xValueSeq->getData().getLength();i++) + CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aValues.getConstArray()[i] == values[i]); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest); CPPUNIT_PLUGIN_IMPLEMENT(); |