Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / qa / uitest / table / tablecontroller.py
blob26390cb5c9632a3461c945ac9a5d2e662568a5b2
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 with self.ui_test.create_doc_in_start_center("impress") as component:
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 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as tableDialog:
26 tabs = tableDialog.getChild("tabcontrol")
27 # Select "shadow".
28 select_pos(tabs, "4")
29 shadowCheckbox = tableDialog.getChild("TSB_SHOW_SHADOW")
30 shadowCheckbox.executeAction("CLICK", tuple())
32 # Check if the shadow was enabled.
33 drawPage = component.getDrawPages().getByIndex(0)
34 shape = drawPage.getByIndex(0)
35 # Without the accompanying fix in place, this test would have failed with:
36 # AssertionError: False != True
37 # i.e. the table still had no shadow.
38 self.assertEqual(shape.Shadow, True)
40 # Close the document.
42 def testUndoCrash(self):
43 # Given an Impress document with a single table in it:
44 with self.ui_test.create_doc_in_start_center("impress"):
45 template = self.xUITest.getTopFocusWindow()
46 self.ui_test.close_dialog_through_button(template.getChild("close"))
47 self.xUITest.executeCommand(".uno:SelectAll")
48 self.xUITest.executeCommand(".uno:Delete")
49 self.xUITest.executeCommand(".uno:InsertTable?Columns:short=3&Rows:short=3")
50 self.xUITest.executeCommand(".uno:SelectAll")
52 # When enabling shadow on the shape while text edit is active:
53 doc = self.xUITest.getTopFocusWindow()
54 impress = doc.getChild("impress_win")
55 impress.executeAction("TYPE", mkPropertyValues({"TEXT": "A1"}))
56 for i in range(6):
57 impress.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+TAB"}))
58 impress.executeAction("TYPE", mkPropertyValues({"TEXT": "A3"}))
59 self.xUITest.executeCommand(".uno:SelectAll")
60 with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as tableDialog:
61 tabs = tableDialog.getChild("tabcontrol")
62 # Select "shadow".
63 select_pos(tabs, "4")
64 shadowCheckbox = tableDialog.getChild("TSB_SHOW_SHADOW")
65 shadowCheckbox.executeAction("CLICK", tuple())
67 # Then make sure we don't crash:
68 # Without the accompanying fix in place, this test would have failed crashed due to a
69 # use-after-free: text edit ended but an undo action of the text edit remained on the undo
70 # stack.
71 for i in range(2):
72 self.xUITest.executeCommand(".uno:Undo")
74 # Close the document.
76 # vim: set shiftwidth=4 softtabstop=4 expandtab: