Fix typo
[LibreOffice.git] / uitest / impress_tests / backgrounds.py
blob1bfeab320eccae1dafbc6473e61257a4861a0f2a
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()
21 if btn == 'btnnone':
22 self.assertEqual(document.DrawPages[0].Background, None)
23 elif btn == 'btncolor':
24 self.assertEqual(
25 hex(document.DrawPages[0].Background.FillColor), '0x729fcf')
26 self.assertEqual(
27 hex(document.DrawPages[0].Background.FillColor), '0x729fcf')
28 elif btn == 'btngradient':
29 self.assertEqual(
30 document.DrawPages[0].Background.FillGradient.Style, LINEAR)
31 self.assertEqual(
32 hex(document.DrawPages[0].Background.FillGradient.StartColor), '0xdde8cb')
33 self.assertEqual(
34 document.DrawPages[0].Background.FillGradient.Angle, 300)
35 self.assertEqual(
36 document.DrawPages[0].Background.FillGradient.Border, 0)
37 self.assertEqual(
38 document.DrawPages[0].Background.FillGradient.XOffset, 0)
39 self.assertEqual(
40 document.DrawPages[0].Background.FillGradient.YOffset, 0)
41 self.assertEqual(
42 document.DrawPages[0].Background.FillGradient.StartIntensity, 100)
43 self.assertEqual(
44 document.DrawPages[0].Background.FillGradient.EndIntensity, 100)
45 self.assertEqual(
46 document.DrawPages[0].Background.FillGradientName, 'Pastel Bouquet')
47 elif btn == 'btnhatch':
48 self.assertEqual(
49 document.DrawPages[0].Background.FillHatch.Style, SINGLE )
50 self.assertEqual(
51 document.DrawPages[0].Background.FillHatch.Color, 0)
52 self.assertEqual(
53 document.DrawPages[0].Background.FillHatch.Distance, 102)
54 self.assertEqual(
55 document.DrawPages[0].Background.FillHatch.Angle, 0)
56 self.assertEqual(
57 document.DrawPages[0].Background.FillHatchName, 'Black 0 Degrees')
58 elif btn == 'btnbitmap':
59 self.assertEqual(
60 document.DrawPages[0].Background.FillBitmapMode, REPEAT)
61 self.assertEqual(
62 document.DrawPages[0].Background.FillBitmapPositionOffsetX, 0)
63 self.assertEqual(
64 document.DrawPages[0].Background.FillBitmapPositionOffsetY, 0)
65 self.assertEqual(
66 document.DrawPages[0].Background.FillBitmapRectanglePoint, MIDDLE_MIDDLE)
67 self.assertEqual(
68 document.DrawPages[0].Background.FillBitmapStretch, False)
69 self.assertEqual(
70 document.DrawPages[0].Background.FillBitmapTile, True)
71 self.assertEqual(
72 document.DrawPages[0].Background.FillBitmapOffsetX, 0)
73 self.assertEqual(
74 document.DrawPages[0].Background.FillBitmapOffsetY, 0)
75 self.assertEqual(
76 document.DrawPages[0].Background.FillBitmapLogicalSize, True)
77 self.assertEqual(
78 document.DrawPages[0].Background.FillBitmapSizeX, 2540)
79 self.assertEqual(
80 document.DrawPages[0].Background.FillBitmapSizeY, 2540)
81 self.assertEqual(document.DrawPages[0].Background.FillBitmapName, 'Painted White')
82 elif btn == 'btnpattern':
83 self.assertEqual(
84 document.DrawPages[0].Background.FillBitmapMode, REPEAT)
85 self.assertEqual(
86 document.DrawPages[0].Background.FillBitmapPositionOffsetX, 0)
87 self.assertEqual(
88 document.DrawPages[0].Background.FillBitmapPositionOffsetY, 0)
89 self.assertEqual(
90 document.DrawPages[0].Background.FillBitmapRectanglePoint, MIDDLE_MIDDLE)
91 self.assertEqual(
92 document.DrawPages[0].Background.FillBitmapStretch, True)
93 self.assertEqual(
94 document.DrawPages[0].Background.FillBitmapTile, True)
95 self.assertEqual(
96 document.DrawPages[0].Background.FillBitmapOffsetX, 0)
97 self.assertEqual(
98 document.DrawPages[0].Background.FillBitmapOffsetY, 0)
99 self.assertEqual(
100 document.DrawPages[0].Background.FillBitmapLogicalSize, True)
101 self.assertEqual(
102 document.DrawPages[0].Background.FillBitmapSizeX, 0)
103 self.assertEqual(
104 document.DrawPages[0].Background.FillBitmapSizeY, 0)
105 self.assertEqual(
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: