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/.
9 from uitest
.framework
import UITestCase
10 from uitest
.uihelper
.common
import change_measurement_unit
11 from uitest
.uihelper
.common
import get_state_as_dict
, get_url_for_data_file
13 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
16 # Chart Display Legend dialog
17 class chartLegend(UITestCase
):
18 def test_chart_display_legend_dialog(self
):
19 with self
.ui_test
.load_file(get_url_for_data_file("chart.ods")):
20 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
21 gridwin
= xCalcDoc
.getChild("grid_window")
23 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
24 gridwin
.executeAction("ACTIVATE", tuple())
25 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
26 xChartMain
= xChartMainTop
.getChild("chart_window")
27 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
28 with self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"})) as xDialog
:
29 left
= xDialog
.getChild("left")
31 left
.executeAction("CLICK", tuple())
33 #reopen and verify InsertMenuLegend dialog
34 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
35 gridwin
.executeAction("ACTIVATE", tuple())
36 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
37 xChartMain
= xChartMainTop
.getChild("chart_window")
38 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
39 with self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"})) as xDialog
:
40 left
= xDialog
.getChild("left")
41 right
= xDialog
.getChild("right")
42 top
= xDialog
.getChild("top")
43 bottom
= xDialog
.getChild("bottom")
44 show
= xDialog
.getChild("show")
46 self
.assertEqual(get_state_as_dict(left
)["Checked"], "true")
47 self
.assertEqual(get_state_as_dict(right
)["Checked"], "false")
48 self
.assertEqual(get_state_as_dict(top
)["Checked"], "false")
49 self
.assertEqual(get_state_as_dict(bottom
)["Checked"], "false")
51 show
.executeAction("CLICK", tuple())
53 #reopen and verify InsertMenuLegend dialog
54 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
55 gridwin
.executeAction("ACTIVATE", tuple())
56 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
57 xChartMain
= xChartMainTop
.getChild("chart_window")
58 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
59 with self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"})) as xDialog
:
60 left
= xDialog
.getChild("left")
61 right
= xDialog
.getChild("right")
62 top
= xDialog
.getChild("top")
63 bottom
= xDialog
.getChild("bottom")
64 show
= xDialog
.getChild("show")
66 self
.assertEqual(get_state_as_dict(left
)["Checked"], "true")
67 self
.assertEqual(get_state_as_dict(right
)["Checked"], "false")
68 self
.assertEqual(get_state_as_dict(top
)["Checked"], "false")
69 self
.assertEqual(get_state_as_dict(bottom
)["Checked"], "false")
71 self
.assertEqual(get_state_as_dict(show
)["Selected"], "false")
73 def test_legends_move_with_arrows_keys(self
):
75 with self
.ui_test
.load_file(get_url_for_data_file("dataLabels.ods")):
77 with
change_measurement_unit(self
, "Centimeter"):
78 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
79 gridwin
= xCalcDoc
.getChild("grid_window")
81 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
82 gridwin
.executeAction("ACTIVATE", tuple())
83 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
84 xChartMain
= xChartMainTop
.getChild("chart_window")
87 xLegends
= xChartMain
.getChild("CID/D=0:Legend=")
88 xLegends
.executeAction("SELECT", tuple())
90 with self
.ui_test
.execute_dialog_through_action(xLegends
, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog
:
91 self
.assertEqual("4.59", get_state_as_dict(xDialog
.getChild("MTR_FLD_POS_X"))['Value'])
92 self
.assertEqual("1.54", get_state_as_dict(xDialog
.getChild("MTR_FLD_POS_Y"))['Value'])
94 xChartMain
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
95 xChartMain
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
97 # Check the position has changed after moving the label using the arrows keys
98 with self
.ui_test
.execute_dialog_through_action(xLegends
, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog
:
99 self
.assertEqual("4.49", get_state_as_dict(xDialog
.getChild("MTR_FLD_POS_X"))['Value'])
100 self
.assertEqual("1.44", get_state_as_dict(xDialog
.getChild("MTR_FLD_POS_Y"))['Value'])
102 def test_Tdf147394(self
):
104 with self
.ui_test
.load_file(get_url_for_data_file("dataLabels.ods")) as calc_doc
:
105 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
106 gridwin
= xCalcDoc
.getChild("grid_window")
108 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
109 gridwin
.executeAction("ACTIVATE", tuple())
110 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
111 xChartMain
= xChartMainTop
.getChild("chart_window")
113 xLegend
= calc_doc
.Sheets
[0].Charts
[0].getEmbeddedObject().getFirstDiagram().Legend
114 self
.assertTrue(xLegend
.Show
)
117 xLegends
= xChartMain
.getChild("CID/D=0:Legend=")
118 xLegends
.executeAction("SELECT", tuple())
120 # Without the fix in place, this test would have crashed here
121 xChartMain
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"}))
123 self
.assertFalse(xLegend
.Show
)
125 # vim: set shiftwidth=4 softtabstop=4 expandtab: