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
.uihelper
.common
import get_state_as_dict
11 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
12 from uitest
.uihelper
.common
import change_measurement_unit
13 from uitest
.framework
import UITestCase
15 class ImpressDrawinglayerTest(UITestCase
):
17 def test_move_object(self
):
18 with self
.ui_test
.create_doc_in_start_center("impress") as document
:
20 xTemplateDlg
= self
.xUITest
.getTopFocusWindow()
21 xCancelBtn
= xTemplateDlg
.getChild("close")
22 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
24 with
change_measurement_unit(self
, 'Centimeter'):
26 xImpressDoc
= self
.xUITest
.getTopFocusWindow()
28 self
.assertIsNone(document
.CurrentSelection
)
30 xEditWin
= xImpressDoc
.getChild("impress_win")
31 xEditWin
.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
32 self
.assertEqual("com.sun.star.drawing.SvxShapeCollection", document
.CurrentSelection
.getImplementationName())
34 with self
.ui_test
.execute_dialog_through_command(".uno:Size") as xDialog
:
35 self
.assertEqual('25.2', get_state_as_dict(xDialog
.getChild('MTR_FLD_WIDTH'))['Value'])
36 self
.assertEqual('9.13', get_state_as_dict(xDialog
.getChild('MTR_FLD_HEIGHT'))['Value'])
37 self
.assertEqual('1.4', get_state_as_dict(xDialog
.getChild('MTR_FLD_POS_X'))['Value'])
38 self
.assertEqual('3.69', get_state_as_dict(xDialog
.getChild('MTR_FLD_POS_Y'))['Value'])
39 self
.assertEqual('0', get_state_as_dict(xDialog
.getChild('NF_ANGLE'))['Value'])
41 xDrawinglayerObject
= xEditWin
.getChild("Unnamed Drawinglayer object 1")
42 xDrawinglayerObject
.executeAction("MOVE", mkPropertyValues({"X": "1000", "Y":"1000"}))
44 with self
.ui_test
.execute_dialog_through_command(".uno:Size") as xDialog
:
45 self
.assertEqual('25.2', get_state_as_dict(xDialog
.getChild('MTR_FLD_WIDTH'))['Value'])
46 self
.assertEqual('9.13', get_state_as_dict(xDialog
.getChild('MTR_FLD_HEIGHT'))['Value'])
47 self
.assertEqual('2.4', get_state_as_dict(xDialog
.getChild('MTR_FLD_POS_X'))['Value'])
48 self
.assertEqual('4.69', get_state_as_dict(xDialog
.getChild('MTR_FLD_POS_Y'))['Value'])
49 self
.assertEqual('0', get_state_as_dict(xDialog
.getChild('NF_ANGLE'))['Value'])
51 self
.assertEqual("com.sun.star.drawing.SvxShapeCollection", document
.CurrentSelection
.getImplementationName())
52 xEditWin
.executeAction("DESELECT", tuple())
53 self
.assertIsNone(document
.CurrentSelection
)
55 def test_resize_object(self
):
56 with self
.ui_test
.create_doc_in_start_center("impress") as document
:
58 xTemplateDlg
= self
.xUITest
.getTopFocusWindow()
59 xCancelBtn
= xTemplateDlg
.getChild("close")
60 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
62 with
change_measurement_unit(self
, 'Centimeter'):
64 xImpressDoc
= self
.xUITest
.getTopFocusWindow()
66 self
.assertIsNone(document
.CurrentSelection
)
68 xEditWin
= xImpressDoc
.getChild("impress_win")
69 xEditWin
.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
70 self
.assertEqual("com.sun.star.drawing.SvxShapeCollection", document
.CurrentSelection
.getImplementationName())
72 with self
.ui_test
.execute_dialog_through_command(".uno:Size") as xDialog
:
73 self
.assertEqual('25.2', get_state_as_dict(xDialog
.getChild('MTR_FLD_WIDTH'))['Value'])
74 self
.assertEqual('9.13', get_state_as_dict(xDialog
.getChild('MTR_FLD_HEIGHT'))['Value'])
75 self
.assertEqual('1.4', get_state_as_dict(xDialog
.getChild('MTR_FLD_POS_X'))['Value'])
76 self
.assertEqual('3.69', get_state_as_dict(xDialog
.getChild('MTR_FLD_POS_Y'))['Value'])
77 self
.assertEqual('0', get_state_as_dict(xDialog
.getChild('NF_ANGLE'))['Value'])
79 xDrawinglayerObject
= xEditWin
.getChild("Unnamed Drawinglayer object 1")
80 xDrawinglayerObject
.executeAction("RESIZE", mkPropertyValues({"X": "500", "Y":"4000", "FRAC_X": "0.5", "FRAC_Y": "0.5"}))
82 xEditWin
.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
83 self
.assertEqual("com.sun.star.drawing.SvxShapeCollection", document
.CurrentSelection
.getImplementationName())
85 with self
.ui_test
.execute_dialog_through_command(".uno:Size") as xDialog
:
86 self
.assertEqual('12.6', get_state_as_dict(xDialog
.getChild('MTR_FLD_WIDTH'))['Value'])
87 self
.assertEqual('4.57', get_state_as_dict(xDialog
.getChild('MTR_FLD_HEIGHT'))['Value'])
88 self
.assertEqual('0.95', get_state_as_dict(xDialog
.getChild('MTR_FLD_POS_X'))['Value'])
89 self
.assertEqual('3.84', get_state_as_dict(xDialog
.getChild('MTR_FLD_POS_Y'))['Value'])
90 self
.assertEqual('0', get_state_as_dict(xDialog
.getChild('NF_ANGLE'))['Value'])
92 self
.assertEqual("com.sun.star.drawing.SvxShapeCollection", document
.CurrentSelection
.getImplementationName())
93 xEditWin
.executeAction("DESELECT", tuple())
94 self
.assertIsNone(document
.CurrentSelection
)
96 def test_rotate_object(self
):
97 with self
.ui_test
.create_doc_in_start_center("impress") as document
:
99 xTemplateDlg
= self
.xUITest
.getTopFocusWindow()
100 xCancelBtn
= xTemplateDlg
.getChild("close")
101 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
103 with
change_measurement_unit(self
, 'Centimeter'):
104 xImpressDoc
= self
.xUITest
.getTopFocusWindow()
106 self
.assertIsNone(document
.CurrentSelection
)
108 xEditWin
= xImpressDoc
.getChild("impress_win")
109 xEditWin
.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
110 self
.assertEqual("com.sun.star.drawing.SvxShapeCollection", document
.CurrentSelection
.getImplementationName())
112 with self
.ui_test
.execute_dialog_through_command(".uno:Size") as xDialog
:
113 self
.assertEqual('25.2', get_state_as_dict(xDialog
.getChild('MTR_FLD_WIDTH'))['Value'])
114 self
.assertEqual('9.13', get_state_as_dict(xDialog
.getChild('MTR_FLD_HEIGHT'))['Value'])
115 self
.assertEqual('1.4', get_state_as_dict(xDialog
.getChild('MTR_FLD_POS_X'))['Value'])
116 self
.assertEqual('3.69', get_state_as_dict(xDialog
.getChild('MTR_FLD_POS_Y'))['Value'])
117 self
.assertEqual('0', get_state_as_dict(xDialog
.getChild('NF_ANGLE'))['Value'])
119 xDrawinglayerObject
= xEditWin
.getChild("Unnamed Drawinglayer object 1")
120 xDrawinglayerObject
.executeAction("ROTATE", mkPropertyValues({"X": "500", "Y":"4000", "ANGLE": "3000"}))
122 xEditWin
.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
123 self
.assertEqual("com.sun.star.drawing.SvxShapeCollection", document
.CurrentSelection
.getImplementationName())
125 with self
.ui_test
.execute_dialog_through_command(".uno:Size") as xDialog
:
126 self
.assertEqual('30', get_state_as_dict(xDialog
.getChild('NF_ANGLE'))['Value'])
128 self
.assertEqual("com.sun.star.drawing.SvxShapeCollection", document
.CurrentSelection
.getImplementationName())
129 xEditWin
.executeAction("DESELECT", tuple())
130 self
.assertIsNone(document
.CurrentSelection
)
133 # vim: set shiftwidth=4 softtabstop=4 expandtab: