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/.
10 from uitest
.framework
import UITestCase
11 from uitest
.uihelper
.common
import select_pos
12 from com
.sun
.star
.awt
.GradientStyle
import LINEAR
13 from com
.sun
.star
.drawing
.HatchStyle
import SINGLE
14 from com
.sun
.star
.drawing
.BitmapMode
import REPEAT
15 from com
.sun
.star
.drawing
.RectanglePoint
import MIDDLE_MIDDLE
17 class ImpressBackgrounds(UITestCase
):
19 def checkDefaultBackground(self
, btn
):
20 document
= self
.ui_test
.get_component()
22 self
.assertEqual(document
.DrawPages
[0].Background
, None)
23 elif btn
== 'btncolor':
25 hex(document
.DrawPages
[0].Background
.FillColor
), '0x729fcf')
27 hex(document
.DrawPages
[0].Background
.FillColor
), '0x729fcf')
28 elif btn
== 'btngradient':
30 document
.DrawPages
[0].Background
.FillGradient
.Style
, LINEAR
)
32 hex(document
.DrawPages
[0].Background
.FillGradient
.StartColor
), '0xdde8cb')
34 document
.DrawPages
[0].Background
.FillGradient
.Angle
, 300)
36 document
.DrawPages
[0].Background
.FillGradient
.Border
, 0)
38 document
.DrawPages
[0].Background
.FillGradient
.XOffset
, 0)
40 document
.DrawPages
[0].Background
.FillGradient
.YOffset
, 0)
42 document
.DrawPages
[0].Background
.FillGradient
.StartIntensity
, 100)
44 document
.DrawPages
[0].Background
.FillGradient
.EndIntensity
, 100)
46 document
.DrawPages
[0].Background
.FillGradientName
, 'Pastel Bouquet')
47 elif btn
== 'btnhatch':
49 document
.DrawPages
[0].Background
.FillHatch
.Style
, SINGLE
)
51 document
.DrawPages
[0].Background
.FillHatch
.Color
, 0)
53 document
.DrawPages
[0].Background
.FillHatch
.Distance
, 102)
55 document
.DrawPages
[0].Background
.FillHatch
.Angle
, 0)
57 document
.DrawPages
[0].Background
.FillHatchName
, 'Black 0 Degrees')
58 elif btn
== 'btnbitmap':
60 document
.DrawPages
[0].Background
.FillBitmapMode
, REPEAT
)
62 document
.DrawPages
[0].Background
.FillBitmapPositionOffsetX
, 0)
64 document
.DrawPages
[0].Background
.FillBitmapPositionOffsetY
, 0)
66 document
.DrawPages
[0].Background
.FillBitmapRectanglePoint
, MIDDLE_MIDDLE
)
68 document
.DrawPages
[0].Background
.FillBitmapStretch
, False)
70 document
.DrawPages
[0].Background
.FillBitmapTile
, True)
72 document
.DrawPages
[0].Background
.FillBitmapOffsetX
, 0)
74 document
.DrawPages
[0].Background
.FillBitmapOffsetY
, 0)
76 document
.DrawPages
[0].Background
.FillBitmapLogicalSize
, True)
78 document
.DrawPages
[0].Background
.FillBitmapSizeX
, 2540)
80 document
.DrawPages
[0].Background
.FillBitmapSizeY
, 2540)
81 self
.assertEqual(document
.DrawPages
[0].Background
.FillBitmapName
, 'Painted White')
82 elif btn
== 'btnpattern':
84 document
.DrawPages
[0].Background
.FillBitmapMode
, REPEAT
)
86 document
.DrawPages
[0].Background
.FillBitmapPositionOffsetX
, 0)
88 document
.DrawPages
[0].Background
.FillBitmapPositionOffsetY
, 0)
90 document
.DrawPages
[0].Background
.FillBitmapRectanglePoint
, MIDDLE_MIDDLE
)
92 document
.DrawPages
[0].Background
.FillBitmapStretch
, True)
94 document
.DrawPages
[0].Background
.FillBitmapTile
, True)
96 document
.DrawPages
[0].Background
.FillBitmapOffsetX
, 0)
98 document
.DrawPages
[0].Background
.FillBitmapOffsetY
, 0)
100 document
.DrawPages
[0].Background
.FillBitmapLogicalSize
, True)
102 document
.DrawPages
[0].Background
.FillBitmapSizeX
, 0)
104 document
.DrawPages
[0].Background
.FillBitmapSizeY
, 0)
106 document
.DrawPages
[0].Background
.FillBitmapName
, '5 Percent')
109 def test_background_dialog(self
):
111 with self
.ui_test
.create_doc_in_start_center("impress"):
113 xTemplateDlg
= self
.xUITest
.getTopFocusWindow()
114 xCancelBtn
= xTemplateDlg
.getChild("close")
115 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
117 buttons
= ['btnbitmap', 'btncolor', 'btngradient', 'btnhatch', 'btnpattern']
118 for index
, button
in enumerate(buttons
):
119 with self
.ui_test
.execute_dialog_through_command(".uno:PageSetup") as xPageSetupDlg
:
121 tabcontrol
= xPageSetupDlg
.getChild("tabcontrol")
122 select_pos(tabcontrol
, "1")
124 xBtn
= xPageSetupDlg
.getChild(button
)
125 xBtn
.executeAction("CLICK", tuple())
127 # tdf#100024: Without the fix in place, this test would have crashed here
128 # changing the background to bitmap
130 self
.checkDefaultBackground(button
)
132 with self
.ui_test
.execute_dialog_through_command(".uno:PageSetup") as xPageSetupDlg
:
134 tabcontrol
= xPageSetupDlg
.getChild("tabcontrol")
135 select_pos(tabcontrol
, "1")
137 xBtn
= xPageSetupDlg
.getChild('btnnone')
138 xBtn
.executeAction("CLICK", tuple())
141 self
.checkDefaultBackground('btnnone')
144 # vim: set shiftwidth=4 softtabstop=4 expandtab: