chart2/qa/extras/uichart.cxx     |   76 +++++++++++++++++++++++++++++++++++++++
 sc/qa/uitest/chart2/tdf101894.py |   67 ----------------------------------
 2 files changed, 76 insertions(+), 67 deletions(-)

New commits:
commit 1d532b15472f42bda831c5404f78f92725e66e83
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu May 4 14:06:14 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri May 5 12:43:18 2023 +0200

    tdf#101894: chart2: move UItest to CppUnittest
    
    Change-Id: I54d7376cb9b96164ed8c4526ef8f3a0502326f9d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151365
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/uitest/data/tdf101894.ods 
b/chart2/qa/extras/data/ods/tdf101894.ods
similarity index 100%
rename from sc/qa/uitest/data/tdf101894.ods
rename to chart2/qa/extras/data/ods/tdf101894.ods
diff --git a/chart2/qa/extras/uichart.cxx b/chart2/qa/extras/uichart.cxx
index 23f2223af896..1dfbfcba8b84 100644
--- a/chart2/qa/extras/uichart.cxx
+++ b/chart2/qa/extras/uichart.cxx
@@ -230,6 +230,82 @@ CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf98690)
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(12), aSeriesList2.getLength());
 }
 
+CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf101894)
+{
+    loadFromURL(u"ods/tdf101894.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>(12),
+                                 aExpectedColumnDescriptions.getLength());
+
+    uno::Sequence<OUString> aExpectedRowDescriptions = 
xChartData->getRowDescriptions();
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect number of rows in origin file",
+                                 static_cast<sal_Int32>(8), 
aExpectedRowDescriptions.getLength());
+
+    Sequence<Sequence<double>> aExpectedData = xChartData->getData();
+
+    // Create a copy of the sheet and move to the end
+    uno::Sequence<beans::PropertyValue> aArgs(
+        comphelper::InitPropertySequence({ { "DocName", 
uno::Any(OUString("tdf101894")) },
+                                           { "Index", 
uno::Any(sal_uInt16(32767)) },
+                                           { "Copy", uno::Any(true) } }));
+    dispatchCommand(mxComponent, ".uno:Move", aArgs);
+
+    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>(12), 
aColumnDescriptions.getLength());
+        for (sal_Int32 i = 0; i < 12; ++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>(8), 
aRowDescriptions.getLength());
+        for (sal_Int32 i = 0; i < 8; ++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 < 8; ++nRowIdx)
+        {
+            for (sal_Int32 nColIdx = 0; nColIdx < 12; ++nColIdx)
+            {
+                double nValue = aData[nRowIdx][nColIdx];
+                double nExpected = aExpectedData[nRowIdx][nColIdx];
+                OString sMessage("Incorrect value in Col: " + 
OString::number(nColIdx)
+                                 + " Row: " + OString::number(nRowIdx));
+
+                // Without the fix in place, this test would have failed with
+                // - Expected: 1
+                // - Actual  : 2.2250738585072e-308
+                // - Incorrect value in Col: 0 Row: 0
+                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/chart2/tdf101894.py b/sc/qa/uitest/chart2/tdf101894.py
deleted file mode 100644
index 1beca011c02e..000000000000
--- a/sc/qa/uitest/chart2/tdf101894.py
+++ /dev/null
@@ -1,67 +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_state_as_dict, get_url_for_data_file
-
-from libreoffice.uno.propertyvalue import mkPropertyValues
-
-
-class tdf101894(UITestCase):
-
-  def test_tdf101894(self):
-    with self.ui_test.load_file(get_url_for_data_file("tdf101894.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(2, len(xDS))
-            xRow.append(xDS[0].Values.SourceRangeRepresentation)
-            xRow.append(xDS[1].Values.SourceRangeRepresentation)
-            xOldSheetRanges.append(xRow)
-
-        # Rename the sheet first
-        with self.ui_test.execute_dialog_through_command(".uno:RenameTable") 
as xDialog:
-            xname_entry = xDialog.getChild("name_entry")
-
-            oldName = get_state_as_dict(xname_entry)['Text']
-            xname_entry.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
-            xname_entry.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-            xname_entry.executeAction("TYPE", 
mkPropertyValues({"TEXT":"NewName"}))
-
-        # Copy sheet and use the old name
-        with self.ui_test.execute_dialog_through_command(".uno:Move") as 
xDialog:
-            newName = xDialog.getChild("newName")
-            newName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
-            newName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-            newName.executeAction("TYPE", mkPropertyValues({"TEXT": oldName}))
-
-        xChart = calc_doc.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(2, len(xDS))
-            xRow.append(xDS[0].Values.SourceRangeRepresentation)
-            xRow.append(xDS[1].Values.SourceRangeRepresentation)
-            xNewSheetRanges.append(xRow)
-
-        self.assertEqual(xOldSheetRanges, xNewSheetRanges)
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab:

Reply via email to