Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / uitest / table / tableProperties.py
blob1549dfec63c79a184eb0d0a1e57453b6d9e18e44
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/.
9 from uitest.framework import UITestCase
10 from uitest.uihelper.common import select_pos
11 from uitest.uihelper.common import select_by_text
12 from libreoffice.uno.propertyvalue import mkPropertyValues
13 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
14 from uitest.uihelper.common import change_measurement_unit
16 #Writer Table Properties
18 class tableProperties(UITestCase):
19 def test_table_properties(self):
20 with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")):
22 with change_measurement_unit(self, "Centimeter"):
24 #dialog Table Properties - Table
25 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
26 tabcontrol = xDialog.getChild("tabcontrol")
27 select_pos(tabcontrol, "0")
29 name = xDialog.getChild("name")
30 free = xDialog.getChild("free")
31 widthmf = xDialog.getChild("widthmf")
32 leftmf = xDialog.getChild("leftmf")
33 rightmf = xDialog.getChild("rightmf")
34 abovemf = xDialog.getChild("abovemf")
35 belowmf = xDialog.getChild("belowmf")
36 textdirection = xDialog.getChild("textdirection")
38 name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
39 name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
40 name.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"}))
41 free.executeAction("CLICK", tuple())
42 widthmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
43 widthmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
44 widthmf.executeAction("TYPE", mkPropertyValues({"TEXT":"15"}))
45 leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
46 leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
47 leftmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
48 rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
49 rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
50 rightmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
51 abovemf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
52 abovemf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
53 abovemf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
54 belowmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
55 belowmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
56 belowmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
57 select_by_text(textdirection, "Left-to-right (LTR)")
58 #verify
59 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
60 tabcontrol = xDialog.getChild("tabcontrol")
61 select_pos(tabcontrol, "0")
63 name = xDialog.getChild("name")
64 free = xDialog.getChild("free")
65 widthmf = xDialog.getChild("widthmf")
66 leftmf = xDialog.getChild("leftmf")
67 rightmf = xDialog.getChild("rightmf")
68 abovemf = xDialog.getChild("abovemf")
69 belowmf = xDialog.getChild("belowmf")
70 textdirection = xDialog.getChild("textdirection")
72 self.assertEqual(get_state_as_dict(name)["Text"], "NewName")
73 self.assertEqual(get_state_as_dict(free)["Checked"], "true")
74 self.assertEqual(get_state_as_dict(widthmf)["Text"], "15.00 cm")
75 self.assertEqual(get_state_as_dict(leftmf)["Text"], "1.00 cm")
76 self.assertEqual(get_state_as_dict(rightmf)["Text"], "1.00 cm")
77 self.assertEqual(get_state_as_dict(abovemf)["Text"], "1.00 cm")
78 self.assertEqual(get_state_as_dict(belowmf)["Text"], "1.00 cm")
80 #dialog Table Properties - Text flow
81 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
82 tabcontrol = xDialog.getChild("tabcontrol")
83 select_pos(tabcontrol, "1")
85 xbreak = xDialog.getChild("break")
86 xbreak.executeAction("CLICK", tuple())
87 column = xDialog.getChild("column")
88 column.executeAction("CLICK", tuple())
89 after = xDialog.getChild("after")
90 after.executeAction("CLICK", tuple())
91 keep = xDialog.getChild("keep")
92 keep.executeAction("CLICK", tuple())
93 headline = xDialog.getChild("headline")
94 headline.executeAction("CLICK", tuple())
95 textdirection = xDialog.getChild("textorientation")
96 select_by_text(textdirection, "Vertical (bottom to top)")
97 vertorient = xDialog.getChild("vertorient")
98 select_by_text(vertorient, "Bottom")
99 #verify
100 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
101 tabcontrol = xDialog.getChild("tabcontrol")
102 select_pos(tabcontrol, "1")
104 xbreak = xDialog.getChild("break")
105 self.assertEqual(get_state_as_dict(xbreak)["Selected"], "true")
106 column = xDialog.getChild("column")
107 self.assertEqual(get_state_as_dict(column)["Checked"], "true")
108 after = xDialog.getChild("column")
109 self.assertEqual(get_state_as_dict(after)["Checked"], "true")
110 keep = xDialog.getChild("keep")
111 self.assertEqual(get_state_as_dict(keep)["Selected"], "true")
112 headline = xDialog.getChild("headline")
113 self.assertEqual(get_state_as_dict(headline)["Selected"], "true")
114 textdirection = xDialog.getChild("textorientation")
115 self.assertEqual(get_state_as_dict(textdirection)["SelectEntryText"], "Vertical (bottom to top)")
116 vertorient = xDialog.getChild("vertorient")
117 self.assertEqual(get_state_as_dict(vertorient)["SelectEntryText"], "Bottom")
119 #dialog Table Properties - Columns
120 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
121 tabcontrol = xDialog.getChild("tabcontrol")
122 select_pos(tabcontrol, "2")
124 adaptwidth = xDialog.getChild("adaptwidth")
125 adaptwidth.executeAction("CLICK", tuple())
127 #verify
128 #doesn't work / probably Bug 100537 - Width and relative checkboxes disabled in Table
129 #dialog by default with automatic alignment
130 # self.ui_test.execute_dialog_through_command(".uno:TableDialog")
131 # xDialog = self.xUITest.getTopFocusWindow()
132 # tabcontrol = xDialog.getChild("tabcontrol")
133 # select_pos(tabcontrol, "2")
134 # adaptwidth = xDialog.getChild("adaptwidth")
135 # self.assertEqual(get_state_as_dict(adaptwidth)["Selected"], "true")
136 # xOKBtn = xDialog.getChild("ok")
137 # self.ui_test.close_dialog_through_button(xOKBtn)
139 #dialog Table Properties - Borders
140 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
141 tabcontrol = xDialog.getChild("tabcontrol")
142 select_pos(tabcontrol, "3")
144 sync = xDialog.getChild("sync")
145 mergeadjacent = xDialog.getChild("mergeadjacent")
146 sync.executeAction("CLICK", tuple())
147 mergeadjacent.executeAction("CLICK", tuple())
149 #verify
150 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
151 tabcontrol = xDialog.getChild("tabcontrol")
152 select_pos(tabcontrol, "3")
153 sync = xDialog.getChild("sync")
154 mergeadjacent = xDialog.getChild("mergeadjacent")
155 # self.assertEqual(get_state_as_dict(sync)["Selected"], "false") #need change spacing, but ui names are not unique
156 self.assertEqual(get_state_as_dict(mergeadjacent)["Selected"], "false")
158 #dialog Table Properties - Background
159 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
160 tabcontrol = xDialog.getChild("tabcontrol")
161 select_pos(tabcontrol, "4")
163 btncolor = xDialog.getChild("btncolor")
164 btncolor.executeAction("CLICK", tuple())
165 R_custom = xDialog.getChild("R_custom")
166 G_custom = xDialog.getChild("G_custom")
167 B_custom = xDialog.getChild("B_custom")
168 R_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
169 R_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
170 R_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"}))
171 G_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
172 G_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
173 G_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"}))
174 B_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
175 B_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
176 B_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"}))
177 B_custom.executeAction("UP", tuple())
178 B_custom.executeAction("DOWN", tuple()) #need to refresh HEX value...
180 #verify
181 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog:
182 tabcontrol = xDialog.getChild("tabcontrol")
183 select_pos(tabcontrol, "4")
184 btncolor = xDialog.getChild("btncolor")
185 btncolor.executeAction("CLICK", tuple())
186 R_custom = xDialog.getChild("R_custom")
187 G_custom = xDialog.getChild("G_custom")
188 B_custom = xDialog.getChild("B_custom")
190 self.assertEqual(get_state_as_dict(R_custom)["Text"], "100")
191 self.assertEqual(get_state_as_dict(B_custom)["Text"], "100")
192 self.assertEqual(get_state_as_dict(G_custom)["Text"], "100")
194 # vim: set shiftwidth=4 softtabstop=4 expandtab: