summaryrefslogtreecommitdiff
path: root/chart2/qa/extras
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-11-28 13:15:07 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-11-28 14:19:17 +0100
commitf97556dc0bdf9b4593fab78ef205972bf89b4af3 (patch)
treee648ea32bff7e21e66935e499d6d91702517d0c9 /chart2/qa/extras
parent2f4e1180b3a616c234d0de7db8cea7c682777243 (diff)
CppunitTest_chart2_uichart: simplify test a bit
Change-Id: I9d25adb68dac446c7e2e013684ceff48eaf23e52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143383 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'chart2/qa/extras')
-rw-r--r--chart2/qa/extras/uichart.cxx42
1 files changed, 15 insertions, 27 deletions
diff --git a/chart2/qa/extras/uichart.cxx b/chart2/qa/extras/uichart.cxx
index 19cd9fc3662f..8bea8dbefef4 100644
--- a/chart2/qa/extras/uichart.cxx
+++ b/chart2/qa/extras/uichart.cxx
@@ -12,8 +12,6 @@
#include <comphelper/propertyvalue.hxx>
#include <vcl/scheduler.hxx>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-
using namespace ::com::sun::star;
class Chart2UiChartTest : public ChartTest
@@ -28,25 +26,16 @@ public:
CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf120348)
{
loadFromURL(u"ods/tdf120348.ods");
- uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+ uno::Reference<chart::XChartDocument> xChartDoc(getChartCompFromSheet(0, mxComponent),
+ uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(xChartDoc.is());
+ uno::Reference<chart::XChartDataArray> xChartData(xChartDoc->getData(), uno::UNO_QUERY_THROW);
- uno::Reference<sheet::XSpreadsheetDocument> xDocument(mxComponent, uno::UNO_QUERY_THROW);
- uno::Reference<container::XIndexAccess> xIndex(xDocument->getSheets(), uno::UNO_QUERY_THROW);
- uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
+ uno::Sequence<OUString> aExpectedSeriesList = xChartData->getColumnDescriptions();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aExpectedSeriesList.getLength());
- std::vector<std::vector<double>> aExpected;
-
- for (sal_Int32 nRowIdx = 1; nRowIdx < 159; ++nRowIdx)
- {
- std::vector<double> aRow;
- for (sal_Int32 nColIdx = 5; nColIdx < 9; ++nColIdx)
- {
- uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(nColIdx, nRowIdx);
- aRow.push_back(xCell->getValue());
- }
- aExpected.push_back(aRow);
- }
+ Sequence<Sequence<double>> aExpectedData = xChartData->getData();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(158), aExpectedData.getLength());
uno::Sequence<beans::PropertyValue> aPropertyValues = {
comphelper::makePropertyValue("ToObject", OUString("Object 2")),
@@ -63,17 +52,16 @@ CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf120348)
dispatchCommand(mxComponent, ".uno:Paste", {});
Scheduler::ProcessEventsToIdle();
- xChartDoc = getChartDocFromSheet(0, mxComponent);
- CPPUNIT_ASSERT(xChartDoc.is());
+ uno::Reference<chart2::XChartDocument> xChartDoc2 = getChartDocFromSheet(0, mxComponent);
+ CPPUNIT_ASSERT(xChartDoc2.is());
- uno::Reference<chart::XChartDataArray> xDataArray(xChartDoc->getDataProvider(),
+ uno::Reference<chart::XChartDataArray> xDataArray(xChartDoc2->getDataProvider(),
UNO_QUERY_THROW);
Sequence<OUString> aColumnDesc = xDataArray->getColumnDescriptions();
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aColumnDesc.getLength());
- CPPUNIT_ASSERT_EQUAL(OUString("Finland"), aColumnDesc[0]);
- CPPUNIT_ASSERT_EQUAL(OUString("Sweden"), aColumnDesc[1]);
- CPPUNIT_ASSERT_EQUAL(OUString("Poland"), aColumnDesc[2]);
- CPPUNIT_ASSERT_EQUAL(OUString(""), aColumnDesc[3]);
+ for (size_t i = 0; i < 4; ++i)
+ CPPUNIT_ASSERT_EQUAL(aExpectedSeriesList[i], aColumnDesc[i]);
+
Sequence<Sequence<double>> aData = xDataArray->getData();
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(158), aData.getLength());
@@ -82,14 +70,14 @@ CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf120348)
for (sal_Int32 nColIdx = 0; nColIdx < 4; ++nColIdx)
{
double nValue = aData[nRowIdx][nColIdx];
- double nExpected = aExpected[nRowIdx][nColIdx];
+ double nExpected = aExpectedData[nRowIdx][nColIdx];
OString sMessage("Incorrect value in Col: " + OString::number(nColIdx)
+ " Row: " + OString::number(nRowIdx));
if (std::isnan(nValue))
{
// On paste, 0 becomes NaN, check whether it's expected
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), 0.0, nExpected);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(sMessage.getStr(), 0.0, nExpected, 1e-1);
}
else
{