1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
10 from uitest
.framework
import UITestCase
11 from uitest
.uihelper
.common
import type_text
, get_state_as_dict
, select_text
15 class EditTest(UITestCase
):
17 def test_type_text(self
):
19 self
.ui_test
.create_doc_in_start_center("calc")
21 self
.ui_test
.execute_modeless_dialog_through_command(".uno:AddName")
22 xAddNameDlg
= self
.xUITest
.getTopFocusWindow()
24 xEdit
= xAddNameDlg
.getChild("edit")
26 type_text(xEdit
, "simpleRangeName")
28 xAddBtn
= xAddNameDlg
.getChild("cancel")
29 self
.ui_test
.close_dialog_through_button(xAddBtn
)
31 self
.ui_test
.close_doc()
33 def test_select_text(self
):
35 self
.ui_test
.create_doc_in_start_center("calc")
37 self
.ui_test
.execute_modeless_dialog_through_command(".uno:AddName")
38 xAddNameDlg
= self
.xUITest
.getTopFocusWindow()
40 xEdit
= xAddNameDlg
.getChild("edit")
42 type_text(xEdit
, "simpleRangeName")
43 xEdit
.executeAction("SELECT", mkPropertyValues({"FROM": "2", "TO": "9"}))
44 type_text(xEdit
, "otherChars")
45 self
.assertEqual("siotherCharsgeName", get_state_as_dict(xEdit
)["Text"])
47 select_text(xEdit
, from_pos
="2", to
="12")
48 self
.assertEqual("otherChars", get_state_as_dict(xEdit
)["SelectedText"])
50 xAddBtn
= xAddNameDlg
.getChild("cancel")
51 self
.ui_test
.close_dialog_through_button(xAddBtn
)
53 self
.ui_test
.close_doc()
55 # vim: set shiftwidth=4 softtabstop=4 expandtab: