| 1 |
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- |
| 2 |
# |
| 3 |
# This file is part of the LibreOffice project. |
| 4 |
# |
| 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/. |
| 8 |
# |
| 9 |
|
| 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 |
| 14 |
|
| 15 |
|
| 16 |
class autocorrectOptions(UITestCase): |
| 17 |
|
| 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) |
| 23 |
|
| 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 |
nrRows = get_state_as_dict(xtabview)["VisibleCount"] |
| 33 |
|
| 34 |
self.assertTrue(int(nrRows) > 0) |
| 35 |
|
| 36 |
#add new rule |
| 37 |
origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) |
| 38 |
origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) |
| 39 |
origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) |
| 40 |
newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) |
| 41 |
newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) |
| 42 |
newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) |
| 43 |
xnew.executeAction("CLICK", tuple()) |
| 44 |
nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"] |
| 45 |
nrRowsDiff = int(nrRowsNew) - int(nrRows) |
| 46 |
self.assertEqual(nrRowsDiff, 1) #we have +1 rule |
| 47 |
#delete rule |
| 48 |
origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) |
| 49 |
origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) |
| 50 |
origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) |
| 51 |
newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) |
| 52 |
newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) |
| 53 |
newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) |
| 54 |
xdelete.executeAction("CLICK", tuple()) |
| 55 |
self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules |
| 56 |
|
| 57 |
select_pos(xTabs, "1") #tab Exceptions |
| 58 |
#abbreviations |
| 59 |
abbrev = xDialog.getChild("abbrev") |
| 60 |
newabbrev = xDialog.getChild("newabbrev") |
| 61 |
delabbrev = xDialog.getChild("delabbrev") |
| 62 |
abbrevlist = xDialog.getChild("abbrevlist") |
| 63 |
|
| 64 |
nrRowsAbb = get_state_as_dict(abbrevlist)["VisibleCount"] |
| 65 |
|
| 66 |
self.assertTrue(int(nrRowsAbb) > 0) |
| 67 |
|
| 68 |
abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) |
| 69 |
abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) |
| 70 |
abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"})) |
| 71 |
newabbrev.executeAction("CLICK", tuple()) |
| 72 |
nrRowsAbbNew = get_state_as_dict(abbrevlist)["VisibleCount"] |
| 73 |
nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) |
| 74 |
self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule |
| 75 |
delabbrev.executeAction("CLICK", tuple()) |
| 76 |
self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], nrRowsAbb) #we have default nr of rules |
| 77 |
|
| 78 |
#words with two initial capitals |
| 79 |
double = xDialog.getChild("double") |
| 80 |
newdouble = xDialog.getChild("newdouble") |
| 81 |
deldouble = xDialog.getChild("deldouble") |
| 82 |
doublelist = xDialog.getChild("doublelist") |
| 83 |
|
| 84 |
nrRowsDouble = get_state_as_dict(doublelist)["VisibleCount"] |
| 85 |
|
| 86 |
self.assertTrue(int(nrRowsDouble) > 0) |
| 87 |
|
| 88 |
double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) |
| 89 |
double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) |
| 90 |
double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"})) |
| 91 |
newdouble.executeAction("CLICK", tuple()) |
| 92 |
nrRowsDoubleNew = get_state_as_dict(doublelist)["VisibleCount"] |
| 93 |
nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and |
| 94 |
self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule |
| 95 |
deldouble.executeAction("CLICK", tuple()) |
| 96 |
self.assertEqual(get_state_as_dict(doublelist)["VisibleCount"], nrRowsDouble) #we have default nr of rules |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |