summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-03-05 12:46:42 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2024-03-05 14:15:19 +0100
commitf03cb8214a2b1b3de8d93c1a19319ecc82e4b21d (patch)
tree172c8bd0b7130e5b88fe641b8e860248c08a6db8
parentace72e8c606aa5f32a425b4afa965a68a854bc85 (diff)
tdf#99969: chart2_uichart: Add unittest
Change-Id: Iddf64e07b4f6ee6913965b294d8a41904d2fc558 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164418 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--chart2/qa/extras/data/ods/tdf99969.odsbin0 -> 14472 bytes
-rw-r--r--chart2/qa/extras/uichart.cxx75
2 files changed, 75 insertions, 0 deletions
diff --git a/chart2/qa/extras/data/ods/tdf99969.ods b/chart2/qa/extras/data/ods/tdf99969.ods
new file mode 100644
index 000000000000..f30212ec73b4
--- /dev/null
+++ b/chart2/qa/extras/data/ods/tdf99969.ods
Binary files differ
diff --git a/chart2/qa/extras/uichart.cxx b/chart2/qa/extras/uichart.cxx
index 2638367c8506..e2f3d9a9d0b3 100644
--- a/chart2/qa/extras/uichart.cxx
+++ b/chart2/qa/extras/uichart.cxx
@@ -104,6 +104,81 @@ void Chart2UiChartTest::testCopyPasteToNewSheet(uno::Reference<chart::XChartDocu
}
}
+CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf99969)
+{
+ loadFromFile(u"ods/tdf99969.ods");
+ uno::Reference<chart::XChartDocument> xChartDoc(getChartCompFromSheet(0, 0, mxComponent),
+ uno::UNO_QUERY_THROW);
+ sal_Int32 nColumns = 2;
+ sal_Int32 nRows = 6;
+ 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", nColumns,
+ aExpectedColumnDescriptions.getLength());
+
+ uno::Sequence<OUString> aExpectedRowDescriptions = xChartData->getRowDescriptions();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in origin file", nRows,
+ aExpectedRowDescriptions.getLength());
+
+ Sequence<Sequence<double>> aExpectedData = xChartData->getData();
+
+ dispatchCommand(mxComponent, ".uno:GoToCell",
+ { comphelper::makePropertyValue("ToPoint", uno::Any(OUString("C2:L25"))) });
+
+ dispatchCommand(mxComponent, ".uno:Copy", {});
+
+ // create a new document
+ load("private:factory/scalc");
+
+ dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ 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_MESSAGE("Incorrect number of columns in destination file", nColumns,
+ aColumnDesc.getLength());
+ for (sal_Int32 i = 0; i < nColumns; ++i)
+ {
+ // Without the fix in place, this test would have failed with
+ // - Expected: ABC
+ // - Actual :
+ // - Incorrect description in column: 0
+ OString sMessage("Incorrect description in column: " + OString::number(i));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), aExpectedColumnDescriptions[i],
+ aColumnDesc[i]);
+ }
+
+ Sequence<OUString> aRowDesc = xDataArray->getRowDescriptions();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in destination file", nRows,
+ aRowDesc.getLength());
+ for (sal_Int32 i = 0; i < nRows; ++i)
+ {
+ OString sMessage("Incorrect description in row: " + OString::number(i));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), aExpectedRowDescriptions[i], aRowDesc[i]);
+ }
+
+ Sequence<Sequence<double>> aData = xDataArray->getData();
+
+ for (sal_Int32 nRowIdx = 0; nRowIdx < nRows; ++nRowIdx)
+ {
+ for (sal_Int32 nColIdx = 0; nColIdx < nColumns; ++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_EQUAL_MESSAGE(sMessage.getStr(), nExpected, nValue);
+ }
+ }
+}
+
CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf120348)
{
loadFromFile(u"ods/tdf120348.ods");