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 get_state_as_dict
, get_url_for_data_file
11 from uitest
.uihelper
.common
import change_measurement_unit
12 from uitest
.uihelper
.common
import select_by_text
13 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
15 class Forms(UITestCase
):
17 def test_tdf140486(self
):
19 with self
.ui_test
.load_file(get_url_for_data_file("tdf140486.odt")):
21 self
.xUITest
.executeCommand(".uno:JumpToNextFrame")
23 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button
=""):
24 xChild
= self
.ui_test
.wait_until_child_is_available('listbox-Empty string is NULL')
26 # Without the fix in place, this test would have failed with
27 # AssertionError: 'Yes' != 'No'
28 self
.assertEqual("Yes", get_state_as_dict(xChild
)['SelectEntryText'])
30 def test_tdf140198(self
):
32 with self
.ui_test
.load_file(get_url_for_data_file("tdf140198.odt")):
34 self
.xUITest
.executeCommand(".uno:JumpToNextFrame")
36 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button
=""):
37 xChild
= self
.ui_test
.wait_until_child_is_available('listbox-Text type')
39 # Without the fix in place, this test would have failed with
40 # AssertionError: 'Multi-line' != 'Single-line'
41 self
.assertEqual("Multi-line", get_state_as_dict(xChild
)['SelectEntryText'])
43 def test_tdf141084(self
):
45 # Reuse document from tdf#140239
46 with self
.ui_test
.load_file(get_url_for_data_file("tdf140239.odt")):
48 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:FormProperties", close_button
=""):
49 xURL
= self
.ui_test
.wait_until_child_is_available('urlcontrol-URL')
51 xURL
.executeAction("TYPE", mkPropertyValues({"TEXT": "1"}))
52 xURL
.executeAction("TYPE", mkPropertyValues({"TEXT": "2"}))
53 xURL
.executeAction("TYPE", mkPropertyValues({"TEXT": "3"}))
54 xURL
.executeAction("TYPE", mkPropertyValues({"TEXT": "4"}))
55 xURL
.executeAction("TYPE", mkPropertyValues({"TEXT": "5"}))
57 # Without the fix in place, this test would have failed with
58 # AssertionError: '12345' != 'file:///tmp/tmp/5file:///tmp/tmp/4file://[40 chars]mp/1'
59 self
.assertEqual("12345", get_state_as_dict(xURL
)['Text'])
61 def test_tdf140239(self
):
63 with self
.ui_test
.load_file(get_url_for_data_file("tdf140239.odt")):
65 self
.xUITest
.executeCommand(".uno:JumpToNextFrame")
67 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button
=""):
68 xAction
= self
.ui_test
.wait_until_child_is_available('listbox-Action')
69 xURL
= self
.ui_test
.wait_until_child_is_available('urlcontrol-URL')
70 xEntry
= self
.ui_test
.wait_until_child_is_available('entry')
72 self
.assertEqual("None", get_state_as_dict(xAction
)['SelectEntryText'])
73 self
.assertEqual("false", get_state_as_dict(xURL
)['Enabled'])
75 select_by_text(xAction
, "Open document/web page")
77 self
.assertEqual("Open document/web page", get_state_as_dict(xAction
)['SelectEntryText'])
79 self
.ui_test
.wait_until_property_is_updated(xURL
, "Enabled", "true")
80 self
.assertEqual("true", get_state_as_dict(xURL
)['Enabled'])
82 xURL
.executeAction("TYPE", mkPropertyValues({"TEXT": "1"}))
83 xURL
.executeAction("TYPE", mkPropertyValues({"TEXT": "2"}))
84 xURL
.executeAction("TYPE", mkPropertyValues({"TEXT": "3"}))
85 xURL
.executeAction("TYPE", mkPropertyValues({"TEXT": "4"}))
86 xURL
.executeAction("TYPE", mkPropertyValues({"TEXT": "5"}))
88 # Without the fix in place, this test would have failed with
89 # AssertionError: '12345' != '54321'
90 self
.assertEqual("12345", get_state_as_dict(xURL
)['Text'])
92 xEntry
.executeAction("FOCUS", tuple())
93 self
.assertEqual("Push Button", get_state_as_dict(xEntry
)['Text'])
95 xEntry
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
96 xEntry
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
97 xEntry
.executeAction("TYPE", mkPropertyValues({"TEXT": "Push"}))
99 # Move the focus to another element so the changes done before will take effect
100 xAction
.executeAction("FOCUS", tuple())
102 # tdf#131522: Without the fix in place, this test would have failed with
103 # AssertionError: 'Push' != 'Push Button'
104 self
.assertEqual("Push", get_state_as_dict(xEntry
)['Text'])
106 def test_tdf138701(self
):
108 # Reuse file from another test
109 with self
.ui_test
.load_file(get_url_for_data_file("tdf140198.odt")):
111 self
.xUITest
.executeCommand(".uno:JumpToNextFrame")
113 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button
=""):
114 xChild
= self
.ui_test
.wait_until_child_is_available('combobox-Data field')
116 xChild
.executeAction("TYPE", mkPropertyValues({"TEXT": "1"}))
117 xChild
.executeAction("TYPE", mkPropertyValues({"TEXT": "2"}))
118 xChild
.executeAction("TYPE", mkPropertyValues({"TEXT": "3"}))
119 xChild
.executeAction("TYPE", mkPropertyValues({"TEXT": "4"}))
120 xChild
.executeAction("TYPE", mkPropertyValues({"TEXT": "5"}))
122 # Without the fix in place, this test would have failed with
123 # AssertionError: '12345' != '54321'
124 self
.assertEqual("12345", get_state_as_dict(xChild
)['Text'])
126 def test_tdf139486(self
):
128 # Reuse file from another test
129 with self
.ui_test
.load_file(get_url_for_data_file("tdf140198.odt")) as document
:
131 with
change_measurement_unit(self
, "Centimeter"):
133 self
.xUITest
.executeCommand(".uno:JumpToNextFrame")
135 shape
= document
.getDrawPages()[0][0]
136 self
.assertEqual(13996, shape
.getSize().Width
)
137 self
.assertEqual(2408, shape
.getSize().Height
)
139 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button
=""):
140 xWidth
= self
.ui_test
.wait_until_child_is_available('numericfield-Width')
141 xHeight
= self
.ui_test
.wait_until_child_is_available('numericfield-Height')
143 self
.assertEqual("14.00 cm", get_state_as_dict(xWidth
)['Text'])
144 self
.assertEqual("2.41 cm", get_state_as_dict(xHeight
)['Text'])
146 xWidth
.executeAction("FOCUS", tuple())
147 xWidth
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
148 xWidth
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
149 xWidth
.executeAction("TYPE", mkPropertyValues({"TEXT":"20 cm"}))
151 self
.assertEqual("20 cm", get_state_as_dict(xWidth
)['Text'])
153 xHeight
.executeAction("FOCUS", tuple())
154 xHeight
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
155 xHeight
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
156 xHeight
.executeAction("TYPE", mkPropertyValues({"TEXT":"5 cm"}))
158 self
.assertEqual("5 cm", get_state_as_dict(xHeight
)['Text'])
160 # Move the focus to another element so the changes done before take effect on the document
161 xDialog
= self
.xUITest
.getTopFocusWindow()
162 xDialog
.getChild('numericfield-PositionY').executeAction("FOCUS", tuple())
164 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
165 xToolkit
.processEventsToIdle()
167 # Without the fix in place, the size of the form wouldn't have changed
168 self
.assertEqual(20001, shape
.getSize().Width
)
169 self
.assertEqual(5001, shape
.getSize().Height
)
171 def test_tdf138271(self
):
173 with self
.ui_test
.load_file(get_url_for_data_file("tdf138271.odt")):
175 self
.xUITest
.executeCommand(".uno:JumpToNextFrame")
177 aOldValue
= ["-1000000.00", "1000000.00"]
178 aNewValue
= ["-100.00", "100.00"]
180 for i
, name
in enumerate(['formattedcontrol-Value min.', 'formattedcontrol-Value max.']):
182 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button
=""):
183 xChild
= self
.ui_test
.wait_until_child_is_available(name
)
185 self
.assertEqual(aOldValue
[i
], get_state_as_dict(xChild
)['Text'])
187 xChild
.executeAction("FOCUS", tuple())
188 xChild
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
189 xChild
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
190 xChild
.executeAction("TYPE", mkPropertyValues({"TEXT": aNewValue
[i
]}))
192 #Close the dialog and open it again
193 self
.xUITest
.executeCommand(".uno:ControlProperties")
195 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button
=""):
196 xChild
= self
.ui_test
.wait_until_child_is_available(name
)
198 # Without the fix in place, this test would have failed here because
199 # the values wouldn't have changed
200 self
.assertEqual(aNewValue
[i
], get_state_as_dict(xChild
)['Text'])
202 self
.xUITest
.executeCommand(".uno:ControlProperties")
204 # vim: set shiftwidth=4 softtabstop=4 expandtab: