[Libreoffice-commits] core.git: sd/CppunitTest_sd_import_tests.mk sd/qa
Muthu Subramanian
sumuthu at collabora.com
Wed Nov 6 11:05:24 CET 2013
sd/CppunitTest_sd_import_tests.mk | 2 +
sd/qa/unit/data/fdo71075.odp |binary
sd/qa/unit/import-tests.cxx | 56 ++++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+)
New commits:
commit 3752d67c050f369f683ca60e50e0a30f59166449
Author: Muthu Subramanian <sumuthu at collabora.com>
Date: Wed Nov 6 15:37:20 2013 +0530
fdo#71075: Adding unit test for chart import (odp)
diff --git a/sd/CppunitTest_sd_import_tests.mk b/sd/CppunitTest_sd_import_tests.mk
index 8e0773c..a0f2ad9 100644
--- a/sd/CppunitTest_sd_import_tests.mk
+++ b/sd/CppunitTest_sd_import_tests.mk
@@ -67,6 +67,8 @@ $(eval $(call gb_CppunitTest_use_ure,sd_import_tests))
$(eval $(call gb_CppunitTest_use_components,sd_import_tests,\
animations/source/animcore/animcore \
basic/util/sb \
+ chart2/source/chartcore \
+ chart2/source/controller/chartcontroller \
comphelper/util/comphelp \
configmgr/source/configmgr \
dbaccess/util/dba \
diff --git a/sd/qa/unit/data/fdo71075.odp b/sd/qa/unit/data/fdo71075.odp
new file mode 100644
index 0000000..b418faf
Binary files /dev/null and b/sd/qa/unit/data/fdo71075.odp differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 6581726..2a7de2d 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();
More information about the Libreoffice-commits
mailing list