Debian Codegraph @

sw/qa/uitest/writer_tests8/tdf125969.py

raw symbols SCIP
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
2 #
3 # This file is part of the LibreOffice project.
4 #
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/.
8 #
9 from libreoffice.uno.propertyvalue import mkPropertyValues
10
11 from uitest.framework import UITestCase
12 from uitest.uihelper.common import get_url_for_data_file
13 from uitest.uihelper.common import select_pos, get_state_as_dict
14
15 # bug 125969: make in-use bitmap-area-fill available for re-use, but ONLY IN THE SAME DOCUMENT
16 class tdf125969(UITestCase):
17
18 number_of_images = 0
19
20 def test_tdf125969(self):
21 with self.ui_test.load_file(get_url_for_data_file("paragraphAreaFill.odt")):
22 xWriterDoc = self.xUITest.getTopFocusWindow()
23 xWriterEdit = xWriterDoc.getChild("writer_edit")
24
25 self.xUITest.executeCommand(".uno:Sidebar") #turn on sidebar
26 xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "PageStylesPanel"}))
27
28 # Get baseline from sidebar: count number of initially available bitmaps by default
29 backgroundType = xWriterEdit.getChild('bgselect') #type of background: color, gradient, ...
30 self.ui_test.wait_until_property_is_updated(backgroundType, "SelectEntryText", "Bitmap")
31
32 imageCollection = xWriterEdit.getChild("lbbitmap") #listbox containing image names
33 number_of_images = int(get_state_as_dict(imageCollection)["EntryCount"])
34
35 # The paragraph area has a custom background logo - which we want to become available
36 # for re-use everywhere as a background fill
37
38 # visit the paragraph background property - which now auto-adds it to the collection
39 with self.ui_test.execute_dialog_through_command(".uno:ParagraphDialog", close_button="cancel") as xDialog:
40 tabcontrol = xDialog.getChild("tabcontrol")
41 select_pos(tabcontrol, "8") # area tab
42
43 # test: the paragraph's wasta-offline logo was added and the list box was refreshed
44 self.ui_test.wait_until_property_is_updated(imageCollection, "EntryCount", str(number_of_images + 1))
45 self.assertEqual(number_of_images + 1, int(get_state_as_dict(imageCollection)["EntryCount"]))
46 self.assertEqual("Painted White", get_state_as_dict(imageCollection)["SelectEntryText"])
47
48 # A new document must not have access to the collected images from another document
49 with self.ui_test.load_empty_file("writer"):
50 xWriterDoc = self.xUITest.getTopFocusWindow()
51 xWriterEdit = xWriterDoc.getChild("writer_edit")
52
53 # because I don't know how to change the sidebar to bitmap mode, use the page dialog
54 with self.ui_test.execute_dialog_through_command(".uno:PageDialog", close_button="ok") as xDialog:
55 tabcontrol = xDialog.getChild("tabcontrol")
56 select_pos(tabcontrol, "2") # area tab
57 xButton = xDialog.getChild('btnbitmap')
58 xButton.executeAction("CLICK", tuple())
59
60 backgroundType = xWriterEdit.getChild('bgselect')
61 imageCollection = xWriterEdit.getChild("lbbitmap")
62 self.ui_test.wait_until_property_is_updated(backgroundType, "SelectEntryText", "Bitmap")
63 # This number MUST NOT be higher than the initial state.
64 # We must not allow document images to leak into the user profile
65 self.assertEqual(number_of_images, int(get_state_as_dict(imageCollection)["EntryCount"]))
66
67 self.xUITest.executeCommand(".uno:Sidebar") # good idea to turn off sidebar again
68 # vim: set shiftwidth=4 softtabstop=4 expandtab: