Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / uitest / impress_tests / backgrounds.py
blob4e904899574caec01085b42c503091f953ea8196
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 com.sun.star.awt.GradientStyle import LINEAR
10 from com.sun.star.drawing.HatchStyle import SINGLE
11 from com.sun.star.drawing.BitmapMode import REPEAT
12 from com.sun.star.drawing.RectanglePoint import MIDDLE_MIDDLE
14 class ImpressBackgrounds(UITestCase):
16 def checkDefaultBackground(self, btn):
17 document = self.ui_test.get_component()
18 if btn == 'btnnone':
19 self.assertEqual(document.DrawPages.getByIndex(0).Background, None)
20 elif btn == 'btncolor':
21 self.assertEqual(document.DrawPages.getByIndex(0).Background.FillColor, 7512015)
22 self.assertEqual(document.DrawPages.getByIndex(0).Background.FillColor, 7512015)
23 elif btn == 'btngradient':
24 self.assertEqual(
25 document.DrawPages.getByIndex(0).Background.FillGradient.Style, LINEAR)
26 self.assertEqual(
27 document.DrawPages.getByIndex(0).Background.FillGradient.StartColor, 9101876)
28 self.assertEqual(
29 document.DrawPages.getByIndex(0).Background.FillGradient.Angle, 300)
30 self.assertEqual(
31 document.DrawPages.getByIndex(0).Background.FillGradient.Border, 0)
32 self.assertEqual(
33 document.DrawPages.getByIndex(0).Background.FillGradient.XOffset, 0)
34 self.assertEqual(
35 document.DrawPages.getByIndex(0).Background.FillGradient.YOffset, 0)
36 self.assertEqual(
37 document.DrawPages.getByIndex(0).Background.FillGradient.StartIntensity, 100)
38 self.assertEqual(
39 document.DrawPages.getByIndex(0).Background.FillGradient.EndIntensity, 100)
40 #self.assertEqual(
41 #document.DrawPages.getByIndex(0).Background.FillGradientName, 'Tango Green')
42 elif btn == 'btnhatch':
43 self.assertEqual(
44 document.DrawPages.getByIndex(0).Background.FillHatch.Style, SINGLE )
45 self.assertEqual(
46 document.DrawPages.getByIndex(0).Background.FillHatch.Color, 0)
47 self.assertEqual(
48 document.DrawPages.getByIndex(0).Background.FillHatch.Distance, 102)
49 self.assertEqual(
50 document.DrawPages.getByIndex(0).Background.FillHatch.Angle, 0)
51 self.assertEqual(
52 document.DrawPages.getByIndex(0).Background.FillHatchName, 'Black 0 Degrees')
53 elif btn == 'btnbitmap':
54 self.assertEqual(
55 document.DrawPages.getByIndex(0).Background.FillBitmapMode, REPEAT)
56 self.assertEqual(
57 document.DrawPages.getByIndex(0).Background.FillBitmapPositionOffsetX, 0)
58 self.assertEqual(
59 document.DrawPages.getByIndex(0).Background.FillBitmapPositionOffsetY, 0)
60 self.assertEqual(
61 document.DrawPages.getByIndex(0).Background.FillBitmapRectanglePoint, MIDDLE_MIDDLE)
62 self.assertEqual(
63 document.DrawPages.getByIndex(0).Background.FillBitmapStretch, False)
64 self.assertEqual(
65 document.DrawPages.getByIndex(0).Background.FillBitmapTile, True)
66 self.assertEqual(
67 document.DrawPages.getByIndex(0).Background.FillBitmapOffsetX, 0)
68 self.assertEqual(
69 document.DrawPages.getByIndex(0).Background.FillBitmapOffsetY, 0)
70 self.assertEqual(
71 document.DrawPages.getByIndex(0).Background.FillBitmapLogicalSize, True)
72 self.assertEqual(
73 document.DrawPages.getByIndex(0).Background.FillBitmapSizeX, 0)
74 self.assertEqual(
75 document.DrawPages.getByIndex(0).Background.FillBitmapSizeY, 0)
76 self.assertEqual(document.DrawPages.getByIndex(0).Background.FillBitmapName, 'Sky')
77 elif btn == 'btnpattern':
78 self.assertEqual(
79 document.DrawPages.getByIndex(0).Background.FillBitmapMode, REPEAT)
80 self.assertEqual(
81 document.DrawPages.getByIndex(0).Background.FillBitmapPositionOffsetX, 0)
82 self.assertEqual(
83 document.DrawPages.getByIndex(0).Background.FillBitmapPositionOffsetY, 0)
84 self.assertEqual(
85 document.DrawPages.getByIndex(0).Background.FillBitmapRectanglePoint, MIDDLE_MIDDLE)
86 self.assertEqual(
87 document.DrawPages.getByIndex(0).Background.FillBitmapStretch, True)
88 self.assertEqual(
89 document.DrawPages.getByIndex(0).Background.FillBitmapTile, True)
90 self.assertEqual(
91 document.DrawPages.getByIndex(0).Background.FillBitmapOffsetX, 0)
92 self.assertEqual(
93 document.DrawPages.getByIndex(0).Background.FillBitmapOffsetY, 0)
94 self.assertEqual(
95 document.DrawPages.getByIndex(0).Background.FillBitmapLogicalSize, True)
96 self.assertEqual(
97 document.DrawPages.getByIndex(0).Background.FillBitmapSizeX, 0)
98 self.assertEqual(
99 document.DrawPages.getByIndex(0).Background.FillBitmapSizeY, 0)
100 self.assertEqual(
101 document.DrawPages.getByIndex(0).Background.FillBitmapName, '5 Percent')
104 def test_background_dialog(self):
106 self.ui_test.create_doc_in_start_center("impress")
108 xTemplateDlg = self.xUITest.getTopFocusWindow()
109 xCancelBtn = xTemplateDlg.getChild("cancel")
110 self.ui_test.close_dialog_through_button(xCancelBtn)
112 buttons = ['btnbitmap', 'btncolor', 'btngradient', 'btnhatch', 'btnpattern']
113 for index, button in enumerate(buttons):
114 self.ui_test.execute_dialog_through_command(".uno:PageSetup")
116 xPageSetupDlg = self.xUITest.getTopFocusWindow()
117 tabcontrol = xPageSetupDlg.getChild("tabcontrol")
118 select_pos(tabcontrol, "1")
120 xBtn = xPageSetupDlg.getChild(button)
121 xBtn.executeAction("CLICK", tuple())
123 xOkBtn = xPageSetupDlg.getChild("ok")
124 xOkBtn.executeAction("CLICK", tuple())
126 xConfirmDlg = self.xUITest.getTopFocusWindow()
128 xNoBtn = xConfirmDlg.getChild("no")
129 xNoBtn.executeAction("CLICK", tuple())
131 self.checkDefaultBackground(button)
133 self.ui_test.execute_dialog_through_command(".uno:PageSetup")
135 xPageSetupDlg = self.xUITest.getTopFocusWindow()
136 tabcontrol = xPageSetupDlg.getChild("tabcontrol")
137 select_pos(tabcontrol, "1")
139 xBtn = xPageSetupDlg.getChild('btnnone')
140 xBtn.executeAction("CLICK", tuple())
142 xOkBtn = xPageSetupDlg.getChild("ok")
143 xOkBtn.executeAction("CLICK", tuple())
145 xConfirmDlg = self.xUITest.getTopFocusWindow()
147 xNoBtn = xConfirmDlg.getChild("no")
148 xNoBtn.executeAction("CLICK", tuple())
150 self.checkDefaultBackground('btnnone')
152 self.ui_test.close_doc()
154 # vim: set shiftwidth=4 softtabstop=4 expandtab: