summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/CppunitTest_chart2_uichart.mk58
-rw-r--r--chart2/Module_chart2.mk1
-rw-r--r--chart2/qa/extras/data/ods/tdf120348.ods (renamed from sc/qa/uitest/data/tdf120348.ods)bin43612 -> 43612 bytes
-rw-r--r--chart2/qa/extras/uichart.cxx108
-rw-r--r--sc/qa/uitest/chart2/tdf120348.py61
5 files changed, 167 insertions, 61 deletions
diff --git a/chart2/CppunitTest_chart2_uichart.mk b/chart2/CppunitTest_chart2_uichart.mk
new file mode 100644
index 000000000000..9e464e0a7c6f
--- /dev/null
+++ b/chart2/CppunitTest_chart2_uichart.mk
@@ -0,0 +1,58 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,chart2_uichart))
+
+$(eval $(call gb_CppunitTest_use_externals,chart2_uichart, \
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,chart2_uichart, \
+ chart2/qa/extras/uichart \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,chart2_uichart, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ i18nlangtag \
+ sal \
+ sc \
+ sfx \
+ subsequenttest \
+ svl \
+ svl \
+ svx \
+ svxcore \
+ test \
+ tl \
+ unotest \
+ utl \
+ vcl \
+))
+
+$(eval $(call gb_CppunitTest_set_include,chart2_uichart,\
+ -I$(SRCDIR)/chart2/qa/extras \
+ -I$(SRCDIR)/chart2/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,chart2_uichart))
+
+$(eval $(call gb_CppunitTest_use_ure,chart2_uichart))
+$(eval $(call gb_CppunitTest_use_vcl,chart2_uichart))
+
+$(eval $(call gb_CppunitTest_use_rdb,chart2_uichart,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,chart2_uichart))
+
+# vim: set noet sw=4 ts=4:
diff --git a/chart2/Module_chart2.mk b/chart2/Module_chart2.mk
index 1a26ebd2b959..5f7fd5aee961 100644
--- a/chart2/Module_chart2.mk
+++ b/chart2/Module_chart2.mk
@@ -37,6 +37,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,chart2,\
CppunitTest_chart2_dump \
CppunitTest_chart2_pivot_chart_test \
CppunitTest_chart2_geometry \
+ CppunitTest_chart2_uichart \
))
ifeq ($(WITH_FONTS), TRUE)
diff --git a/sc/qa/uitest/data/tdf120348.ods b/chart2/qa/extras/data/ods/tdf120348.ods
index 7a593c1bff7b..7a593c1bff7b 100644
--- a/sc/qa/uitest/data/tdf120348.ods
+++ b/chart2/qa/extras/data/ods/tdf120348.ods
Binary files differ
diff --git a/chart2/qa/extras/uichart.cxx b/chart2/qa/extras/uichart.cxx
new file mode 100644
index 000000000000..b6e2cb417643
--- /dev/null
+++ b/chart2/qa/extras/uichart.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#include "charttest.hxx"
+
+#include <comphelper/propertyvalue.hxx>
+#include <vcl/scheduler.hxx>
+
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+
+using namespace ::com::sun::star;
+
+class Chart2UiChartTest : public ChartTest
+{
+public:
+ Chart2UiChartTest()
+ : ChartTest("/chart2/qa/extras/data/")
+ {
+ }
+};
+
+CPPUNIT_TEST_FIXTURE(Chart2UiChartTest, testTdf120348)
+{
+ loadFromURL(u"ods/tdf120348.ods");
+ uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDocument(mxComponent, uno::UNO_QUERY_THROW);
+ uno::Reference<container::XIndexAccess> xIndex(xDocument->getSheets(), uno::UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
+
+ std::vector<std::vector<double>> aExpected;
+
+ for (sal_Int32 nRowIdx = 1; nRowIdx < 159; ++nRowIdx)
+ {
+ std::vector<double> aRow;
+ for (sal_Int32 nColIdx = 5; nColIdx < 9; ++nColIdx)
+ {
+ uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(nColIdx, nRowIdx);
+ aRow.push_back(xCell->getValue());
+ }
+ aExpected.push_back(aRow);
+ }
+
+ uno::Sequence<beans::PropertyValue> aPropertyValues = {
+ comphelper::makePropertyValue("ToObject", OUString("Object 2")),
+ };
+ 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();
+
+ xChartDoc = getChartDocFromSheet(0, mxComponent);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ uno::Reference<chart::XChartDataArray> xDataArray(xChartDoc->getDataProvider(),
+ UNO_QUERY_THROW);
+ Sequence<OUString> aColumnDesc = xDataArray->getColumnDescriptions();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aColumnDesc.getLength());
+ CPPUNIT_ASSERT_EQUAL(OUString("Finland"), aColumnDesc[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Sweden"), aColumnDesc[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("Poland"), aColumnDesc[2]);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), aColumnDesc[3]);
+ Sequence<Sequence<double>> aData = xDataArray->getData();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(158), aData.getLength());
+
+ for (sal_Int32 nRowIdx = 0; nRowIdx < 158; ++nRowIdx)
+ {
+ for (sal_Int32 nColIdx = 0; nColIdx < 4; ++nColIdx)
+ {
+ double nValue = aData[nRowIdx][nColIdx];
+ double nExpected = aExpected[nRowIdx][nColIdx];
+ OString sMessage("Incorrect value in Col: " + OString::number(nColIdx)
+ + " Row: " + OString::number(nRowIdx));
+
+ if (std::isnan(nValue))
+ {
+ // On paste, 0 becomes NaN, check whether it's expected
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), 0.0, nExpected);
+ }
+ else
+ {
+ // Without the fix in place, this test would have failed with
+ // - Expected: 0
+ // - Actual : 3.33625955201419
+ // - Incorrect value in Col: 2 Row: 51
+ 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/tdf120348.py b/sc/qa/uitest/chart2/tdf120348.py
deleted file mode 100644
index 9f3a6483705d..000000000000
--- a/sc/qa/uitest/chart2/tdf120348.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 uitest.uihelper.common import get_url_for_data_file
-
-from libreoffice.calc.document import get_cell_by_position
-from libreoffice.uno.propertyvalue import mkPropertyValues
-
-
-class tdf120348(UITestCase):
-
- def test_tdf120348(self):
-
- with self.ui_test.load_file(get_url_for_data_file("tdf120348.ods")) as calc_doc:
- xCalcDoc = self.xUITest.getTopFocusWindow()
- gridwin = xCalcDoc.getChild("grid_window")
-
- xFirstMatrix = []
- for row in range(1, 159):
- xRow = []
- for column in range(5, 9):
- xRow.append(round(get_cell_by_position(calc_doc, 0, column, row).getValue(), 5))
- xFirstMatrix.append(xRow)
-
- gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 2"}))
-
- 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
-
- columnNames = ('Finland', 'Sweden', 'Poland', '')
- self.assertEqual(columnNames, xData.ColumnDescriptions)
-
- xSecondMatrix = []
- for row in xData.Data:
- xRow = []
- for value in row:
- xRow.append(round(value, 5))
- xSecondMatrix.append(xRow)
-
- # Without the fix in place, this test would have failed with
- # First differing element 51:
- # [3.31618, 3.65089, 3.33626, 0.0]
- # [3.31618, 3.65089, 0.0, 0.0]
-
- self.assertEqual(xFirstMatrix, xSecondMatrix)
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab: