summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-05-05 13:48:48 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-05-05 15:51:31 +0200
commit87cefcdce6a02044e61c3173777b4546f3ad39f6 (patch)
tree72aa966932eab7a50df7039472916ddd936b90ce /chart2
parenta86cbb0da80e0e05c041a8ddbd8e16df47638c73 (diff)
chart2: move UItest to CppUnittest
Change-Id: I4c9a2f9488a031b497c3ef87bcec9c1413002e23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151423 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/data/ods/chartWithDotInSheetName.odsbin0 -> 15057 bytes
-rw-r--r--chart2/qa/extras/uichart.cxx82
2 files changed, 82 insertions, 0 deletions
diff --git a/chart2/qa/extras/data/ods/chartWithDotInSheetName.ods b/chart2/qa/extras/data/ods/chartWithDotInSheetName.ods
new file mode 100644
index 000000000000..873d45f4be8c
--- /dev/null
+++ b/chart2/qa/extras/data/ods/chartWithDotInSheetName.ods
Binary files differ
diff --git a/chart2/qa/extras/uichart.cxx b/chart2/qa/extras/uichart.cxx
index 1dfbfcba8b84..2f5aee857e80 100644
--- a/chart2/qa/extras/uichart.cxx
+++ b/chart2/qa/extras/uichart.cxx
@@ -257,6 +257,10 @@ CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf101894)
{ "Copy", uno::Any(true) } }));
dispatchCommand(mxComponent, ".uno:Move", aArgs);
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
+ uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xIA->getCount());
+
for (sal_Int32 sheetIndex = 0; sheetIndex < 2; ++sheetIndex)
{
uno::Reference<chart::XChartDocument> xChartDoc2(
@@ -306,6 +310,84 @@ CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf101894)
}
}
+CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testCopyPasteChartWithDotInSheetName)
+{
+ loadFromURL(u"ods/chartWithDotInSheetName.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>(4),
+ aExpectedColumnDescriptions.getLength());
+
+ uno::Sequence<OUString> aExpectedRowDescriptions = xChartData->getRowDescriptions();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in origin file",
+ static_cast<sal_Int32>(7), aExpectedRowDescriptions.getLength());
+
+ Sequence<Sequence<double>> aExpectedData = xChartData->getData();
+
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:Copy", {});
+
+ uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+ { { "Name", uno::Any(OUString("NewTab")) }, { "Index", uno::Any(sal_uInt16(2)) } }));
+ dispatchCommand(mxComponent, ".uno:Insert", aArgs);
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
+ uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xIA->getCount());
+
+ dispatchCommand(mxComponent, ".uno:Paste", {});
+
+ 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>(4), aColumnDescriptions.getLength());
+ for (sal_Int32 i = 0; i < 4; ++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>(7), aRowDescriptions.getLength());
+ for (sal_Int32 i = 0; i < 7; ++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 < 7; ++nRowIdx)
+ {
+ for (sal_Int32 nColIdx = 0; nColIdx < 4; ++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: */