Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / qa / uitest / impress_tests / autocorrectOptions.py
blob2f4b7645e30ca00cd392fca8de649c4e7d77e9a7
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
16 class autocorrectOptions(UITestCase):
18 def test_autocorrect_options_impress(self):
19 with self.ui_test.create_doc_in_start_center("impress"):
20 xTemplateDlg = self.xUITest.getTopFocusWindow()
21 xCancelBtn = xTemplateDlg.getChild("close")
22 self.ui_test.close_dialog_through_button(xCancelBtn)
24 with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg", close_button="cancel") as xDialog:
25 xTabs = xDialog.getChild("tabcontrol")
26 select_pos(xTabs, "0") #tab replace
27 origtext = xDialog.getChild("origtext")
28 newtext = xDialog.getChild("newtext")
29 xnew = xDialog.getChild("new")
30 xdelete = xDialog.getChild("delete")
31 xtabview = xDialog.getChild("tabview")
32 xreset = xDialog.getChild("reset")
33 nrRows = get_state_as_dict(xtabview)["VisibleCount"]
35 self.assertTrue(int(nrRows) > 0)
37 #add new rule
38 origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
39 origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
40 origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"}))
41 newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
42 newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
43 newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"}))
44 xnew.executeAction("CLICK", tuple())
45 nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"]
46 nrRowsDiff = int(nrRowsNew) - int(nrRows)
47 self.assertEqual(nrRowsDiff, 1) #we have +1 rule
48 #delete rule
49 origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
50 origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
51 origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"}))
52 newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
53 newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
54 newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"}))
55 xdelete.executeAction("CLICK", tuple())
56 self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules
58 select_pos(xTabs, "1") #tab Exceptions
59 #abbreviations
60 abbrev = xDialog.getChild("abbrev")
61 newabbrev = xDialog.getChild("newabbrev")
62 delabbrev = xDialog.getChild("delabbrev")
63 abbrevlist = xDialog.getChild("abbrevlist")
65 nrRowsAbb = get_state_as_dict(abbrevlist)["VisibleCount"]
67 self.assertTrue(int(nrRowsAbb) > 0)
69 abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
70 abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
71 abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"}))
72 newabbrev.executeAction("CLICK", tuple())
73 nrRowsAbbNew = get_state_as_dict(abbrevlist)["VisibleCount"]
74 nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb)
75 self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule
76 delabbrev.executeAction("CLICK", tuple())
77 self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], nrRowsAbb) #we have default nr of rules
79 #words with two initial capitals
80 double = xDialog.getChild("double")
81 newdouble = xDialog.getChild("newdouble")
82 deldouble = xDialog.getChild("deldouble")
83 doublelist = xDialog.getChild("doublelist")
85 nrRowsDouble = get_state_as_dict(doublelist)["VisibleCount"]
87 self.assertTrue(int(nrRowsDouble) > 0)
89 double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
90 double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
91 double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"}))
92 newdouble.executeAction("CLICK", tuple())
93 nrRowsDoubleNew = get_state_as_dict(doublelist)["VisibleCount"]
94 nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and
95 self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule
96 deldouble.executeAction("CLICK", tuple())
97 self.assertEqual(get_state_as_dict(doublelist)["VisibleCount"], nrRowsDouble) #we have default nr of rules
101 # vim: set shiftwidth=4 softtabstop=4 expandtab: