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 autocorrectOptions(UITestCase
):
17 def test_autocorrect_options_writer(self
):
18 with self
.ui_test
.create_doc_in_start_center("writer"):
20 with self
.ui_test
.execute_dialog_through_command(".uno:AutoCorrectDlg", close_button
="cancel") as xDialog
:
21 xTabs
= xDialog
.getChild("tabcontrol")
22 select_pos(xTabs
, "0") #tab replace
23 origtext
= xDialog
.getChild("origtext")
24 newtext
= xDialog
.getChild("newtext")
25 xnew
= xDialog
.getChild("new")
26 xdelete
= xDialog
.getChild("delete")
27 xtabview
= xDialog
.getChild("tabview")
28 nrRows
= get_state_as_dict(xtabview
)["VisibleCount"]
30 self
.assertTrue(int(nrRows
) > 0)
33 origtext
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
34 origtext
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
35 origtext
.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"}))
36 newtext
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
37 newtext
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
38 newtext
.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"}))
39 xnew
.executeAction("CLICK", tuple())
40 nrRowsNew
= get_state_as_dict(xtabview
)["VisibleCount"]
41 nrRowsDiff
= int(nrRowsNew
) - int(nrRows
)
42 self
.assertEqual(nrRowsDiff
, 1) #we have +1 rule
44 origtext
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
45 origtext
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
46 origtext
.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"}))
47 newtext
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
48 newtext
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
49 newtext
.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"}))
50 xdelete
.executeAction("CLICK", tuple())
51 self
.assertEqual(get_state_as_dict(xtabview
)["VisibleCount"], nrRows
) #we have default nr of rules
53 select_pos(xTabs
, "1") #tab Exceptions
55 abbrev
= xDialog
.getChild("abbrev")
56 newabbrev
= xDialog
.getChild("newabbrev")
57 delabbrev
= xDialog
.getChild("delabbrev")
58 abbrevlist
= xDialog
.getChild("abbrevlist")
60 nrRowsAbb
= get_state_as_dict(abbrevlist
)["VisibleCount"]
62 self
.assertTrue(int(nrRowsAbb
) > 0)
64 abbrev
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
65 abbrev
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
66 abbrev
.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"}))
67 newabbrev
.executeAction("CLICK", tuple())
68 nrRowsAbbNew
= get_state_as_dict(abbrevlist
)["VisibleCount"]
69 nrRowsAbbDiff
= int(nrRowsAbbNew
) - int(nrRowsAbb
)
70 self
.assertEqual(nrRowsAbbDiff
, 1) #we have +1 rule
71 delabbrev
.executeAction("CLICK", tuple())
72 self
.assertEqual(get_state_as_dict(abbrevlist
)["VisibleCount"], nrRowsAbb
) #we have default nr of rules
74 #words with two initial capitals
75 double
= xDialog
.getChild("double")
76 newdouble
= xDialog
.getChild("newdouble")
77 deldouble
= xDialog
.getChild("deldouble")
78 doublelist
= xDialog
.getChild("doublelist")
80 nrRowsDouble
= get_state_as_dict(doublelist
)["VisibleCount"]
82 self
.assertTrue(int(nrRowsDouble
) > 0)
84 double
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
85 double
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
86 double
.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"}))
87 newdouble
.executeAction("CLICK", tuple())
88 nrRowsDoubleNew
= get_state_as_dict(doublelist
)["VisibleCount"]
89 nrRowsDoubleDiff
= int(nrRowsDoubleNew
) - int(nrRowsDouble
) #convert string and
90 self
.assertEqual(nrRowsDoubleDiff
, 1) #we have +1 rule
91 deldouble
.executeAction("CLICK", tuple())
92 self
.assertEqual(get_state_as_dict(doublelist
)["VisibleCount"], nrRowsDouble
) #we have default nr of rules
96 # vim: set shiftwidth=4 softtabstop=4 expandtab: