summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2013-06-15 17:11:51 +0200
committerNoel Power <noel.power@suse.com>2013-06-18 09:23:20 +0000
commit6e8eb540c8cfe1bf663c8e4cc15e484f0d8ea0b2 (patch)
treeee49b38ac245c3209c82d85e5452c8cb2ac4acc1 /sw
parentb9155a663b767695c5d636e855765c209944cfd5 (diff)
Migrate CheckFields unit test to python
Change-Id: Ia765b37888b4095a735015e792f06fc89201d1a3 Reviewed-on: https://gerrit.libreoffice.org/4294 Reviewed-by: Noel Power <noel.power@suse.com> Tested-by: Noel Power <noel.power@suse.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/PythonTest_sw_python.mk5
-rw-r--r--sw/qa/python/check_fields.py46
2 files changed, 51 insertions, 0 deletions
diff --git a/sw/PythonTest_sw_python.mk b/sw/PythonTest_sw_python.mk
index 0b582a2b1c05..94212491f444 100644
--- a/sw/PythonTest_sw_python.mk
+++ b/sw/PythonTest_sw_python.mk
@@ -9,8 +9,13 @@
$(eval $(call gb_PythonTest_PythonTest,sw_python))
+$(eval $(call gb_PythonTest_set_defs,sw_python,\
+ TDOC="$(SRCDIR)/sw/qa/complex/writer/testdocuments" \
+))
+
$(eval $(call gb_PythonTest_add_modules,sw_python,$(SRCDIR)/sw/qa/python,\
check_index \
+ check_fields \
get_expression \
set_expression \
var_fields \
diff --git a/sw/qa/python/check_fields.py b/sw/qa/python/check_fields.py
new file mode 100644
index 000000000000..5a3c2b74f0fc
--- /dev/null
+++ b/sw/qa/python/check_fields.py
@@ -0,0 +1,46 @@
+import unittest
+from org.libreoffice.unotest import UnoInProcess
+
+class CheckFields(unittest.TestCase):
+ _uno = None
+ _xDoc = None
+
+ @classmethod
+ def setUpClass(cls):
+ cls._uno = UnoInProcess()
+ cls._uno.setUp()
+ cls._xDoc = cls._uno.openWriterTemplateDoc("fdo39694.ott")
+ cls._xEmptyDoc = cls._uno.openEmptyWriterDoc()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls._uno.tearDown()
+
+ def test_fdo39694_load(self):
+ placeholders = ["<Kadr1>", "<Kadr2>", "<Kadr3>", "<Kadr4>", "<Pnname>", "<Pvname>", "<Pgeboren>"]
+ xDoc = self.__class__._xDoc
+ xEnumerationAccess = xDoc.getTextFields()
+ xFieldEnum = xEnumerationAccess.createEnumeration()
+ while xFieldEnum.hasMoreElements():
+ xField = xFieldEnum.nextElement()
+ if xField.supportsService("com.sun.star.text.TextField.JumpEdit"):
+ xAnchor = xField.getAnchor()
+ readContent = xAnchor.getString()
+ self.assertTrue(readContent in placeholders,
+ "field %s is not contained: " % readContent)
+
+ def test_fdo42073(self):
+ xDoc = self.__class__._xEmptyDoc
+ xBodyText = xDoc.getText()
+ xCursor = xBodyText.createTextCursor()
+ xTextField = xDoc.createInstance("com.sun.star.text.TextField.Input")
+ xBodyText.insertTextContent(xCursor, xTextField, True)
+ readContent = xTextField.getPropertyValue("Content")
+ self.assertEqual("", readContent)
+ content = "this is not surprising"
+ xTextField.setPropertyValue("Content", content)
+ readContent = xTextField.getPropertyValue("Content")
+ self.assertEqual(content, readContent)
+
+if __name__ == '__main__':
+ unittest.main()