summaryrefslogtreecommitdiffstats
path: root/sd/qa/uitest/impress_tests/autocorrectOptions.py
blob: a79facecc204e8b0f3ed9277513ebd3b92bb9d5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict
import time
from uitest.uihelper.common import select_pos

class autocorrectOptions(UITestCase):

   def test_autocorrect_options_impress(self):
        with self.ui_test.create_doc_in_start_center("impress"):
            xTemplateDlg = self.xUITest.getTopFocusWindow()
            xCancelBtn = xTemplateDlg.getChild("close")
            self.ui_test.close_dialog_through_button(xCancelBtn)

            with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg", close_button="cancel") as xDialog:
                xTabs = xDialog.getChild("tabcontrol")
                select_pos(xTabs, "0")       #tab replace
                origtext = xDialog.getChild("origtext")
                newtext = xDialog.getChild("newtext")
                xnew = xDialog.getChild("new")
                xdelete = xDialog.getChild("delete")
                xtabview = xDialog.getChild("tabview")
                xreset = xDialog.getChild("reset")
                nrRows = get_state_as_dict(xtabview)["VisibleCount"]

                self.assertTrue(int(nrRows) > 0)

                #add new rule
                origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"}))
                newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"}))
                xnew.executeAction("CLICK", tuple())
                nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"]
                nrRowsDiff = int(nrRowsNew) - int(nrRows)
                self.assertEqual(nrRowsDiff, 1)  #we have +1 rule
                #delete rule
                origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"}))
                newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"}))
                xdelete.executeAction("CLICK", tuple())
                self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows)   #we have default nr of rules

                select_pos(xTabs, "1")     #tab Exceptions
                #abbreviations
                abbrev = xDialog.getChild("abbrev")
                newabbrev = xDialog.getChild("newabbrev")
                delabbrev = xDialog.getChild("delabbrev")
                abbrevlist = xDialog.getChild("abbrevlist")

                nrRowsAbb = get_state_as_dict(abbrevlist)["VisibleCount"]

                self.assertTrue(int(nrRowsAbb) > 0)

                abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"}))
                newabbrev.executeAction("CLICK", tuple())
                nrRowsAbbNew = get_state_as_dict(abbrevlist)["VisibleCount"]
                nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb)
                self.assertEqual(nrRowsAbbDiff, 1)  #we have +1 rule
                delabbrev.executeAction("CLICK", tuple())
                self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], nrRowsAbb)   #we have default nr of rules

                #words with two initial capitals
                double = xDialog.getChild("double")
                newdouble = xDialog.getChild("newdouble")
                deldouble = xDialog.getChild("deldouble")
                doublelist = xDialog.getChild("doublelist")

                nrRowsDouble = get_state_as_dict(doublelist)["VisibleCount"]

                self.assertTrue(int(nrRowsDouble) > 0)

                double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"}))
                newdouble.executeAction("CLICK", tuple())
                nrRowsDoubleNew = get_state_as_dict(doublelist)["VisibleCount"]
                nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and
                self.assertEqual(nrRowsDoubleDiff, 1)  #we have +1 rule
                deldouble.executeAction("CLICK", tuple())
                self.assertEqual(get_state_as_dict(doublelist)["VisibleCount"], nrRowsDouble)   #we have default nr of rules



# vim: set shiftwidth=4 softtabstop=4 expandtab: