From 4daba1f0e526c8c1ba829fe6e95c957bef6e46bb Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Sat, 10 Oct 2015 21:51:48 +0200 Subject: tdf#88154 - added unit test for rotated layout Change-Id: Ie0243bda8ec253d68f3bc5e469623d1f4edddcf5 Reviewed-on: https://gerrit.libreoffice.org/19297 Reviewed-by: Andras Timar Tested-by: Andras Timar --- chart2/qa/extras/xshape/chart2xshape.cxx | 68 +++++++++++++++++++++ .../data/pptx/tdf88154_LabelRotatedLayout.pptx | Bin 0 -> 34771 bytes 2 files changed, 68 insertions(+) create mode 100644 chart2/qa/extras/xshape/data/pptx/tdf88154_LabelRotatedLayout.pptx (limited to 'chart2') diff --git a/chart2/qa/extras/xshape/chart2xshape.cxx b/chart2/qa/extras/xshape/chart2xshape.cxx index dd74e183e1a9..c49662fbb8f1 100644 --- a/chart2/qa/extras/xshape/chart2xshape.cxx +++ b/chart2/qa/extras/xshape/chart2xshape.cxx @@ -35,6 +35,7 @@ public: void testPieChartLabels3(); void testPieChartLabels4(); void testTdf76649TrendLineBug(); + void testTdf88154LabelRotatedLayout(); CPPUNIT_TEST_SUITE(Chart2XShapeTest); CPPUNIT_TEST(testFdo75075); @@ -44,6 +45,7 @@ public: CPPUNIT_TEST(testPieChartLabels3); CPPUNIT_TEST(testPieChartLabels4); CPPUNIT_TEST(testTdf76649TrendLineBug); + CPPUNIT_TEST(testTdf88154LabelRotatedLayout); CPPUNIT_TEST_SUITE_END(); @@ -155,6 +157,72 @@ void Chart2XShapeTest::testTdf76649TrendLineBug() assertXPath(pXmlDoc, "//XShape[@name='CID/D=0:CS=0:CT=0:Series=0:Curve=0']", 1); } +void Chart2XShapeTest::testTdf88154LabelRotatedLayout() +{ + load("chart2/qa/extras/xshape/data/pptx/", "tdf88154_LabelRotatedLayout.pptx"); + uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromDrawImpress(0,6); + uno::Reference< qa::XDumper > xDumper( xChartDoc, UNO_QUERY_THROW ); + OUString rDump = xDumper->dump(); + OString aXmlDump = OUStringToOString(rDump, RTL_TEXTENCODING_UTF8); + xmlDocPtr pXmlDoc = xmlParseDoc(reinterpret_cast(aXmlDump.getStr())); + + { + OString aPath( "//XShape[@text='Oct-12']/Transformation" ); + assertXPath(pXmlDoc, aPath, 1); + double fT11 = getXPath(pXmlDoc, aPath + "/Line1", "column1").toDouble(); + double fT12 = getXPath(pXmlDoc, aPath + "/Line1", "column2").toDouble(); + double fT21 = getXPath(pXmlDoc, aPath + "/Line2", "column1").toDouble(); + double fT22 = getXPath(pXmlDoc, aPath + "/Line2", "column2").toDouble(); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(fT11, -fT21, 1e-8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fT12, fT22, 1e-8); + } + { + OString aPath( "//XShape[@text='Nov-12']/Transformation" ); + assertXPath(pXmlDoc, aPath, 1); + double fT11 = getXPath(pXmlDoc, aPath + "/Line1", "column1").toDouble(); + double fT12 = getXPath(pXmlDoc, aPath + "/Line1", "column2").toDouble(); + double fT21 = getXPath(pXmlDoc, aPath + "/Line2", "column1").toDouble(); + double fT22 = getXPath(pXmlDoc, aPath + "/Line2", "column2").toDouble(); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(fT11, -fT21, 1e-8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fT12, fT22, 1e-8); + } + { + OString aPath( "//XShape[@text='Dec-12']/Transformation" ); + assertXPath(pXmlDoc, aPath, 1); + double fT11 = getXPath(pXmlDoc, aPath + "/Line1", "column1").toDouble(); + double fT12 = getXPath(pXmlDoc, aPath + "/Line1", "column2").toDouble(); + double fT21 = getXPath(pXmlDoc, aPath + "/Line2", "column1").toDouble(); + double fT22 = getXPath(pXmlDoc, aPath + "/Line2", "column2").toDouble(); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(fT11, -fT21, 1e-8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fT12, fT22, 1e-8); + } + { + OString aPath( "//XShape[@text='May-13']/Transformation" ); + assertXPath(pXmlDoc, aPath, 1); + double fT11 = getXPath(pXmlDoc, aPath + "/Line1", "column1").toDouble(); + double fT12 = getXPath(pXmlDoc, aPath + "/Line1", "column2").toDouble(); + double fT21 = getXPath(pXmlDoc, aPath + "/Line2", "column1").toDouble(); + double fT22 = getXPath(pXmlDoc, aPath + "/Line2", "column2").toDouble(); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(fT11, -fT21, 1e-8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fT12, fT22, 1e-8); + } + { + OString aPath( "//XShape[@text='Jan-14']/Transformation" ); + assertXPath(pXmlDoc, aPath, 1); + double fT11 = getXPath(pXmlDoc, aPath + "/Line1", "column1").toDouble(); + double fT12 = getXPath(pXmlDoc, aPath + "/Line1", "column2").toDouble(); + double fT21 = getXPath(pXmlDoc, aPath + "/Line2", "column1").toDouble(); + double fT22 = getXPath(pXmlDoc, aPath + "/Line2", "column2").toDouble(); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(fT11, -fT21, 1e-8); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fT12, fT22, 1e-8); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2XShapeTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/xshape/data/pptx/tdf88154_LabelRotatedLayout.pptx b/chart2/qa/extras/xshape/data/pptx/tdf88154_LabelRotatedLayout.pptx new file mode 100644 index 000000000000..f3af67765677 Binary files /dev/null and b/chart2/qa/extras/xshape/data/pptx/tdf88154_LabelRotatedLayout.pptx differ -- cgit