summaryrefslogtreecommitdiff
path: root/chart2/qa/extras/chart2import.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-07-07 19:04:41 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-07-07 19:06:22 -0400
commitdc4355e51764d18b36f748e7a743abde53cf9b9f (patch)
tree5b65807e1fbcf9ea4e4d90caeedeb82e053e9fc6 /chart2/qa/extras/chart2import.cxx
parentb8c444a46b2f41dae673c6118d84276be0e6c87d (diff)
bnc#881025: Write test for this.
Change-Id: Ifb1f83bbe5f9bb9ecb7fca26f883d1331052f10d
Diffstat (limited to 'chart2/qa/extras/chart2import.cxx')
-rw-r--r--chart2/qa/extras/chart2import.cxx61
1 files changed, 61 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index e0728edae9cc..785129118043 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -40,6 +40,7 @@ public:
* hidden columns for internal data table yet).
*/
void testPPTXHiddenDataSeries();
+ void testPPTXStackedNonStackedYAxis();
void testPPTChartSeries();
void testODPChartSeries();
void testBnc864396();
@@ -70,6 +71,7 @@ public:
CPPUNIT_TEST(testPPTChartSeries);
CPPUNIT_TEST(testPPTXChartSeries);
CPPUNIT_TEST(testPPTXHiddenDataSeries);
+ CPPUNIT_TEST(testPPTXStackedNonStackedYAxis);
CPPUNIT_TEST(testODPChartSeries);
CPPUNIT_TEST(testBnc864396);
CPPUNIT_TEST(testBnc882383);
@@ -365,6 +367,65 @@ void Chart2ImportTest::testPPTXHiddenDataSeries()
CPPUNIT_ASSERT_EQUAL(OUString("Category 4"), aCategories[3][0]);
}
+void Chart2ImportTest::testPPTXStackedNonStackedYAxis()
+{
+ load("/chart2/qa/extras/data/pptx/", "stacked-non-stacked-mix-y-axis.pptx");
+
+ // 1st chart is a normal stacked column.
+ Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
+ OUString aTitle = getTitleString(xTitled);
+ CPPUNIT_ASSERT_EQUAL(OUString("Stacked"), aTitle);
+
+ // Get the Y-axis.
+ Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
+ CPPUNIT_ASSERT(xYAxis.is());
+
+ sal_Int32 nNumberFormat = getNumberFormatFromAxis(xYAxis);
+ sal_Int16 nType = getNumberFormatType(xChartDoc, nNumberFormat);
+ CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType & util::NumberFormat::NUMBER));
+ CPPUNIT_ASSERT_MESSAGE("Y axis should NOT be a percent format.", !(nType & util::NumberFormat::PERCENT));
+
+ // 2nd chart is a percent-stacked column.
+ xChartDoc.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ xTitled.set(xChartDoc, uno::UNO_QUERY_THROW);
+ aTitle = getTitleString(xTitled);
+ CPPUNIT_ASSERT_EQUAL(OUString("100% Stacked"), aTitle);
+
+ // Get the Y-axis.
+ xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
+ CPPUNIT_ASSERT(xYAxis.is());
+
+ // Get the number format of the Y-axis.
+ nNumberFormat = getNumberFormatFromAxis(xYAxis);
+ nType = getNumberFormatType(xChartDoc, nNumberFormat);
+ CPPUNIT_ASSERT_MESSAGE("Y axis should be a percent format.", (nType & util::NumberFormat::PERCENT));
+
+ // 3rd chart is a mixture of normal-stacked column with a percent-stacked
+ // area chart series. Excel in this case sets the Y-axis to be
+ // non-percent axis and we should do the same for interoperability.
+ xChartDoc.set(getChartDocFromDrawImpress(2, 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ xTitled.set(xChartDoc, uno::UNO_QUERY_THROW);
+ aTitle = getTitleString(xTitled);
+ CPPUNIT_ASSERT_EQUAL(OUString("Stacked column mixed with 100% stacked area"), aTitle);
+
+ // Get the Y-axis.
+ xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
+ CPPUNIT_ASSERT(xYAxis.is());
+
+ // Get the number format of the Y-axis.
+ nNumberFormat = getNumberFormatFromAxis(xYAxis);
+ nType = getNumberFormatType(xChartDoc, nNumberFormat);
+ CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType & util::NumberFormat::NUMBER));
+ CPPUNIT_ASSERT_MESSAGE("Y axis should NOT be a percent format.", !(nType & util::NumberFormat::PERCENT));
+}
+
void Chart2ImportTest::testODPChartSeries()
{
//test chart series names for odp