Get the style color and number just once
[LibreOffice.git] / sw / qa / uitest / fieldDialog / tdf129796.py
blobfb764f7aec79bd20f9e069b892e7b03da303c797
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 from uitest.framework import UITestCase
11 from libreoffice.uno.propertyvalue import mkPropertyValues
12 from uitest.uihelper.common import get_state_as_dict
13 from uitest.uihelper.common import select_pos
15 class Tdf129796(UITestCase):
17 def test_tdf129796(self):
19 with self.ui_test.create_doc_in_start_center("writer") as writer_doc:
21 with self.ui_test.execute_modeless_dialog_through_command(".uno:InsertField", close_button="cancel") as xDialog:
22 xTab = xDialog.getChild("tabcontrol")
23 select_pos(xTab, "4")
25 xType = xDialog.getChild("type-var")
26 xType.getChild('8').executeAction("SELECT", tuple())
27 self.assertEqual("User Field", get_state_as_dict(xType)['SelectEntryText'])
29 xNumFormat = xDialog.getChild("numformat-var")
30 xNumFormat.getChild('0').executeAction("SELECT", tuple())
31 self.assertEqual("Text", get_state_as_dict(xNumFormat)['SelectEntryText'])
33 xName = xDialog.getChild("name-var")
34 xName.executeAction("TYPE", mkPropertyValues({"TEXT": "MyField"}))
36 xValue = xDialog.getChild("value-var")
37 xValue.executeAction("TYPE", mkPropertyValues({"TEXT": "abc"}))
39 xApplyBtn = xDialog.getChild("apply")
40 xApplyBtn.executeAction("CLICK", ())
42 xType.getChild('4').executeAction("SELECT", tuple())
43 self.assertEqual("Input field", get_state_as_dict(xType)['SelectEntryText'])
45 self.assertEqual("MyField", get_state_as_dict(xDialog.getChild("select-var"))["SelectEntryText"])
47 xValue.executeAction("TYPE", mkPropertyValues({"TEXT": "ref"}))
49 xOkBtn = xDialog.getChild("ok")
50 with self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ())) as xFieldDialog:
51 xName = xFieldDialog.getChild("name")
52 self.assertEqual("ref", get_state_as_dict(xName)['Text'])
53 xText = xFieldDialog.getChild("text")
54 self.assertEqual("abc", get_state_as_dict(xText)['Text'])
56 textfields = writer_doc.getTextFields()
57 textfield = textfields.createEnumeration().nextElement()
58 self.assertEqual('MyField', textfield.Content)
59 self.assertTrue(textfield.supportsService("com.sun.star.text.TextField.InputUser"))
61 # Move the cursor to the field
62 self.xUITest.executeCommand(".uno:GoLeft")
64 with self.ui_test.execute_dialog_through_command(".uno:FieldDialog") as xDialog:
65 xType = xDialog.getChild("type-var")
66 xNumFormat = xDialog.getChild("numformat-var")
67 xValue = xDialog.getChild("value-var")
68 xName = xDialog.getChild("name-var")
70 # Without the fix in place, this test would have crashed here
71 self.assertEqual("ref", get_state_as_dict(xValue)['Text'])
72 self.assertEqual("Input field", get_state_as_dict(xType)['SelectEntryText'])
73 self.assertEqual("General", get_state_as_dict(xNumFormat)['SelectEntryText'])
74 self.assertEqual("MyField", get_state_as_dict(xName)['Text'])
76 # vim: set shiftwidth=4 softtabstop=4 expandtab: