diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-28 14:23:31 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-28 20:48:35 +0100 |
commit | e16daa6079f703c87e19904e7bb85e5fd9beac7c (patch) | |
tree | bc77af229da7658148aeb831d5921fb0b23589f7 | |
parent | 730e7a9194a58613a47867839cef0870d52d8d6d (diff) |
tdf#107097: move UItest to CppUniTest
Change-Id: I81834b8316b19baad55122cc06a481d55fb6244a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143401
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | chart2/qa/extras/data/ods/tdf107097.ods (renamed from sc/qa/uitest/data/tdf107097.ods) | bin | 17945 -> 17945 bytes | |||
-rw-r--r-- | chart2/qa/extras/uichart.cxx | 64 | ||||
-rw-r--r-- | sc/qa/uitest/chart2/tdf107097.py | 61 |
3 files changed, 64 insertions, 61 deletions
diff --git a/sc/qa/uitest/data/tdf107097.ods b/chart2/qa/extras/data/ods/tdf107097.ods Binary files differindex efa9f1c013f3..efa9f1c013f3 100644 --- a/sc/qa/uitest/data/tdf107097.ods +++ b/chart2/qa/extras/data/ods/tdf107097.ods diff --git a/chart2/qa/extras/uichart.cxx b/chart2/qa/extras/uichart.cxx index 8bea8dbefef4..296677a7d046 100644 --- a/chart2/qa/extras/uichart.cxx +++ b/chart2/qa/extras/uichart.cxx @@ -133,6 +133,70 @@ CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf151091) CPPUNIT_ASSERT_EQUAL(aExpected[i], aSeriesList[i]); } +CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf107097) +{ + loadFromURL(u"ods/tdf107097.ods"); + uno::Reference<chart::XChartDocument> xChartDoc(getPivotChartDocFromSheet(1, 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(static_cast<sal_Int32>(4), aExpectedColumnDescriptions.getLength()); + + uno::Sequence<OUString> aExpectedRowDescriptions = xChartData->getRowDescriptions(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(12), aExpectedRowDescriptions.getLength()); + + Sequence<Sequence<double>> aExpectedData = xChartData->getData(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(12), aExpectedData.getLength()); + + uno::Sequence<beans::PropertyValue> aPropertyValues = { + comphelper::makePropertyValue("ToObject", OUString("Object 1")), + }; + dispatchCommand(mxComponent, ".uno:GoToObject", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + // create a new document + load("private:factory/scalc"); + + dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + + 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(static_cast<sal_Int32>(4), aColumnDesc.getLength()); + for (size_t i = 0; i < 4; ++i) + CPPUNIT_ASSERT_EQUAL(aExpectedColumnDescriptions[i], aColumnDesc[i]); + + Sequence<OUString> aRowDesc = xDataArray->getRowDescriptions(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(12), aRowDesc.getLength()); + for (size_t i = 0; i < 12; ++i) + CPPUNIT_ASSERT_EQUAL(aExpectedRowDescriptions[i], aRowDesc[i]); + + Sequence<Sequence<double>> aData = xDataArray->getData(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(12), aData.getLength()); + + for (sal_Int32 nRowIdx = 0; nRowIdx < 12; ++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/chart2/tdf107097.py b/sc/qa/uitest/chart2/tdf107097.py deleted file mode 100644 index 53ba438ecea5..000000000000 --- a/sc/qa/uitest/chart2/tdf107097.py +++ /dev/null @@ -1,61 +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 libreoffice.calc.document import get_cell_by_position -from libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.uihelper.common import get_url_for_data_file - -# Test pivot chart is pasted correctly to a new document - -class tdf107097(UITestCase): - - def test_tdf107097(self): - with self.ui_test.load_file(get_url_for_data_file("tdf107097.ods")) as calc_doc: - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - - - xFirstMatrix = [] - for row in range(6, 18): - xRow = [] - for column in range(3, 7): - xRow.append(get_cell_by_position(calc_doc, 1, column, row).getValue()) - xFirstMatrix.append(xRow) - - gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) - - self.xUITest.executeCommand(".uno:Copy") - - with self.ui_test.load_empty_file("calc") as calc_document: - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - - self.xUITest.executeCommand(".uno:Paste") - - xData = calc_document.Sheets[0].Charts[0].getEmbeddedObject().Data - - xSecondMatrix = [] - for row in xData.Data: - xRow = [] - for value in row: - xRow.append(value) - xSecondMatrix.append(xRow) - - self.assertEqual(xFirstMatrix, xSecondMatrix) - - aExpectedColumnDescriptions = ('Sum - Sales T1', 'Sum - Sales T2', - 'Sum - Sales T3', 'Sum - Sales T4') - aExpectedRowDescriptions = ('DE Berlin A', 'DE Berlin B', 'DE Munich A', - 'DE Munich B', 'EN Glasgow A', 'EN Liverpool B', 'EN London A', - 'EN London B', 'FR Nantes A', 'FR Nantes B', 'FR Paris A', 'FR Paris B') - - self.assertEqual(aExpectedColumnDescriptions, xData.ColumnDescriptions) - self.assertEqual(aExpectedRowDescriptions, xData.RowDescriptions) - -# vim: set shiftwidth=4 softtabstop=4 expandtab: |