Kaydet (Commit) 750b2a1c authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#123504: improve unit test robustness

... since the values are unstable for charts. Just use reasonable
lower bounds.

Change-Id: I9510d834a3905c188b52313e267998a4c73f8aa2
Reviewed-on: https://gerrit.libreoffice.org/69458
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 5788bb02
...@@ -856,7 +856,6 @@ DECLARE_DUMP_TEST(PieChartTest, Chart2DumpTest, false) ...@@ -856,7 +856,6 @@ DECLARE_DUMP_TEST(PieChartTest, Chart2DumpTest, false)
"exploded_pie_chart.ods", "exploded_pie_chart.ods",
"donut_chart.ods", "donut_chart.ods",
"pie_chart_many_slices.ods", "pie_chart_many_slices.ods",
"pie_chart_100_and_0.ods",
}; };
for (const OUString& sTestFile : aTestFiles) for (const OUString& sTestFile : aTestFiles)
......
// nSeriesCount
1
/// Series 0 slices
// nSlicesCountInSeries
1
/// /D=0:CS=0:CT=0:Series=0:Point=0
// aSlicePosition.X
3210
// aSlicePosition.Y
180
// aSliceSize.Height
8639
// aSliceSize.Width
8639
// aSliceTransformation
8639;0;3210;0;8639;180;0;0;1
// static_cast<sal_Int32>(aSliceFillStyle)
1
// static_cast<sal_Int32>(aSliceFillColor)
17798
\ No newline at end of file
...@@ -123,6 +123,7 @@ public: ...@@ -123,6 +123,7 @@ public:
void testDataPointInheritedColorDOCX(); void testDataPointInheritedColorDOCX();
void testExternalStrRefsXLSX(); void testExternalStrRefsXLSX();
void testSourceNumberFormatComplexCategoriesXLS(); void testSourceNumberFormatComplexCategoriesXLS();
void testTdf123504();
CPPUNIT_TEST_SUITE(Chart2ImportTest); CPPUNIT_TEST_SUITE(Chart2ImportTest);
CPPUNIT_TEST(Fdo60083); CPPUNIT_TEST(Fdo60083);
...@@ -200,6 +201,7 @@ public: ...@@ -200,6 +201,7 @@ public:
CPPUNIT_TEST(testDataPointInheritedColorDOCX); CPPUNIT_TEST(testDataPointInheritedColorDOCX);
CPPUNIT_TEST(testExternalStrRefsXLSX); CPPUNIT_TEST(testExternalStrRefsXLSX);
CPPUNIT_TEST(testSourceNumberFormatComplexCategoriesXLS); CPPUNIT_TEST(testSourceNumberFormatComplexCategoriesXLS);
CPPUNIT_TEST(testTdf123504);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -1797,6 +1799,37 @@ void Chart2ImportTest::testSourceNumberFormatComplexCategoriesXLS() ...@@ -1797,6 +1799,37 @@ void Chart2ImportTest::testSourceNumberFormatComplexCategoriesXLS()
CPPUNIT_ASSERT(nNumberFormat != 0); CPPUNIT_ASSERT(nNumberFormat != 0);
} }
void Chart2ImportTest::testTdf123504()
{
load("/chart2/qa/extras/data/ods/", "pie_chart_100_and_0.ods");
Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent),
UNO_QUERY_THROW);
Reference<chart2::XChartDocument> xChartDoc2(xChartDoc, UNO_QUERY_THROW);
Reference<chart2::XChartType> xChartType(getChartTypeFromDoc(xChartDoc2, 0), UNO_SET_THROW);
std::vector aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType);
CPPUNIT_ASSERT_EQUAL(size_t(1), aDataSeriesYValues.size());
Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW);
Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW);
Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW);
Reference<drawing::XShape> xSeriesSlices(getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=0"),
UNO_SET_THROW);
Reference<container::XIndexAccess> xIndexAccess(xSeriesSlices, UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
Reference<drawing::XShape> xSlice(xIndexAccess->getByIndex(0), UNO_QUERY_THROW);
// Check size and position of the only slice in the chart (100%)
// In the regressed state, it used to be 0-sized at position 0,0
awt::Point aSlicePosition = xSlice->getPosition();
CPPUNIT_ASSERT_GREATER(sal_Int32(3000), aSlicePosition.X);
CPPUNIT_ASSERT_GREATER(sal_Int32(150), aSlicePosition.Y);
awt::Size aSliceSize = xSlice->getSize();
CPPUNIT_ASSERT_GREATER(sal_Int32(8500), aSliceSize.Height);
CPPUNIT_ASSERT_GREATER(sal_Int32(8500), aSliceSize.Width);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment