From f2471280c7c625e39369f76bd0efa1d2402f62bf Mon Sep 17 00:00:00 2001 From: Kevin Hunter Date: Sun, 16 Feb 2014 22:12:27 -0500 Subject: [PATCH] Test for fdo#74824. The bug in question crashed LibO when inserting a group of cells. This bug was quashed, per se, by commit 07e2c31831ad265b018e5fdf59bdde048fbb4d35, but it occurs to me that at least the particular functionality of inserting a group of cells could use more testing. Change-Id: Icdbfff86fb0265eef325bcc94d9fc9f3e9e38413 --- pyuno/Module_pyuno.mk | 1 + pyuno/PythonTest_pytests.mk | 1 + ...honTest_pyuno_pytests_insertremovecells.mk | 20 +++++ pyuno/qa/pytests/insertremovecells.py | 85 ++++++++++++++++++ pyuno/qa/pytests/testdocuments/fdo74824.ods | Bin 0 -> 4811 bytes 5 files changed, 107 insertions(+) create mode 100644 pyuno/PythonTest_pyuno_pytests_insertremovecells.mk create mode 100644 pyuno/qa/pytests/insertremovecells.py create mode 100644 pyuno/qa/pytests/testdocuments/fdo74824.ods diff --git a/pyuno/Module_pyuno.mk b/pyuno/Module_pyuno.mk index 31c831a2e1d4..b79c21d458b9 100644 --- a/pyuno/Module_pyuno.mk +++ b/pyuno/Module_pyuno.mk @@ -63,6 +63,7 @@ endif # SYSTEM_PYTHON ifneq (,$(filter PythonTest_pytests,$(MAKECMDGOALS))) $(eval $(call gb_Module_add_targets,pyuno, \ PythonTest_pytests \ + PythonTest_pyuno_pytests_insertremovecells \ )) endif diff --git a/pyuno/PythonTest_pytests.mk b/pyuno/PythonTest_pytests.mk index afb4ba52291a..63ffbb67731c 100644 --- a/pyuno/PythonTest_pytests.mk +++ b/pyuno/PythonTest_pytests.mk @@ -24,5 +24,6 @@ $(eval $(call gb_PythonTest_PythonTest,pytests)) $(call gb_PythonTest_get_target,pytests) : \ + $(call gb_PythonTest_get_target,pyuno_pytests_insertremovecells) \ # vim: set noet sw=4 ts=4: diff --git a/pyuno/PythonTest_pyuno_pytests_insertremovecells.mk b/pyuno/PythonTest_pyuno_pytests_insertremovecells.mk new file mode 100644 index 000000000000..3b3e3c0988ee --- /dev/null +++ b/pyuno/PythonTest_pyuno_pytests_insertremovecells.mk @@ -0,0 +1,20 @@ +# -*- 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_PythonTest_PythonTest,pyuno_pytests_insertremovecells)) + +$(eval $(call gb_PythonTest_set_defs,pyuno_pytests_insertremovecells,\ + TDOC="$(SRCDIR)/pyuno/qa/pytests/testdocuments" \ +)) + +$(eval $(call gb_PythonTest_add_modules,pyuno_pytests_insertremovecells,$(SRCDIR)/pyuno/qa/pytests,\ + insertremovecells \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/pyuno/qa/pytests/insertremovecells.py b/pyuno/qa/pytests/insertremovecells.py new file mode 100644 index 000000000000..4ce2707602bc --- /dev/null +++ b/pyuno/qa/pytests/insertremovecells.py @@ -0,0 +1,85 @@ +import unittest + +from os import getenv, path + +try: + from urllib.parse import quote +except ImportError: + from urllib import quote + +from org.libreoffice.unotest import pyuno, mkPropertyValue + +class InsertRemoveCells(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.xContext = pyuno.getComponentContext() + pyuno.experimentalExtraMagic() + + + # no need for a tearDown(cls) method. + + + def test_fdo74824_load(self): + ctxt = self.xContext + assert(ctxt) + + smgr = ctxt.ServiceManager + desktop = smgr.createInstanceWithContext('com.sun.star.frame.Desktop', ctxt) + loadProps = tuple(mkPropertyValue(k, v) for (k, v) in ( + ('Hidden', True), + ('ReadOnly', False) + )) + tdoc_dir = getenv('TDOC') + url = 'file://' + quote(path.join(tdoc_dir, 'fdo74824.ods')) + doc = desktop.loadComponentFromURL(url, "_blank", 0, loadProps) + + sheet = doc.Sheets.Sheet1 + area = sheet.getCellRangeByName( 'A2:B4' ) + addr = area.getRangeAddress() + + # 2 = intended to shift cells right, but I don't know where to find + # the ENUM to put in it's place. Corrections welcome. + sheet.insertCells( addr, 2 ) + + # basically, the insertCells call is the test: it should not crash + # LibreOffice. However, for completeness, we should test the cell + # contents as well. + + empty_cells = ( + (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), + (3, 1), (4, 0), (4, 2), (5, 0), (5, 2), (5, 3), + ) + formula_cells = ( + (2, 0, '=(1+GDR)^-D1', '1.000', 1.0), + (4, 1, '=(1+GDR)^-F2', '0.125', 0.125), + (4, 3, '=SUM(C1:C2)', '1.000', 1.0), + ) + value_cells = ( + (2, 2, '2010', 2010.0), + (2, 3, '7', 7.0), + (3, 0, '0', 0), + (3, 2, '2012', 2012.0), + (3, 3, '6', 6.0), + (5, 1, '1', 1.0), + ) + for pos in empty_cells: + cell = sheet.getCellByPosition(*pos) + self.assertEqual( 'EMPTY', cell.Type.value ) + for x, y, f, s, val in formula_cells: + cell = sheet.getCellByPosition(x, y) + self.assertEqual( 'FORMULA', cell.Type.value ) + self.assertEqual( f, cell.getFormula() ) + self.assertEqual( s, cell.String ) + self.assertEqual( val, cell.Value ) + for x, y, s, val in value_cells: + cell = sheet.getCellByPosition(x, y) + self.assertEqual( s, cell.String ) + self.assertEqual( val, cell.Value ) + + doc.close( True ) + + +if __name__ == '__main__': + unittest.main() + diff --git a/pyuno/qa/pytests/testdocuments/fdo74824.ods b/pyuno/qa/pytests/testdocuments/fdo74824.ods new file mode 100644 index 0000000000000000000000000000000000000000..122bae22d9d45e0f282b4c734ae4f294976ee0da GIT binary patch literal 4811 zcmaKwbyQUA-^CA|0ulq#A`USlA>AzvBMj0a7Y0EZhLVP%LWbRZ36;e)w#A!g2(N#K4R^PGYh-UHHH(qZJz02X{ z)9Vn)3CoKlw@bJm@#kEyxzI-fF&yaV%xarhet(okPw>hmZKt$IK%f1C*2h+%vL5S| zypqE6&;>Q>)T?mI)MDs@h)w2=m0bPRZkY!w4+u+4D=W&jZiewPt;y3nw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