Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / python / check_fields.py
blobeb6dd2dc1c8a1cffc87db9cc39ad710132ea5798
1 #! /usr/bin/env python
2 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 import unittest
11 from org.libreoffice.unotest import UnoInProcess
14 class CheckFields(unittest.TestCase):
16 @classmethod
17 def setUpClass(cls):
18 cls._uno = UnoInProcess()
19 cls._uno.setUp()
21 @classmethod
22 def tearDownClass(cls):
23 cls._uno.tearDown()
25 def test_fdo39694_load(self):
26 placeholders = ["<Kadr1>", "<Kadr2>", "<Kadr3>", "<Kadr4>", "<Pnname>", "<Pvname>", "<Pgeboren>"]
27 xDoc = self.__class__._uno.openTemplateFromTDOC("fdo39694.ott")
28 xEnumerationAccess = xDoc.getTextFields()
29 xFieldEnum = xEnumerationAccess.createEnumeration()
30 for xField in xFieldEnum:
31 if xField.supportsService("com.sun.star.text.TextField.JumpEdit"):
32 xAnchor = xField.getAnchor()
33 read_content = xAnchor.getString()
34 self.assertTrue(read_content in placeholders,
35 "field %s is not contained: " % read_content)
36 xDoc.close(True)
38 def test_fdo42073(self):
39 xDoc = self.__class__._uno.openEmptyWriterDoc()
40 xBodyText = xDoc.getText()
41 xCursor = xBodyText.createTextCursor()
42 xTextField = xDoc.createInstance("com.sun.star.text.TextField.Input")
43 xBodyText.insertTextContent(xCursor, xTextField, True)
44 read_content = xTextField.getPropertyValue("Content")
45 self.assertEqual("", read_content)
46 content = "this is not surprising"
47 xTextField.setPropertyValue("Content", content)
48 read_content = xTextField.getPropertyValue("Content")
49 self.assertEqual(content, read_content)
50 xDoc.close(True)
52 if __name__ == '__main__':
53 unittest.main()