Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / uitest / writer_tests7 / forms.py
blob3d6cbf4108887ecb490199dea9c5bd8b5456ce77
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 drawPage = document.getDrawPages().getByIndex(0)
136 shape = drawPage.getByIndex(0)
137 self.assertEqual(13996, shape.getSize().Width)
138 self.assertEqual(2408, shape.getSize().Height)
140 with self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button=""):
141 xWidth = self.ui_test.wait_until_child_is_available('numericfield-Width')
142 xHeight = self.ui_test.wait_until_child_is_available('numericfield-Height')
144 self.assertEqual("14.00 cm", get_state_as_dict(xWidth)['Text'])
145 self.assertEqual("2.41 cm", get_state_as_dict(xHeight)['Text'])
147 xWidth.executeAction("FOCUS", tuple())
148 xWidth.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
149 xWidth.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
150 xWidth.executeAction("TYPE", mkPropertyValues({"TEXT":"20 cm"}))
152 self.assertEqual("20 cm", get_state_as_dict(xWidth)['Text'])
154 xHeight.executeAction("FOCUS", tuple())
155 xHeight.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
156 xHeight.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
157 xHeight.executeAction("TYPE", mkPropertyValues({"TEXT":"5 cm"}))
159 self.assertEqual("5 cm", get_state_as_dict(xHeight)['Text'])
161 # Move the focus to another element so the changes done before take effect on the document
162 xDialog = self.xUITest.getTopFocusWindow()
163 xDialog.getChild('numericfield-PositionY').executeAction("FOCUS", tuple())
165 xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
166 xToolkit.processEventsToIdle()
168 # Without the fix in place, the size of the form wouldn't have changed
169 self.assertEqual(20001, shape.getSize().Width)
170 self.assertEqual(5001, shape.getSize().Height)
172 def test_tdf138271(self):
174 with self.ui_test.load_file(get_url_for_data_file("tdf138271.odt")):
176 self.xUITest.executeCommand(".uno:JumpToNextFrame")
178 aOldValue = ["-1000000.00", "1000000.00"]
179 aNewValue = ["-100.00", "100.00"]
181 for i, name in enumerate(['formattedcontrol-Value min.', 'formattedcontrol-Value max.']):
183 with self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button=""):
184 xChild = self.ui_test.wait_until_child_is_available(name)
186 self.assertEqual(aOldValue[i], get_state_as_dict(xChild)['Text'])
188 xChild.executeAction("FOCUS", tuple())
189 xChild.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
190 xChild.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
191 xChild.executeAction("TYPE", mkPropertyValues({"TEXT": aNewValue[i]}))
193 #Close the dialog and open it again
194 self.xUITest.executeCommand(".uno:ControlProperties")
196 with self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button=""):
197 xChild = self.ui_test.wait_until_child_is_available(name)
199 # Without the fix in place, this test would have failed here because
200 # the values wouldn't have changed
201 self.assertEqual(aNewValue[i], get_state_as_dict(xChild)['Text'])
203 self.xUITest.executeCommand(".uno:ControlProperties")
205 # vim: set shiftwidth=4 softtabstop=4 expandtab: