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 uitest
.uihelper
.common
import get_state_as_dict
9 from uitest
.uihelper
.common
import select_pos
10 from uitest
.uihelper
.common
import change_measurement_unit
11 from uitest
.uihelper
.calc
import enter_text_to_cell
12 from libreoffice
.calc
.document
import get_cell_by_position
13 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
14 from uitest
.uihelper
.common
import get_state_as_dict
, type_text
15 from uitest
.debug
import sleep
16 import org
.libreoffice
.unotest
19 def get_url_for_data_file(file_name
):
20 return pathlib
.Path(org
.libreoffice
.unotest
.makeCopyFromTDOC(file_name
)).as_uri()
22 #Chart Display Legend dialog
24 class chartLegend(UITestCase
):
25 def test_chart_display_legend_dialog(self
):
26 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("tdf98390.ods"))
27 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
28 gridwin
= xCalcDoc
.getChild("grid_window")
29 document
= self
.ui_test
.get_component()
31 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
32 gridwin
.executeAction("ACTIVATE", tuple())
33 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
34 xChartMain
= xChartMainTop
.getChild("chart_window")
35 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
36 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"}))
37 xDialog
= self
.xUITest
.getTopFocusWindow()
39 left
= xDialog
.getChild("left")
40 right
= xDialog
.getChild("right")
41 top
= xDialog
.getChild("top")
42 bottom
= xDialog
.getChild("bottom")
44 left
.executeAction("CLICK", tuple())
46 xOKBtn
= xDialog
.getChild("ok")
47 self
.ui_test
.close_dialog_through_button(xOKBtn
)
49 #reopen and verify InsertMenuLegend dialog
50 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
51 gridwin
.executeAction("ACTIVATE", tuple())
52 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
53 xChartMain
= xChartMainTop
.getChild("chart_window")
54 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
55 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"}))
56 xDialog
= self
.xUITest
.getTopFocusWindow()
58 left
= xDialog
.getChild("left")
59 right
= xDialog
.getChild("right")
60 top
= xDialog
.getChild("top")
61 bottom
= xDialog
.getChild("bottom")
62 show
= xDialog
.getChild("show")
64 self
.assertEqual(get_state_as_dict(left
)["Checked"], "true")
65 self
.assertEqual(get_state_as_dict(right
)["Checked"], "false")
66 self
.assertEqual(get_state_as_dict(top
)["Checked"], "false")
67 self
.assertEqual(get_state_as_dict(bottom
)["Checked"], "false")
69 show
.executeAction("CLICK", tuple())
71 xOKBtn
= xDialog
.getChild("ok")
72 self
.ui_test
.close_dialog_through_button(xOKBtn
)
74 #reopen and verify InsertMenuLegend dialog
75 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
76 gridwin
.executeAction("ACTIVATE", tuple())
77 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
78 xChartMain
= xChartMainTop
.getChild("chart_window")
79 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
80 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"}))
81 xDialog
= self
.xUITest
.getTopFocusWindow()
83 left
= xDialog
.getChild("left")
84 right
= xDialog
.getChild("right")
85 top
= xDialog
.getChild("top")
86 bottom
= xDialog
.getChild("bottom")
87 show
= xDialog
.getChild("show")
89 self
.assertEqual(get_state_as_dict(left
)["Checked"], "true")
90 self
.assertEqual(get_state_as_dict(right
)["Checked"], "false")
91 self
.assertEqual(get_state_as_dict(top
)["Checked"], "false")
92 self
.assertEqual(get_state_as_dict(bottom
)["Checked"], "false")
94 self
.assertEqual(get_state_as_dict(show
)["Selected"], "false")
96 xOKBtn
= xDialog
.getChild("ok")
97 self
.ui_test
.close_dialog_through_button(xOKBtn
)
98 self
.ui_test
.close_doc()
100 def test_legends_move_with_arrows_keys(self
):
102 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("dataLabels.ods"))
103 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
104 gridwin
= xCalcDoc
.getChild("grid_window")
106 change_measurement_unit(self
, "Centimeter")
108 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
109 gridwin
.executeAction("ACTIVATE", tuple())
110 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
111 xChartMain
= xChartMainTop
.getChild("chart_window")
114 xLegends
= xChartMain
.getChild("CID/D=0:Legend=")
115 xLegends
.executeAction("SELECT", tuple())
117 self
.ui_test
.execute_dialog_through_action(xLegends
, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"}))
119 xDialog
= self
.xUITest
.getTopFocusWindow()
120 self
.assertEqual("4.61", get_state_as_dict(xDialog
.getChild("MTR_FLD_POS_X"))['Value'])
121 self
.assertEqual("1.54", get_state_as_dict(xDialog
.getChild("MTR_FLD_POS_Y"))['Value'])
123 xOkBtn
= xDialog
.getChild("ok")
124 xOkBtn
.executeAction("CLICK", tuple())
126 xChartMain
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
127 xChartMain
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
129 self
.ui_test
.execute_dialog_through_action(xLegends
, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"}))
131 # Check the position has changed after moving the label using the arrows keys
132 xDialog
= self
.xUITest
.getTopFocusWindow()
133 self
.assertEqual("4.51", get_state_as_dict(xDialog
.getChild("MTR_FLD_POS_X"))['Value'])
134 self
.assertEqual("1.44", get_state_as_dict(xDialog
.getChild("MTR_FLD_POS_Y"))['Value'])
136 xOkBtn
= xDialog
.getChild("ok")
137 xOkBtn
.executeAction("CLICK", tuple())
139 self
.ui_test
.close_doc()
141 # vim: set shiftwidth=4 softtabstop=4 expandtab: