diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-12-07 12:00:57 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-12-07 14:45:54 +0000 |
commit | 8e3258f7d62ec154f2d80af2f39028a4c40fa12f (patch) | |
tree | 5b6928d2a8ecd04df2c4cb271c81486f57b9f4ac /chart2/qa | |
parent | 3772f18266c3347e8fd60eb8f058d65328c400b4 (diff) |
tdf#136011: move UItest to CppUnittest
Change-Id: Id8ea0fcfef8598f163febe2aa2564b0ce9d0657f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143769
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'chart2/qa')
-rw-r--r-- | chart2/qa/extras/data/ods/tdf136011.ods | bin | 0 -> 23559 bytes | |||
-rw-r--r-- | chart2/qa/extras/uichart.cxx | 72 |
2 files changed, 72 insertions, 0 deletions
diff --git a/chart2/qa/extras/data/ods/tdf136011.ods b/chart2/qa/extras/data/ods/tdf136011.ods Binary files differnew file mode 100644 index 000000000000..03a0a7dd6324 --- /dev/null +++ b/chart2/qa/extras/data/ods/tdf136011.ods diff --git a/chart2/qa/extras/uichart.cxx b/chart2/qa/extras/uichart.cxx index 2d70428a7547..a6f63fa5986d 100644 --- a/chart2/qa/extras/uichart.cxx +++ b/chart2/qa/extras/uichart.cxx @@ -197,6 +197,78 @@ CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf107097) } } +CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf136011) +{ + for (sal_Int32 nChart = 0; nChart < 2; ++nChart) + { + loadFromURL(u"ods/tdf136011.ods"); + uno::Reference<chart::XChartDocument> xChartDoc( + getChartCompFromSheet(0, nChart, 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(static_cast<sal_Int32>(3), aExpectedColumnDescriptions.getLength()); + + uno::Sequence<OUString> aExpectedRowDescriptions = xChartData->getRowDescriptions(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(9), aExpectedRowDescriptions.getLength()); + + Sequence<Sequence<double>> aExpectedData = xChartData->getData(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(9), aExpectedData.getLength()); + + uno::Sequence<beans::PropertyValue> aPropertyValues = { + comphelper::makePropertyValue("ToObject", "Object " + OUString::number(nChart + 1)), + }; + dispatchCommand(mxComponent, ".uno:GoToObject", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + // create a new document + load("private:factory/scalc"); + + dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + + uno::Reference<chart2::XChartDocument> xChartDoc2 = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc2.is()); + + uno::Reference<chart::XChartDataArray> xDataArray(xChartDoc2->getDataProvider(), + UNO_QUERY_THROW); + Sequence<OUString> aColumnDesc = xDataArray->getColumnDescriptions(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), aColumnDesc.getLength()); + for (size_t i = 0; i < 3; ++i) + CPPUNIT_ASSERT_EQUAL(aExpectedColumnDescriptions[i], aColumnDesc[i]); + + Sequence<OUString> aRowDesc = xDataArray->getRowDescriptions(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(9), aRowDesc.getLength()); + + // Without the fix in place, this test would have failed with + // - Expected: Test 1 1 + // - Actual : Test 1 + for (size_t i = 0; i < 9; ++i) + CPPUNIT_ASSERT_EQUAL(aExpectedRowDescriptions[i], aRowDesc[i]); + + Sequence<Sequence<double>> aData = xDataArray->getData(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(9), aData.getLength()); + + for (sal_Int32 nRowIdx = 0; nRowIdx < 9; ++nRowIdx) + { + for (sal_Int32 nColIdx = 0; nColIdx < 3; ++nColIdx) + { + double nValue = aData[nRowIdx][nColIdx]; + double nExpected = aExpectedData[nRowIdx][nColIdx]; + OString sMessage("Incorrect value in Col: " + OString::number(nColIdx) + + " Row: " + OString::number(nRowIdx)); + + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(sMessage.getStr(), nExpected, nValue, 1e-1); + } + } + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |