diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-05-04 14:06:14 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-05-05 12:43:18 +0200 |
commit | 1d532b15472f42bda831c5404f78f92725e66e83 (patch) | |
tree | d558c09f7d7de78fe86ff963ccc7593c8b734fca /chart2 | |
parent | edab3e4d2941a545b6f84df41003fa621c4471d3 (diff) |
tdf#101894: chart2: move UItest to CppUnittest
Change-Id: I54d7376cb9b96164ed8c4526ef8f3a0502326f9d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151365
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/qa/extras/data/ods/tdf101894.ods | bin | 0 -> 18221 bytes | |||
-rw-r--r-- | chart2/qa/extras/uichart.cxx | 76 |
2 files changed, 76 insertions, 0 deletions
diff --git a/chart2/qa/extras/data/ods/tdf101894.ods b/chart2/qa/extras/data/ods/tdf101894.ods Binary files differnew file mode 100644 index 000000000000..70d8b3a0dd55 --- /dev/null +++ b/chart2/qa/extras/data/ods/tdf101894.ods diff --git a/chart2/qa/extras/uichart.cxx b/chart2/qa/extras/uichart.cxx index 23f2223af896..1dfbfcba8b84 100644 --- a/chart2/qa/extras/uichart.cxx +++ b/chart2/qa/extras/uichart.cxx @@ -230,6 +230,82 @@ CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf98690) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(12), aSeriesList2.getLength()); } +CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf101894) +{ + loadFromURL(u"ods/tdf101894.ods"); + uno::Reference<chart::XChartDocument> xChartDoc(getChartCompFromSheet(0, 0, mxComponent), + uno::UNO_QUERY_THROW); + + CPPUNIT_ASSERT(xChartDoc.is()); + uno::Reference<chart::XChartDataArray> xChartData(xChartDoc->getData(), uno::UNO_QUERY_THROW); + + uno::Sequence<OUString> aExpectedColumnDescriptions = xChartData->getColumnDescriptions(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of columns in origin file", + static_cast<sal_Int32>(12), + aExpectedColumnDescriptions.getLength()); + + uno::Sequence<OUString> aExpectedRowDescriptions = xChartData->getRowDescriptions(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in origin file", + static_cast<sal_Int32>(8), aExpectedRowDescriptions.getLength()); + + Sequence<Sequence<double>> aExpectedData = xChartData->getData(); + + // Create a copy of the sheet and move to the end + uno::Sequence<beans::PropertyValue> aArgs( + comphelper::InitPropertySequence({ { "DocName", uno::Any(OUString("tdf101894")) }, + { "Index", uno::Any(sal_uInt16(32767)) }, + { "Copy", uno::Any(true) } })); + dispatchCommand(mxComponent, ".uno:Move", aArgs); + + for (sal_Int32 sheetIndex = 0; sheetIndex < 2; ++sheetIndex) + { + uno::Reference<chart::XChartDocument> xChartDoc2( + getChartCompFromSheet(sheetIndex, 0, mxComponent), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xChartDoc2.is()); + uno::Reference<chart::XChartDataArray> xChartData2(xChartDoc2->getData(), + uno::UNO_QUERY_THROW); + + uno::Sequence<OUString> aColumnDescriptions = xChartData2->getColumnDescriptions(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of columns in origin file", + static_cast<sal_Int32>(12), aColumnDescriptions.getLength()); + for (sal_Int32 i = 0; i < 12; ++i) + { + OString sMessage("Incorrect description in column: " + OString::number(i)); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), aExpectedColumnDescriptions[i], + aColumnDescriptions[i]); + } + + uno::Sequence<OUString> aRowDescriptions = xChartData2->getRowDescriptions(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in origin file", + static_cast<sal_Int32>(8), aRowDescriptions.getLength()); + for (sal_Int32 i = 0; i < 8; ++i) + { + OString sMessage("Incorrect description in row: " + OString::number(i)); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), aExpectedRowDescriptions[i], + aRowDescriptions[i]); + } + + Sequence<Sequence<double>> aData = xChartData2->getData(); + + for (sal_Int32 nRowIdx = 0; nRowIdx < 8; ++nRowIdx) + { + for (sal_Int32 nColIdx = 0; nColIdx < 12; ++nColIdx) + { + double nValue = aData[nRowIdx][nColIdx]; + double nExpected = aExpectedData[nRowIdx][nColIdx]; + OString sMessage("Incorrect value in Col: " + OString::number(nColIdx) + + " Row: " + OString::number(nRowIdx)); + + // Without the fix in place, this test would have failed with + // - Expected: 1 + // - Actual : 2.2250738585072e-308 + // - Incorrect value in Col: 0 Row: 0 + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(sMessage.getStr(), nExpected, nValue, 1e-1); + } + } + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |