summaryrefslogtreecommitdiffstats
path: root/sw/qa/uitest/table/tableProperties.py
blob: c0edf484f4f28753fc367842471ec2a803987515 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# -*- 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 uitest.uihelper.common import select_pos
from uitest.uihelper.common import select_by_text
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
from uitest.uihelper.common import change_measurement_unit

#Writer Table Properties

class tableProperties(UITestCase):
    def test_table_properties(self):
        with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) as writer_doc:
            xWriterDoc = self.xUITest.getTopFocusWindow()

            change_measurement_unit(self, "Centimeter")

            #dialog Table Properties - Table
            with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
                tabcontrol = xDialog.getChild("tabcontrol")
                select_pos(tabcontrol, "0")

                name = xDialog.getChild("name")
                free = xDialog.getChild("free")
                widthmf = xDialog.getChild("widthmf")
                leftmf = xDialog.getChild("leftmf")
                rightmf = xDialog.getChild("rightmf")
                abovemf = xDialog.getChild("abovemf")
                belowmf = xDialog.getChild("belowmf")
                textdirection = xDialog.getChild("textdirection")

                name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                name.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"}))
                free.executeAction("CLICK", tuple())
                widthmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                widthmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                widthmf.executeAction("TYPE", mkPropertyValues({"TEXT":"15"}))
                leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                leftmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
                rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                rightmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
                abovemf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                abovemf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                abovemf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
                belowmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                belowmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                belowmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
                select_by_text(textdirection, "Left-to-right (LTR)")
            #verify
            with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
                tabcontrol = xDialog.getChild("tabcontrol")
                select_pos(tabcontrol, "0")

                name = xDialog.getChild("name")
                free = xDialog.getChild("free")
                widthmf = xDialog.getChild("widthmf")
                leftmf = xDialog.getChild("leftmf")
                rightmf = xDialog.getChild("rightmf")
                abovemf = xDialog.getChild("abovemf")
                belowmf = xDialog.getChild("belowmf")
                textdirection = xDialog.getChild("textdirection")

                self.assertEqual(get_state_as_dict(name)["Text"], "NewName")
                self.assertEqual(get_state_as_dict(free)["Checked"], "true")
                self.assertEqual(get_state_as_dict(widthmf)["Text"], "15.00 cm")
                self.assertEqual(get_state_as_dict(leftmf)["Text"], "1.00 cm")
                self.assertEqual(get_state_as_dict(rightmf)["Text"], "1.00 cm")
                self.assertEqual(get_state_as_dict(abovemf)["Text"], "1.00 cm")
                self.assertEqual(get_state_as_dict(belowmf)["Text"], "1.00 cm")

            #dialog Table Properties - Text flow
            with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
                tabcontrol = xDialog.getChild("tabcontrol")
                select_pos(tabcontrol, "1")

                xbreak = xDialog.getChild("break")
                xbreak.executeAction("CLICK", tuple())
                column = xDialog.getChild("column")
                column.executeAction("CLICK", tuple())
                after = xDialog.getChild("after")
                after.executeAction("CLICK", tuple())
                keep = xDialog.getChild("keep")
                keep.executeAction("CLICK", tuple())
                headline = xDialog.getChild("headline")
                headline.executeAction("CLICK", tuple())
                textdirection = xDialog.getChild("textorientation")
                select_by_text(textdirection, "Vertical (bottom to top)")
                vertorient = xDialog.getChild("vertorient")
                select_by_text(vertorient, "Bottom")
            #verify
            with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
                tabcontrol = xDialog.getChild("tabcontrol")
                select_pos(tabcontrol, "1")

                xbreak = xDialog.getChild("break")
                self.assertEqual(get_state_as_dict(xbreak)["Selected"], "true")
                column = xDialog.getChild("column")
                self.assertEqual(get_state_as_dict(column)["Checked"], "true")
                after = xDialog.getChild("column")
                self.assertEqual(get_state_as_dict(after)["Checked"], "true")
                keep = xDialog.getChild("keep")
                self.assertEqual(get_state_as_dict(keep)["Selected"], "true")
                headline = xDialog.getChild("headline")
                self.assertEqual(get_state_as_dict(headline)["Selected"], "true")
                textdirection = xDialog.getChild("textorientation")
                self.assertEqual(get_state_as_dict(textdirection)["SelectEntryText"], "Vertical (bottom to top)")
                vertorient = xDialog.getChild("vertorient")
                self.assertEqual(get_state_as_dict(vertorient)["SelectEntryText"], "Bottom")

            #dialog Table Properties - Columns
            with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
                tabcontrol = xDialog.getChild("tabcontrol")
                select_pos(tabcontrol, "2")

                adaptwidth = xDialog.getChild("adaptwidth")
                adaptwidth.executeAction("CLICK", tuple())

            #verify
            #doesn't work / probably Bug 100537 - Width and relative checkboxes disabled in Table
            #dialog by default with automatic alignment
    #        self.ui_test.execute_dialog_through_command(".uno:TableDialog")
    #        xDialog = self.xUITest.getTopFocusWindow()
    #        tabcontrol = xDialog.getChild("tabcontrol")
    #        select_pos(tabcontrol, "2")
    #        adaptwidth = xDialog.getChild("adaptwidth")
    #        self.assertEqual(get_state_as_dict(adaptwidth)["Selected"], "true")
    #        xOKBtn = xDialog.getChild("ok")
    #        self.ui_test.close_dialog_through_button(xOKBtn)

            #dialog Table Properties - Borders
            with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
                tabcontrol = xDialog.getChild("tabcontrol")
                select_pos(tabcontrol, "3")

                sync = xDialog.getChild("sync")
                mergeadjacent = xDialog.getChild("mergeadjacent")
                sync.executeAction("CLICK", tuple())
                mergeadjacent.executeAction("CLICK", tuple())

            #verify
            with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
                tabcontrol = xDialog.getChild("tabcontrol")
                select_pos(tabcontrol, "3")
                sync = xDialog.getChild("sync")
                mergeadjacent = xDialog.getChild("mergeadjacent")
        #        self.assertEqual(get_state_as_dict(sync)["Selected"], "false") #need change spacing, but ui names are not unique
                self.assertEqual(get_state_as_dict(mergeadjacent)["Selected"], "false")

            #dialog Table Properties - Background
            with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
                tabcontrol = xDialog.getChild("tabcontrol")
                select_pos(tabcontrol, "4")

                btncolor = xDialog.getChild("btncolor")
                btncolor.executeAction("CLICK", tuple())
                R_custom = xDialog.getChild("R_custom")
                G_custom = xDialog.getChild("G_custom")
                B_custom = xDialog.getChild("B_custom")
                R_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                R_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                R_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"}))
                G_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                G_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                G_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"}))
                B_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
                B_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
                B_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"}))
                B_custom.executeAction("UP", tuple())
                B_custom.executeAction("DOWN", tuple())  #need to refresh HEX value...

            #verify
            with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
                tabcontrol = xDialog.getChild("tabcontrol")
                select_pos(tabcontrol, "4")
                btncolor = xDialog.getChild("btncolor")
                btncolor.executeAction("CLICK", tuple())
                R_custom = xDialog.getChild("R_custom")
                G_custom = xDialog.getChild("G_custom")
                B_custom = xDialog.getChild("B_custom")

                self.assertEqual(get_state_as_dict(R_custom)["Text"], "100")
                self.assertEqual(get_state_as_dict(B_custom)["Text"], "100")
                self.assertEqual(get_state_as_dict(G_custom)["Text"], "100")

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