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':
21 self
.assertEqual(document
.DrawPages
.getByIndex(0).Background
.FillColor
, 7512015)
22 self
.assertEqual(document
.DrawPages
.getByIndex(0).Background
.FillColor
, 7512015)
23 elif btn
== 'btngradient':
25 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.Style
, LINEAR
)
27 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.StartColor
, 9101876)
29 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.Angle
, 300)
31 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.Border
, 0)
33 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.XOffset
, 0)
35 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.YOffset
, 0)
37 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.StartIntensity
, 100)
39 document
.DrawPages
.getByIndex(0).Background
.FillGradient
.EndIntensity
, 100)
41 #document.DrawPages.getByIndex(0).Background.FillGradientName, 'Tango Green')
42 elif btn
== 'btnhatch':
44 document
.DrawPages
.getByIndex(0).Background
.FillHatch
.Style
, SINGLE
)
46 document
.DrawPages
.getByIndex(0).Background
.FillHatch
.Color
, 0)
48 document
.DrawPages
.getByIndex(0).Background
.FillHatch
.Distance
, 102)
50 document
.DrawPages
.getByIndex(0).Background
.FillHatch
.Angle
, 0)
52 document
.DrawPages
.getByIndex(0).Background
.FillHatchName
, 'Black 0 Degrees')
53 elif btn
== 'btnbitmap':
55 document
.DrawPages
.getByIndex(0).Background
.FillBitmapMode
, REPEAT
)
57 document
.DrawPages
.getByIndex(0).Background
.FillBitmapPositionOffsetX
, 0)
59 document
.DrawPages
.getByIndex(0).Background
.FillBitmapPositionOffsetY
, 0)
61 document
.DrawPages
.getByIndex(0).Background
.FillBitmapRectanglePoint
, MIDDLE_MIDDLE
)
63 document
.DrawPages
.getByIndex(0).Background
.FillBitmapStretch
, False)
65 document
.DrawPages
.getByIndex(0).Background
.FillBitmapTile
, True)
67 document
.DrawPages
.getByIndex(0).Background
.FillBitmapOffsetX
, 0)
69 document
.DrawPages
.getByIndex(0).Background
.FillBitmapOffsetY
, 0)
71 document
.DrawPages
.getByIndex(0).Background
.FillBitmapLogicalSize
, True)
73 document
.DrawPages
.getByIndex(0).Background
.FillBitmapSizeX
, 0)
75 document
.DrawPages
.getByIndex(0).Background
.FillBitmapSizeY
, 0)
76 self
.assertEqual(document
.DrawPages
.getByIndex(0).Background
.FillBitmapName
, 'Sky')
77 elif btn
== 'btnpattern':
79 document
.DrawPages
.getByIndex(0).Background
.FillBitmapMode
, REPEAT
)
81 document
.DrawPages
.getByIndex(0).Background
.FillBitmapPositionOffsetX
, 0)
83 document
.DrawPages
.getByIndex(0).Background
.FillBitmapPositionOffsetY
, 0)
85 document
.DrawPages
.getByIndex(0).Background
.FillBitmapRectanglePoint
, MIDDLE_MIDDLE
)
87 document
.DrawPages
.getByIndex(0).Background
.FillBitmapStretch
, True)
89 document
.DrawPages
.getByIndex(0).Background
.FillBitmapTile
, True)
91 document
.DrawPages
.getByIndex(0).Background
.FillBitmapOffsetX
, 0)
93 document
.DrawPages
.getByIndex(0).Background
.FillBitmapOffsetY
, 0)
95 document
.DrawPages
.getByIndex(0).Background
.FillBitmapLogicalSize
, True)
97 document
.DrawPages
.getByIndex(0).Background
.FillBitmapSizeX
, 0)
99 document
.DrawPages
.getByIndex(0).Background
.FillBitmapSizeY
, 0)
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: