1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from uitest
.framework
import UITestCase
8 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
9 from uitest
.uihelper
.common
import get_state_as_dict
11 from uitest
.debug
import sleep
12 from uitest
.uihelper
.common
import select_pos
15 class watermark(UITestCase
):
17 def test_insert_watermark(self
):
18 self
.ui_test
.create_doc_in_start_center("writer")
19 document
= self
.ui_test
.get_component()
20 xWriterDoc
= self
.xUITest
.getTopFocusWindow()
21 xWriterEdit
= xWriterDoc
.getChild("writer_edit")
23 self
.ui_test
.execute_dialog_through_command(".uno:Watermark")
24 xDialog
= self
.xUITest
.getTopFocusWindow()
25 xTextInput
= xDialog
.getChild("TextInput")
26 xAngle
= xDialog
.getChild("Angle")
27 xTransparency
= xDialog
.getChild("Transparency")
29 xTextInput
.executeAction("TYPE", mkPropertyValues({"TEXT":"Watermark"}))
30 xAngle
.executeAction("UP", tuple())
31 xTransparency
.executeAction("UP", tuple())
33 xOkBtn
= xDialog
.getChild("ok")
34 self
.ui_test
.close_dialog_through_button(xOkBtn
)
36 self
.ui_test
.execute_dialog_through_command(".uno:Watermark")
37 xDialog
= self
.xUITest
.getTopFocusWindow()
38 xTextInput
= xDialog
.getChild("TextInput")
39 xAngle
= xDialog
.getChild("Angle")
40 xTransparency
= xDialog
.getChild("Transparency")
42 self
.assertEqual(get_state_as_dict(xTextInput
)["Text"], "Watermark")
43 self
.assertEqual(get_state_as_dict(xAngle
)["Text"], "46°")
44 self
.assertEqual(get_state_as_dict(xTransparency
)["Text"], "51%")
46 xCancBtn
= xDialog
.getChild("cancel")
47 self
.ui_test
.close_dialog_through_button(xCancBtn
)
49 self
.ui_test
.execute_dialog_through_command(".uno:Watermark")
50 xDialog
= self
.xUITest
.getTopFocusWindow()
51 xTextInput
= xDialog
.getChild("TextInput")
52 xTextInput
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
53 xTextInput
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
54 xOkBtn
= xDialog
.getChild("ok")
55 self
.ui_test
.close_dialog_through_button(xOkBtn
)
57 self
.ui_test
.execute_dialog_through_command(".uno:Watermark")
58 xDialog
= self
.xUITest
.getTopFocusWindow()
59 xTextInput
= xDialog
.getChild("TextInput")
61 self
.assertEqual(get_state_as_dict(xTextInput
)["Text"], "")
63 xCancBtn
= xDialog
.getChild("cancel")
64 self
.ui_test
.close_dialog_through_button(xCancBtn
)
66 self
.ui_test
.close_doc()
67 # vim: set shiftwidth=4 softtabstop=4 expandtab: