chart2/qa/extras/uichart.cxx | 82 ++++++++++++++++++++++++++++++++++++++++ sc/qa/uitest/chart/copyPaste.py | 70 ---------------------------------- 2 files changed, 82 insertions(+), 70 deletions(-)
New commits: commit 87cefcdce6a02044e61c3173777b4546f3ad39f6 Author: Xisco Fauli <[email protected]> AuthorDate: Fri May 5 13:48:48 2023 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Fri May 5 15:51:31 2023 +0200 chart2: move UItest to CppUnittest Change-Id: I4c9a2f9488a031b497c3ef87bcec9c1413002e23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151423 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sc/qa/uitest/data/chartWithDotInSheetName.ods b/chart2/qa/extras/data/ods/chartWithDotInSheetName.ods similarity index 100% rename from sc/qa/uitest/data/chartWithDotInSheetName.ods rename to chart2/qa/extras/data/ods/chartWithDotInSheetName.ods 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: */ diff --git a/sc/qa/uitest/chart/copyPaste.py b/sc/qa/uitest/chart/copyPaste.py deleted file mode 100644 index fe58d59917c8..000000000000 --- a/sc/qa/uitest/chart/copyPaste.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -from uitest.framework import UITestCase -from uitest.uihelper.common import get_url_for_data_file - -from libreoffice.uno.propertyvalue import mkPropertyValues - - -class CopyPaste(UITestCase): - - def test_copy_paste_chart_with_dot_in_sheet_name(self): - with self.ui_test.load_file(get_url_for_data_file("chartWithDotInSheetName.ods")) as calc_doc: - - xChart = calc_doc.Sheets[0].Charts[0] - xDataSeries = xChart.getEmbeddedObject().getFirstDiagram().CoordinateSystems[0].ChartTypes[0].DataSeries - - self.assertEqual(4, len(xDataSeries)) - - xOldSheetRanges = [] - for i in range(4): - xRow = [] - xDS = xDataSeries[i].DataSequences - - self.assertEqual(1, len(xDS)) - xRow.append(xDS[0].Values.SourceRangeRepresentation) - xOldSheetRanges.append(xRow) - - self.xUITest.executeCommand(".uno:SelectAll") - - self.xUITest.executeCommand(".uno:Copy") - - with self.ui_test.load_empty_file("calc") as calc_document: - - # Rename the sheet to match the same name as the first document - with self.ui_test.execute_dialog_through_command(".uno:RenameTable") as xDialog: - xname_entry = xDialog.getChild("name_entry") - - xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"Sheet.1"})) - - self.xUITest.executeCommand(".uno:Paste") - - xChart = calc_document.Sheets[0].Charts[0] - xDataSeries = xChart.getEmbeddedObject().getFirstDiagram().CoordinateSystems[0].ChartTypes[0].DataSeries - - self.assertEqual(4, len(xDataSeries)) - - xNewSheetRanges = [] - for i in range(4): - xRow = [] - xDS = xDataSeries[i].DataSequences - - self.assertEqual(1, len(xDS)) - xRow.append(xDS[0].Values.SourceRangeRepresentation) - xNewSheetRanges.append(xRow) - - # Without the fix in place, this test would have failed with - # ["$'Sheet.1'.$B$12:$B$18"] - # ["'file:///home/<user>/Documents/Sheet.1'#$Sheet1.$B$12:$B$18"] - self.assertEqual(xOldSheetRanges, xNewSheetRanges) - -# vim: set shiftwidth=4 softtabstop=4 expandtab:
