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()
19 self
.assertEqual(document
.DrawPages
.getByIndex(0).Background
, None)
20 elif btn
== 'btncolor':
22 hex(document
.DrawPages
.getByIndex(0).Background
.FillColor
), '0x729fcf')
24 hex(document
.DrawPages
.getByIndex(0).Background
.FillColor
), '0x729fcf')
25 elif btn
== 'btngradient':
27 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.Style
, LINEAR
)
29 hex(document
.DrawPages
.getByIndex(0).Background
.FillGradient
.StartColor
), '0xdde8cb')
31 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.Angle
, 300)
33 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.Border
, 0)
35 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.XOffset
, 0)
37 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.YOffset
, 0)
39 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.StartIntensity
, 100)
41 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.EndIntensity
, 100)
43 document
.DrawPages
.getByIndex(0).Background
.FillGradientName
, 'Pastel Bouquet')
44 elif btn
== 'btnhatch':
46 document
.DrawPages
.getByIndex(0).Background
.FillHatch
.Style
, SINGLE
)
48 document
.DrawPages
.getByIndex(0).Background
.FillHatch
.Color
, 0)
50 document
.DrawPages
.getByIndex(0).Background
.FillHatch
.Distance
, 102)
52 document
.DrawPages
.getByIndex(0).Background
.FillHatch
.Angle
, 0)
54 document
.DrawPages
.getByIndex(0).Background
.FillHatchName
, 'Black 0 Degrees')
55 elif btn
== 'btnbitmap':
57 document
.DrawPages
.getByIndex(0).Background
.FillBitmapMode
, REPEAT
)
59 document
.DrawPages
.getByIndex(0).Background
.FillBitmapPositionOffsetX
, 0)
61 document
.DrawPages
.getByIndex(0).Background
.FillBitmapPositionOffsetY
, 0)
63 document
.DrawPages
.getByIndex(0).Background
.FillBitmapRectanglePoint
, MIDDLE_MIDDLE
)
65 document
.DrawPages
.getByIndex(0).Background
.FillBitmapStretch
, False)
67 document
.DrawPages
.getByIndex(0).Background
.FillBitmapTile
, True)
69 document
.DrawPages
.getByIndex(0).Background
.FillBitmapOffsetX
, 0)
71 document
.DrawPages
.getByIndex(0).Background
.FillBitmapOffsetY
, 0)
73 document
.DrawPages
.getByIndex(0).Background
.FillBitmapLogicalSize
, True)
75 document
.DrawPages
.getByIndex(0).Background
.FillBitmapSizeX
, 0)
77 document
.DrawPages
.getByIndex(0).Background
.FillBitmapSizeY
, 0)
78 self
.assertEqual(document
.DrawPages
.getByIndex(0).Background
.FillBitmapName
, 'Painted White')
79 elif btn
== 'btnpattern':
81 document
.DrawPages
.getByIndex(0).Background
.FillBitmapMode
, REPEAT
)
83 document
.DrawPages
.getByIndex(0).Background
.FillBitmapPositionOffsetX
, 0)
85 document
.DrawPages
.getByIndex(0).Background
.FillBitmapPositionOffsetY
, 0)
87 document
.DrawPages
.getByIndex(0).Background
.FillBitmapRectanglePoint
, MIDDLE_MIDDLE
)
89 document
.DrawPages
.getByIndex(0).Background
.FillBitmapStretch
, True)
91 document
.DrawPages
.getByIndex(0).Background
.FillBitmapTile
, True)
93 document
.DrawPages
.getByIndex(0).Background
.FillBitmapOffsetX
, 0)
95 document
.DrawPages
.getByIndex(0).Background
.FillBitmapOffsetY
, 0)
97 document
.DrawPages
.getByIndex(0).Background
.FillBitmapLogicalSize
, True)
99 document
.DrawPages
.getByIndex(0).Background
.FillBitmapSizeX
, 0)
101 document
.DrawPages
.getByIndex(0).Background
.FillBitmapSizeY
, 0)
103 document
.DrawPages
.getByIndex(0).Background
.FillBitmapName
, '5 Percent')
106 def test_background_dialog(self
):
108 self
.ui_test
.create_doc_in_start_center("impress")
110 xTemplateDlg
= self
.xUITest
.getTopFocusWindow()
111 xCancelBtn
= xTemplateDlg
.getChild("cancel")
112 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
114 buttons
= ['btnbitmap', 'btncolor', 'btngradient', 'btnhatch', 'btnpattern']
115 for index
, button
in enumerate(buttons
):
116 self
.ui_test
.execute_dialog_through_command(".uno:PageSetup")
118 xPageSetupDlg
= self
.xUITest
.getTopFocusWindow()
119 tabcontrol
= xPageSetupDlg
.getChild("tabcontrol")
120 select_pos(tabcontrol
, "1")
122 xBtn
= xPageSetupDlg
.getChild(button
)
123 xBtn
.executeAction("CLICK", tuple())
125 xOkBtn
= xPageSetupDlg
.getChild("ok")
126 xOkBtn
.executeAction("CLICK", tuple())
128 self
.checkDefaultBackground(button
)
130 self
.ui_test
.execute_dialog_through_command(".uno:PageSetup")
132 xPageSetupDlg
= self
.xUITest
.getTopFocusWindow()
133 tabcontrol
= xPageSetupDlg
.getChild("tabcontrol")
134 select_pos(tabcontrol
, "1")
136 xBtn
= xPageSetupDlg
.getChild('btnnone')
137 xBtn
.executeAction("CLICK", tuple())
139 xOkBtn
= xPageSetupDlg
.getChild("ok")
140 xOkBtn
.executeAction("CLICK", tuple())
142 self
.checkDefaultBackground('btnnone')
144 self
.ui_test
.close_doc()
146 # vim: set shiftwidth=4 softtabstop=4 expandtab: