Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sw / qa / python / check_fields.py
blob60418a93001d41539966b9ff166cf23e8f4d09aa
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()
20 cls._xDoc = cls._uno.openTemplateFromTDOC("fdo39694.ott")
21 cls._xEmptyDoc = cls._uno.openEmptyWriterDoc()
23 @classmethod
24 def tearDownClass(cls):
25 cls._uno.tearDown()
27 def test_fdo39694_load(self):
28 placeholders = ["<Kadr1>", "<Kadr2>", "<Kadr3>", "<Kadr4>", "<Pnname>", "<Pvname>", "<Pgeboren>"]
29 xDoc = self.__class__._xDoc
30 xEnumerationAccess = xDoc.getTextFields()
31 xFieldEnum = xEnumerationAccess.createEnumeration()
32 for xField in xFieldEnum:
33 if xField.supportsService("com.sun.star.text.TextField.JumpEdit"):
34 xAnchor = xField.getAnchor()
35 read_content = xAnchor.getString()
36 self.assertTrue(read_content in placeholders,
37 "field %s is not contained: " % read_content)
39 def test_fdo42073(self):
40 xDoc = self.__class__._xEmptyDoc
41 xBodyText = xDoc.getText()
42 xCursor = xBodyText.createTextCursor()
43 xTextField = xDoc.createInstance("com.sun.star.text.TextField.Input")
44 xBodyText.insertTextContent(xCursor, xTextField, True)
45 read_content = xTextField.getPropertyValue("Content")
46 self.assertEqual("", read_content)
47 content = "this is not surprising"
48 xTextField.setPropertyValue("Content", content)
49 read_content = xTextField.getPropertyValue("Content")
50 self.assertEqual(content, read_content)
52 if __name__ == '__main__':
53 unittest.main()