Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / chart2 / tdf129587.py
blob1fa06c889fab005258d92188006831d27b3b4a47
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 get_state_as_dict, get_url_for_data_file
11 from uitest.uihelper.common import select_pos
12 from libreoffice.uno.propertyvalue import mkPropertyValues
14 class tdf129587(UITestCase):
15 def test_tdf129587(self):
17 with self.ui_test.load_file(get_url_for_data_file("tdf129587.ods")) as calc_doc:
18 xCalcDoc = self.xUITest.getTopFocusWindow()
19 gridwin = xCalcDoc.getChild("grid_window")
21 xDataSeries = calc_doc.Sheets[0].Charts[0].getEmbeddedObject().getFirstDiagram().CoordinateSystems[0].ChartTypes[0].DataSeries
22 self.assertEqual("$Tabelle1.$F$2:$G$11", xDataSeries[0].ErrorBarY.ErrorBarRangeNegative)
24 gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
25 gridwin.executeAction("ACTIVATE", tuple())
26 xChartMainTop = self.xUITest.getTopFocusWindow()
27 xChartMain = xChartMainTop.getChild("chart_window")
29 xSeriesObj = xChartMain.getChild("CID/MultiClick/D=0:CS=0:CT=0:Series=0:ErrorsY=")
30 with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatYErrorBars"})) as xDialog:
32 tabcontrol = xDialog.getChild("tabcontrol")
33 select_pos(tabcontrol, "0")
35 xPerBtn = xDialog.getChild("RB_PERCENT")
36 xPerBtn.executeAction("CLICK", tuple())
38 xPosField = xDialog.getChild("MF_POSITIVE")
39 xNegField = xDialog.getChild("MF_NEGATIVE")
41 self.assertEqual("0%", get_state_as_dict(xPosField)['Text'])
42 self.assertEqual("0%", get_state_as_dict(xNegField)['Text'])
44 #Increase value by one
45 xPosField.executeAction("UP", tuple())
47 #Both fields are updated because 'Same value for both' is enabled
48 self.assertEqual("1%", get_state_as_dict(xPosField)['Text'])
49 self.assertEqual("1%", get_state_as_dict(xNegField)['Text'])
52 #Without the fix in place, it would have crashed here
53 xDataSeries = calc_doc.Sheets[0].Charts[0].getEmbeddedObject().getFirstDiagram().CoordinateSystems[0].ChartTypes[0].DataSeries
54 self.assertEqual(1.0, xDataSeries[0].ErrorBarY.PercentageError)
56 # vim: set shiftwidth=4 softtabstop=4 expandtab: