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 Tdf145062(UITestCase
):
17 def test_tdf145062(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
="") as xDialog
:
22 xTab
= xDialog
.getChild("tabcontrol")
25 xType
= xDialog
.getChild("type-func")
26 xType
.getChild('2').executeAction("SELECT", tuple())
27 self
.assertEqual("Input field", get_state_as_dict(xType
)['SelectEntryText'])
29 xOkBtn
= xDialog
.getChild("ok")
30 with self
.ui_test
.execute_blocking_action(xOkBtn
.executeAction
, args
=('CLICK', ())) as xFieldDialog
:
31 xText
= xFieldDialog
.getChild("text")
32 xText
.executeAction("TYPE", mkPropertyValues({"TEXT": "AAA"}))
34 # move cursor to the middle of the field
35 self
.xUITest
.executeCommand(".uno:GoLeft")
36 self
.xUITest
.executeCommand(".uno:GoLeft")
38 xType
.getChild('6').executeAction("SELECT", tuple())
39 self
.assertEqual("Hidden text", get_state_as_dict(xType
)['SelectEntryText'])
41 # try to insert a hidden text a few times
42 # Without the fix in place, this test would have crashed here
44 xOkBtn
.executeAction("CLICK", ())
46 # close_dialog_through_button should be used here but it hangs and
47 # the reason seems to be that interacting with the document while
48 # the dialog is open doesn't play well together in the uitests
49 # As a workaround, leave the dialog open, close the document,
50 # open a new one and then, close the dialog.
51 # If the dialog is not closed, it will be displayed in other tests
53 textfields
= writer_doc
.getTextFields()
54 textfield
= textfields
.createEnumeration().nextElement()
55 self
.assertTrue(textfield
.supportsService("com.sun.star.text.TextField.Input"))
56 self
.assertEqual('AAA', textfield
.Content
)
58 with self
.ui_test
.load_empty_file("writer"):
59 xDialog
= self
.xUITest
.getTopFocusWindow()
60 xCancelBtn
= xDialog
.getChild("cancel")
61 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
63 # vim: set shiftwidth=4 softtabstop=4 expandtab: