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