summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-06-11 11:45:14 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-06-11 12:00:17 -0400
commit56ca1b76963c44318a4f5577e15cfa5e7e1cd2a2 (patch)
tree4643783106cf85b9bb25765092e2e75bff62ab76 /chart2
parent51d1545e0ce8b30eea710501b84853288dd2563b (diff)
fdo#77506: (finally) write a unit test for this.
I've switched from using a Draw document to Writer document due to some instability with Draw instance in our cppunit run. The bug is reproducible either way. The test is disabled for now, since the bug has yet to be fixed. Change-Id: I49e0417e1ecbc70f40aab8531237ae98ae58bdd3
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2export.cxx77
-rw-r--r--chart2/qa/extras/charttest.hxx61
-rw-r--r--chart2/qa/extras/data/odg/scatter-plot-labels.odgbin12861 -> 0 bytes
-rw-r--r--chart2/qa/extras/data/odt/scatter-plot-labels.odtbin0 -> 13454 bytes
4 files changed, 96 insertions, 42 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 6d83a8a64fe4..2d4713ed963e 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -50,7 +50,7 @@ public:
void testShapeFollowedByChart();
void testPieChartDataLabels();
void testSeriesIdxOrder();
- // void testScatterPlotLabels();
+ void testScatterPlotLabels();
void testErrorBarDataRangeODS();
void testChartCrash();
void testPieChartRotation();
@@ -83,7 +83,7 @@ public:
CPPUNIT_TEST(testShapeFollowedByChart);
CPPUNIT_TEST(testPieChartDataLabels);
CPPUNIT_TEST(testSeriesIdxOrder);
-// CPPUNIT_TEST(testScatterPlotLabels); TODO : This test crashes for some unknown reason.
+ CPPUNIT_TEST(testScatterPlotLabels);
CPPUNIT_TEST(testErrorBarDataRangeODS);
CPPUNIT_TEST(testChartCrash);
CPPUNIT_TEST(testPieChartRotation);
@@ -714,46 +714,39 @@ void Chart2ExportTest::testSeriesIdxOrder()
assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:order[1]", "val", "1");
}
-// void Chart2ExportTest::testScatterPlotLabels()
-// {
-// load("/chart2/qa/extras/data/odg/", "scatter-plot-labels.odg");
-// Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
-// CPPUNIT_ASSERT(xChartDoc.is());
-//
-// Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0, 0);
-// CPPUNIT_ASSERT(xCT.is());
-//
-// OUString aLabelRole = xCT->getRoleOfSequenceForSeriesLabel();
-//
-// Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY);
-// CPPUNIT_ASSERT(xDSCont.is());
-// Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
-// CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aDataSeriesSeq.getLength());
-//
-// for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)
-// {
-// uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY);
-// CPPUNIT_ASSERT(xDSrc.is());
-// uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
-// for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j)
-// {
-// Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues();
-// CPPUNIT_ASSERT(xValues.is());
-// Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY);
-// if (!xPropSet.is())
-// continue;
-//
-// OUString aRoleName;
-// xPropSet->getPropertyValue("Role") >>= aRoleName;
-// if (aRoleName == aLabelRole)
-// {
-// // TODO : Check the data series labels.
-// }
-// }
-// }
-//
-// CPPUNIT_ASSERT(false);
-// }
+void Chart2ExportTest::testScatterPlotLabels()
+{
+ load("/chart2/qa/extras/data/odt/", "scatter-plot-labels.odt");
+ Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0, 0);
+ CPPUNIT_ASSERT(xCT.is());
+
+ // Make sure the original chart has 'a', 'b', 'c' as its data labels.
+ std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
+ CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels[0][0].get<OUString>());
+ CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels[1][0].get<OUString>());
+ CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels[2][0].get<OUString>());
+
+ // Reload the doc and check again. The labels should not change.
+ reload("writer8");
+
+ xChartDoc.set(getChartDocFromWriter(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ xCT = getChartTypeFromDoc(xChartDoc, 0, 0);
+ CPPUNIT_ASSERT(xCT.is());
+
+#if 0
+ aLabels = getDataSeriesLabelsFromChartType(xCT);
+ CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels[0][0].get<OUString>());
+ CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels[1][0].get<OUString>());
+ CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels[2][0].get<OUString>());
+#endif
+}
void Chart2ExportTest::testErrorBarDataRangeODS()
{
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 6a52df0f9187..71b20e762b98 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -67,6 +67,8 @@ public:
uno::Reference<chart::XChartDocument> getChartDocFromDrawImpress( sal_Int32 nPage, sal_Int32 nShape );
+ uno::Reference<chart::XChartDocument> getChartDocFromWriter( sal_Int32 nShape );
+
virtual void setUp() SAL_OVERRIDE;
virtual void tearDown() SAL_OVERRIDE;
@@ -292,6 +294,46 @@ uno::Sequence < OUString > getWriterChartColumnDescriptions( Reference< lang::XC
return seriesList;
}
+std::vector<uno::Sequence<uno::Any> > getDataSeriesLabelsFromChartType( const Reference<chart2::XChartType>& xCT )
+{
+ OUString aLabelRole = xCT->getRoleOfSequenceForSeriesLabel();
+
+ Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xDSCont.is());
+ Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aDataSeriesSeq.getLength());
+
+ std::vector<uno::Sequence<uno::Any> > aRet;
+ for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)
+ {
+ uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xDSrc.is());
+ uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
+ for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j)
+ {
+ Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues();
+ CPPUNIT_ASSERT(xValues.is());
+ Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY);
+ if (!xPropSet.is())
+ continue;
+
+ OUString aRoleName;
+ xPropSet->getPropertyValue("Role") >>= aRoleName;
+ if (aRoleName == aLabelRole)
+ {
+ Reference<chart2::data::XLabeledDataSequence> xLabel = aDataSeqs[j];
+ CPPUNIT_ASSERT(xLabel.is());
+ Reference<chart2::data::XDataSequence> xDS2 = xLabel->getLabel();
+ CPPUNIT_ASSERT(xDS2.is());
+ uno::Sequence<uno::Any> aData = xDS2->getData();
+ aRet.push_back(aData);
+ }
+ }
+ }
+
+ return aRet;
+}
+
uno::Reference< chart::XChartDocument > ChartTest::getChartDocFromImpress( const char* pDir, const char* pName )
{
mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.comp.Draw.PresentationDocument");
@@ -337,6 +379,25 @@ uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromDrawImpress(
return xChartDoc;
}
+uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromWriter( sal_Int32 nShape )
+{
+ Reference<drawing::XDrawPageSupplier> xPageSupp(mxComponent, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xPageSupp.is());
+
+ Reference<drawing::XDrawPage> xPage = xPageSupp->getDrawPage();
+ CPPUNIT_ASSERT(xPage.is());
+
+ Reference<beans::XPropertySet> xShapeProps(xPage->getByIndex(nShape), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xShapeProps.is());
+
+ Reference<frame::XModel> xDocModel;
+ xShapeProps->getPropertyValue("Model") >>= xDocModel;
+ CPPUNIT_ASSERT(xDocModel.is());
+
+ uno::Reference<chart::XChartDocument> xChartDoc(xDocModel, uno::UNO_QUERY);
+ return xChartDoc;
+}
+
uno::Sequence < OUString > ChartTest::getImpressChartColumnDescriptions( const char* pDir, const char* pName )
{
uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromImpress( pDir, pName );
diff --git a/chart2/qa/extras/data/odg/scatter-plot-labels.odg b/chart2/qa/extras/data/odg/scatter-plot-labels.odg
deleted file mode 100644
index af0dfee11384..000000000000
--- a/chart2/qa/extras/data/odg/scatter-plot-labels.odg
+++ /dev/null
Binary files differ
diff --git a/chart2/qa/extras/data/odt/scatter-plot-labels.odt b/chart2/qa/extras/data/odt/scatter-plot-labels.odt
new file mode 100644
index 000000000000..ab8f24324256
--- /dev/null
+++ b/chart2/qa/extras/data/odt/scatter-plot-labels.odt
Binary files differ