Get the style color and number just once
[LibreOffice.git] / sw / qa / uitest / writer_tests7 / tdf137802.py
blobd545d406db37686aa5a825f0a68310a02570e159
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_url_for_data_file
11 from libreoffice.uno.propertyvalue import mkPropertyValues
12 from com.sun.star.text.TextContentAnchorType import AT_PAGE, AT_PARAGRAPH
14 class tdf137802(UITestCase):
16 def test_tdf137802(self):
18 with self.ui_test.load_file(get_url_for_data_file("tdf137802.odt")) as document:
20 xWriterDoc = self.xUITest.getTopFocusWindow()
21 xWriterEdit = xWriterDoc.getChild("writer_edit")
23 self.assertEqual(len(document.DrawPage), 2)
24 self.assertEqual(AT_PARAGRAPH, document.DrawPage[0].AnchorType)
26 self.xUITest.executeCommand(".uno:JumpToNextFrame")
28 self.ui_test.wait_until_child_is_available('metricfield')
30 with self.ui_test.execute_dialog_through_command(".uno:TransformDialog") as xDialog:
33 xDialog.getChild('topage').executeAction("CLICK", tuple())
36 self.assertEqual(AT_PAGE, document.DrawPage[0].AnchorType)
38 self.assertEqual(len(document.DrawPage), 2)
40 xWriterDoc = self.xUITest.getTopFocusWindow()
41 xWriterEdit = xWriterDoc.getChild("writer_edit")
43 # When shape 1 is selected, esc key doesn't put the focus back to the document
44 # because the shape has a textbox. Move the focus to another shape with tab key
45 # and then use escape
46 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
47 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ESC"}))
49 # Wait until the shape is deselected and the cursor is on the document
50 self.ui_test.wait_until_child_is_available('FontNameBox')
52 # Delete the second paragraph. Shape 2 is anchored to this paragraph
53 # so it should be deleted
54 # tdf#137587 fly is no longer deleted by backspace so explicitly select
55 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "SHIFT+LEFT"}))
56 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
58 self.assertEqual(len(document.DrawPage), 1)
60 self.xUITest.executeCommand(".uno:JumpToNextFrame")
61 self.xUITest.executeCommand(".uno:Delete")
63 self.assertEqual(len(document.DrawPage), 0)
65 self.xUITest.executeCommand(".uno:Undo")
67 self.assertEqual(len(document.DrawPage), 1)
69 self.xUITest.executeCommand(".uno:Undo")
71 self.assertEqual(len(document.DrawPage), 2)
73 self.xUITest.executeCommand(".uno:Undo")
75 self.assertEqual(AT_PARAGRAPH, document.DrawPage[0].AnchorType)
77 # vim: set shiftwidth=4 softtabstop=4 expandtab: