[Libreoffice-commits] core.git: 2 commits - pyuno/Module_pyuno.mk pyuno/PythonTest_pytests.mk pyuno/PythonTest_pyuno_pytests_insertremovecells.mk pyuno/qa

Kevin Hunter hunteke at earlham.edu
Thu Feb 20 03:02:07 PST 2014


 pyuno/Module_pyuno.mk                               |    7 +
 pyuno/PythonTest_pytests.mk                         |   29 ++++++
 pyuno/PythonTest_pyuno_pytests_insertremovecells.mk |   20 ++++
 pyuno/qa/pytests/insertremovecells.py               |   85 ++++++++++++++++++++
 pyuno/qa/pytests/testdocuments/fdo74824.ods         |binary
 5 files changed, 141 insertions(+)

New commits:
commit f2471280c7c625e39369f76bd0efa1d2402f62bf
Author: Kevin Hunter <hunteke at earlham.edu>
Date:   Sun Feb 16 22:12:27 2014 -0500

    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

diff --git a/pyuno/Module_pyuno.mk b/pyuno/Module_pyuno.mk
index 31c831a..b79c21d 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 afb4ba5..63ffbb6 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 0000000..3b3e3c0
--- /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 0000000..4ce2707
--- /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 0000000..122bae2
Binary files /dev/null and b/pyuno/qa/pytests/testdocuments/fdo74824.ods differ
commit 4e887567c5b4b06646ab1340376e240d6c5af9cb
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Feb 20 11:53:01 2014 +0100

    A rudimentary framework for additional Python tests not run by default
    
    * see the mail thread starting at
      <http://lists.freedesktop.org/archives/libreoffice/2014-February/059548.html>
      "Testing/Working on PyUNO?" for a rationale
    
    * run the tests via top-level "make PythonTest_pytests" or "cd pyuno && make -rs
      PythonTest_pytests" or similar
    
    * see the documentation in pyuno/PythonTest_pytests.mk for adding tests to the
      framework
    
    Change-Id: I6a2a9e60b3294cd649f9cccbaffbd3f6bd79ecff

diff --git a/pyuno/Module_pyuno.mk b/pyuno/Module_pyuno.mk
index 28aef71..31c831a 100644
--- a/pyuno/Module_pyuno.mk
+++ b/pyuno/Module_pyuno.mk
@@ -60,6 +60,12 @@ endif
 
 endif # SYSTEM_PYTHON
 
+ifneq (,$(filter PythonTest_pytests,$(MAKECMDGOALS)))
+$(eval $(call gb_Module_add_targets,pyuno, \
+    PythonTest_pytests \
+))
+endif
+
 endif # DISABLE_PYTHON
 
 # vim:set noet sw=4 ts=4:
diff --git a/pyuno/PythonTest_pytests.mk b/pyuno/PythonTest_pytests.mk
new file mode 100644
index 0000000..afb4ba5
--- /dev/null
+++ b/pyuno/PythonTest_pytests.mk
@@ -0,0 +1,28 @@
+# -*- 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/.
+#
+
+# Dummy .mk to have a single "make PythonTest_pytests" goal to run all the
+# pyuno/PythonTest_pyuno_pytests_*.mk tests (which are not run by default).
+#
+# To add a new test pyuno/PythonTest_pyuno_pytests_NEW.mk, add
+#
+#   $(call gb_PythonTest_get_target,pyuno_pytests_NEW) \
+#
+# to the below list and
+#
+#   PythonTest_pyuno_pytests_NEW \
+#
+# to the list in the "ifneq (,$(filter PythonTest_pytests,$(MAKECMDGOALS)))"
+# section of pyuno/Module_pyuno.mk.
+
+$(eval $(call gb_PythonTest_PythonTest,pytests))
+
+$(call gb_PythonTest_get_target,pytests) : \
+
+# vim: set noet sw=4 ts=4:


More information about the Libreoffice-commits mailing list