bump product version to 7.2.5.1
[LibreOffice.git] / svx / qa / uitest / table / tablecontroller.py
blob607df44a3a4f8eda93b4a80a7b978f830cc773c3
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from uitest.framework import UITestCase
8 from uitest.uihelper.common import select_pos
9 from libreoffice.uno.propertyvalue import mkPropertyValues
12 # Test for SvxTableController.
13 class SvxTableControllerTest(UITestCase):
15 def testOnFormatTable(self):
16 # Create an Impress document with a single table in it.
17 self.ui_test.create_doc_in_start_center("impress")
18 template = self.xUITest.getTopFocusWindow()
19 self.ui_test.close_dialog_through_button(template.getChild("close"))
20 self.xUITest.executeCommand(".uno:SelectAll")
21 self.xUITest.executeCommand(".uno:Delete")
22 self.xUITest.executeCommand(".uno:InsertTable?Columns:short=2&Rows:short=2")
24 # Enable shadow.
25 self.ui_test.execute_dialog_through_command(".uno:TableDialog")
26 tableDialog = self.xUITest.getTopFocusWindow()
27 tabs = tableDialog.getChild("tabcontrol")
28 # Select "shadow".
29 select_pos(tabs, "4")
30 shadowCheckbox = tableDialog.getChild("TSB_SHOW_SHADOW")
31 shadowCheckbox.executeAction("CLICK", tuple())
32 self.ui_test.close_dialog_through_button(tableDialog.getChild("ok"))
34 # Check if the shadow was enabled.
35 component = self.ui_test.get_component()
36 drawPage = component.getDrawPages().getByIndex(0)
37 shape = drawPage.getByIndex(0)
38 # Without the accompanying fix in place, this test would have failed with:
39 # AssertionError: False != True
40 # i.e. the table still had no shadow.
41 self.assertEqual(shape.Shadow, True)
43 # Close the document.
44 self.ui_test.close_doc()
46 def testUndoCrash(self):
47 # Given an Impress document with a single table in it:
48 self.ui_test.create_doc_in_start_center("impress")
49 template = self.xUITest.getTopFocusWindow()
50 self.ui_test.close_dialog_through_button(template.getChild("close"))
51 self.xUITest.executeCommand(".uno:SelectAll")
52 self.xUITest.executeCommand(".uno:Delete")
53 self.xUITest.executeCommand(".uno:InsertTable?Columns:short=3&Rows:short=3")
54 self.xUITest.executeCommand(".uno:SelectAll")
56 # When enabling shadow on the shape while text edit is active:
57 doc = self.xUITest.getTopFocusWindow()
58 impress = doc.getChild("impress_win")
59 impress.executeAction("TYPE", mkPropertyValues({"TEXT": "A1"}))
60 for i in range(6):
61 impress.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+TAB"}))
62 impress.executeAction("TYPE", mkPropertyValues({"TEXT": "A3"}))
63 self.xUITest.executeCommand(".uno:SelectAll")
64 self.ui_test.execute_dialog_through_command(".uno:TableDialog")
65 tableDialog = self.xUITest.getTopFocusWindow()
66 tabs = tableDialog.getChild("tabcontrol")
67 # Select "shadow".
68 select_pos(tabs, "4")
69 shadowCheckbox = tableDialog.getChild("TSB_SHOW_SHADOW")
70 shadowCheckbox.executeAction("CLICK", tuple())
71 self.ui_test.close_dialog_through_button(tableDialog.getChild("ok"))
73 # Then make sure we don't crash:
74 # Without the accompanying fix in place, this test would have failed crashed due to a
75 # use-after-free: text edit ended but an undo action of the text edit remained on the undo
76 # stack.
77 for i in range(2):
78 self.xUITest.executeCommand(".uno:Undo")
80 # Close the document.
81 self.ui_test.close_doc()
83 # vim: set shiftwidth=4 softtabstop=4 expandtab: