summaryrefslogtreecommitdiff
path: root/chart2/qa/extras/chart2import.cxx
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2013-10-30 16:36:25 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-10-30 11:21:42 +0000
commitce85ba3e2e926f72084cef2f18343f5f09f03152 (patch)
tree873741ecb9d657b3901b46f5f59ae3eaa349c069 /chart2/qa/extras/chart2import.cxx
parent9239dc026ae31d38e495c7031b1e55cab4aebe9a (diff)
Unit tests for Chart Series Name
Added UTS to verify the series names (Labels) for chart series for following- * xls, xlsx, ods * odt Change-Id: I4575a2e7ada9d4cf8b3fa708bd313f9d16244f65 Change-Id: Id291b49bf7547ee7264eb7c0751e416d20ca1e54 Reviewed-on: https://gerrit.libreoffice.org/6383 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'chart2/qa/extras/chart2import.cxx')
-rw-r--r--chart2/qa/extras/chart2import.cxx149
1 files changed, 148 insertions, 1 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index ad10a1d5630e..f20b834fb7c5 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -7,10 +7,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include "charttest.hxx"
+#include "charttest.hxx"
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/chart2/CurveStyle.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart/XChartDocument.hpp>
+#include <com/sun/star/chart/XChartData.hpp>
+#include <com/sun/star/chart2/XInternalDataProvider.hpp>
+#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
+#include <com/sun/star/chart/XChartDataArray.hpp>
class Chart2ImportTest : public ChartTest
{
@@ -18,11 +26,33 @@ public:
void Fdo60083();
void testSteppedLines();
void testErrorBarRange();
+ void testODSChartSeries();
+ void testXLSXChartSeries();
+ void testXLSChartSeries();
+ void testODTChartSeries();
+ void testDOCChartSeries();
+ void testPPTXChartSeries();
+ void testPPTChartSeries();
+ void testODPChartSeries();
CPPUNIT_TEST_SUITE(Chart2ImportTest);
CPPUNIT_TEST(Fdo60083);
CPPUNIT_TEST(testSteppedLines);
CPPUNIT_TEST(testErrorBarRange);
+ CPPUNIT_TEST(testODSChartSeries);
+ CPPUNIT_TEST(testXLSXChartSeries);
+ CPPUNIT_TEST(testXLSChartSeries);
+ CPPUNIT_TEST(testODTChartSeries);
+ CPPUNIT_TEST(testDOCChartSeries);
+/*
+ * Disabling Impress Uts.
+ * ChartTest::tearDown() calls dispose of mxComponent
+ * this causes the UT to crash in sd.
+ * sd::DrawView::Notify tries to reset by calling sd::DrawViewShell::ResetActualPage
+ */
+// CPPUNIT_TEST(testPPTChartSeries);
+// CPPUNIT_TEST(testPPTXChartSeries);
+// CPPUNIT_TEST(testODPChartSeries);
CPPUNIT_TEST_SUITE_END();
private:
@@ -150,6 +180,123 @@ void Chart2ImportTest::testSteppedLines()
}
}
+uno::Sequence < OUString > getChartColumnDescriptions( uno::Reference< chart::XChartDocument > xChart1Doc)
+{
+ CPPUNIT_ASSERT(xChart1Doc.is());
+ uno::Reference< chart::XChartDataArray > xChartData ( xChart1Doc->getData(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xChartData.is());
+ uno::Sequence < OUString > seriesList = xChartData->getColumnDescriptions();
+ return seriesList;
+}
+
+void Chart2ImportTest::testODSChartSeries()
+{
+ load("/chart2/qa/extras/data/ods/", "chart.ods");
+ uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
+ uno::Sequence < OUString > seriesList = getChartColumnDescriptions( xChart1Doc);
+ CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Col2"), seriesList[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Col 33"), seriesList[2]);
+
+}
+
+void Chart2ImportTest::testXLSXChartSeries()
+{
+ load("/chart2/qa/extras/data/xlsx/", "chart.xlsx");
+ uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
+ uno::Sequence < OUString > seriesList = getChartColumnDescriptions(xChart1Doc );
+ CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Col2"), seriesList[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Col 33"), seriesList[2]);
+
+}
+
+void Chart2ImportTest::testXLSChartSeries()
+{
+ load("/chart2/qa/extras/data/xls/", "chart.xls");
+ uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
+ uno::Sequence < OUString > seriesList = getChartColumnDescriptions(xChart1Doc );
+ CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Col 2"), seriesList[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Col 3"), seriesList[2]);
+
+}
+
+void Chart2ImportTest::testODTChartSeries()
+{
+ load("/chart2/qa/extras/data/odt/", "chart.odt");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT( xShape.is() );
+ uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+ uno::Reference< chart2::XChartDocument > xChartDoc;
+ xChartDoc.set( xPropertySet->getPropertyValue( "Model" ), uno::UNO_QUERY );
+ CPPUNIT_ASSERT( xChartDoc.is() );
+ CPPUNIT_ASSERT( xChartDoc->getDataProvider().is() );
+ uno::Reference<beans::XPropertySet> xProp(xChartDoc->getDataProvider(), uno::UNO_QUERY );
+ uno::Reference< chart2::XAnyDescriptionAccess > xAnyDescriptionAccess ( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
+ CPPUNIT_ASSERT( xAnyDescriptionAccess.is() );
+ uno::Sequence< OUString > seriesList = xAnyDescriptionAccess->getColumnDescriptions();
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
+
+}
+
+void Chart2ImportTest::testDOCChartSeries()
+{
+ load("/chart2/qa/extras/data/doc/", "chart.doc");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT( xShape.is() );
+ uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+ uno::Reference< chart2::XChartDocument > xChartDoc;
+ xChartDoc.set( xPropertySet->getPropertyValue( "Model" ), uno::UNO_QUERY );
+ CPPUNIT_ASSERT( xChartDoc.is() );
+ CPPUNIT_ASSERT( xChartDoc->getDataProvider().is() );
+ uno::Reference<beans::XPropertySet> xProp(xChartDoc->getDataProvider(), uno::UNO_QUERY );
+ uno::Reference< chart2::XAnyDescriptionAccess > xAnyDescriptionAccess ( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
+ CPPUNIT_ASSERT( xAnyDescriptionAccess.is() );
+ uno::Sequence< OUString > seriesList = xAnyDescriptionAccess->getColumnDescriptions();
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
+}
+
+
+void Chart2ImportTest::testPPTChartSeries()
+{
+ //test chart series names for ppt
+ uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions("/chart2/qa/extras/data/ppt/", "chart.ppt");
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
+
+}
+
+void Chart2ImportTest::testPPTXChartSeries()
+{
+ //test chart series names for pptx
+ uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions("/chart2/qa/extras/data/pptx/", "chart.pptx");
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[2]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[3]);
+
+}
+
+void Chart2ImportTest::testODPChartSeries()
+{
+ //test chart series names for odp
+ uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions("/chart2/qa/extras/data/odp/", "chart.odp");
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
+
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();