nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / uitest / chart / chartArea.py
blobd2cd4fe259f3c58dcb2f0ecd88963758fd70eb00
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 import org.libreoffice.unotest
16 import pathlib
18 def get_url_for_data_file(file_name):
19 return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
21 #Chart Area dialog
23 class chartArea(UITestCase):
24 def test_chart_area_dialog(self):
25 calc_doc = self.ui_test.load_file(get_url_for_data_file("chartArea.ods"))
26 xCalcDoc = self.xUITest.getTopFocusWindow()
27 gridwin = xCalcDoc.getChild("grid_window")
28 document = self.ui_test.get_component()
30 change_measurement_unit(self, "Centimeter")
32 xArea = document.Sheets[0].Charts[0].getEmbeddedObject().Area
33 self.assertEqual(xArea.LineWidth, 0)
34 self.assertEqual(xArea.LineTransparence, 0)
35 self.assertEqual(hex(xArea.FillColor), '0xffffff')
36 self.assertEqual(xArea.FillTransparence, 0)
38 gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
39 gridwin.executeAction("ACTIVATE", tuple())
40 xChartMainTop = self.xUITest.getTopFocusWindow()
41 xChartMain = xChartMainTop.getChild("chart_window")
42 xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
43 self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"}))
44 xDialog = self.xUITest.getTopFocusWindow()
45 #Click on tab "Borders".
46 tabcontrol = xDialog.getChild("tabcontrol")
47 select_pos(tabcontrol, "0")
49 xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
50 transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
52 xWidth.executeAction("UP", tuple())
53 transparency.executeAction("UP", tuple())
55 xOKBtn = xDialog.getChild("ok")
56 self.ui_test.close_dialog_through_button(xOKBtn)
58 self.assertEqual(xArea.LineWidth, 100)
59 self.assertEqual(xArea.LineTransparence, 5)
60 self.assertEqual(hex(xArea.FillColor), '0xffffff')
61 self.assertEqual(xArea.FillTransparence, 0)
63 #reopen and verify tab "Borders".
64 gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
65 gridwin.executeAction("ACTIVATE", tuple())
66 xChartMainTop = self.xUITest.getTopFocusWindow()
67 xChartMain = xChartMainTop.getChild("chart_window")
68 xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
69 self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"}))
70 xDialog = self.xUITest.getTopFocusWindow()
72 tabcontrol = xDialog.getChild("tabcontrol")
73 select_pos(tabcontrol, "0")
74 xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
75 transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
77 self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
78 self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
80 #Click on tab "Area"
81 tabcontrol = xDialog.getChild("tabcontrol")
82 select_pos(tabcontrol, "1")
84 btncolor = xDialog.getChild("btncolor")
85 btncolor.executeAction("CLICK", tuple())
87 rCustom = xDialog.getChild("R_custom")
88 gCustom = xDialog.getChild("G_custom")
89 bCustom = xDialog.getChild("B_custom")
91 rCustom.executeAction("CLEAR", tuple())
92 rCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"35"}))
93 rCustom.executeAction("UP", tuple())
94 rCustom.executeAction("DOWN", tuple()) #without this save data doesn't works
95 self.assertEqual(get_state_as_dict(rCustom)["Text"], "35")
96 gCustom.executeAction("CLEAR", tuple())
97 gCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"169"}))
98 gCustom.executeAction("UP", tuple())
99 gCustom.executeAction("DOWN", tuple()) #without this save data doesn't works
100 bCustom.executeAction("CLEAR", tuple())
101 bCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"211"}))
102 bCustom.executeAction("UP", tuple())
103 bCustom.executeAction("DOWN", tuple()) #without this save data doesn't works
104 xOKBtn = xDialog.getChild("ok")
105 self.ui_test.close_dialog_through_button(xOKBtn)
107 self.assertEqual(xArea.LineWidth, 100)
108 self.assertEqual(xArea.LineTransparence, 5)
109 self.assertEqual(hex(xArea.FillColor), '0x23a9d3')
110 self.assertEqual(xArea.FillTransparence, 0)
112 #reopen and verify tab "Area".
113 gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
114 gridwin.executeAction("ACTIVATE", tuple())
115 xChartMainTop = self.xUITest.getTopFocusWindow()
116 xChartMain = xChartMainTop.getChild("chart_window")
117 xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
118 self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"}))
119 xDialog = self.xUITest.getTopFocusWindow()
121 tabcontrol = xDialog.getChild("tabcontrol")
122 select_pos(tabcontrol, "1")
124 rCustom = xDialog.getChild("R_custom")
125 gCustom = xDialog.getChild("G_custom")
126 bCustom = xDialog.getChild("B_custom")
128 self.assertEqual(get_state_as_dict(rCustom)["Text"], "35")
129 self.assertEqual(get_state_as_dict(gCustom)["Text"], "169")
130 self.assertEqual(get_state_as_dict(bCustom)["Text"], "211")
132 #change tab "Transparency"
133 select_pos(tabcontrol, "2")
134 transparency = xDialog.getChild("RBT_TRANS_LINEAR")
135 transparencyPercent = xDialog.getChild("MTR_TRANSPARENT") #51%
137 transparency.executeAction("CLICK", tuple())
138 transparencyPercent.executeAction("UP", tuple())
140 xOKBtn = xDialog.getChild("ok")
141 self.ui_test.close_dialog_through_button(xOKBtn)
143 self.assertEqual(xArea.LineWidth, 100)
144 self.assertEqual(xArea.LineTransparence, 5)
145 self.assertEqual(hex(xArea.FillColor), '0x23a9d3')
146 self.assertEqual(xArea.FillTransparence, 51)
148 #reopen and verify tab "Transparency"
149 gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
150 gridwin.executeAction("ACTIVATE", tuple())
151 xChartMainTop = self.xUITest.getTopFocusWindow()
152 xChartMain = xChartMainTop.getChild("chart_window")
153 xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
154 self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"}))
155 xDialog = self.xUITest.getTopFocusWindow()
157 tabcontrol = xDialog.getChild("tabcontrol")
158 select_pos(tabcontrol, "2")
160 transparency = xDialog.getChild("RBT_TRANS_LINEAR")
161 transparencyPercent = xDialog.getChild("MTR_TRANSPARENT") #51%
163 self.assertEqual(get_state_as_dict(transparency)["Checked"], "true")
164 self.assertEqual(get_state_as_dict(transparencyPercent)["Text"], "51%")
166 xOKBtn = xDialog.getChild("ok")
167 self.ui_test.close_dialog_through_button(xOKBtn)
169 self.assertEqual(xArea.LineWidth, 100)
170 self.assertEqual(xArea.LineTransparence, 5)
171 self.assertEqual(hex(xArea.FillColor), '0x23a9d3')
172 self.assertEqual(xArea.FillTransparence, 51)
174 self.ui_test.close_doc()
175 # vim: set shiftwidth=4 softtabstop=4 expandtab: