Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / chart2 / tdf134059.py
blob92be27ffa0e89f66178c2c03ddb3e12429af3789
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 select_pos
11 from libreoffice.uno.propertyvalue import mkPropertyValues
12 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
13 from libreoffice.calc.document import get_row
15 class Tdf134059(UITestCase):
17 def assertSeriesNames(self, gridwin):
19 gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
20 gridwin.executeAction("ACTIVATE", tuple())
21 xChartMainTop = self.xUITest.getTopFocusWindow()
22 xChartMain = xChartMainTop.getChild("chart_window")
24 xPage = xChartMain.getChild("CID/Page=")
26 with self.ui_test.execute_dialog_through_action(xPage, "COMMAND", mkPropertyValues({"COMMAND": "DataRanges"})) as xDialog:
28 xTabs = xDialog.getChild("tabcontrol")
29 select_pos(xTabs, "1")
31 xSeries = xDialog.getChild("LB_SERIES")
32 self.assertEqual(3, len(xSeries.getChildren()))
33 self.assertEqual("Col. 1", get_state_as_dict(xSeries.getChild('0'))['Text'])
34 self.assertEqual("Col. 2", get_state_as_dict(xSeries.getChild('1'))['Text'])
35 self.assertEqual("Col. 3", get_state_as_dict(xSeries.getChild('2'))['Text'])
38 gridwin.executeAction("DESELECT", mkPropertyValues({"OBJECT": "Object 1"}))
40 def test_tdf134059(self):
41 with self.ui_test.load_file(get_url_for_data_file("tdf134059.ods")) as calc_doc:
42 xCalcDoc = self.xUITest.getTopFocusWindow()
43 gridwin = xCalcDoc.getChild("grid_window")
45 self.assertSeriesNames(gridwin)
47 # Hide row 10
48 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A10"}))
49 self.ui_test._xUITest.executeCommand(".uno:HideRow")
51 row = get_row(calc_doc, 9)
52 self.assertFalse(row.getPropertyValue("IsVisible"))
54 # Without the fix in place, this test would have failed with
55 # AssertionError: 'Col. 1' != 'Column C'
56 self.assertSeriesNames(gridwin)
58 self.xUITest.executeCommand(".uno:Undo")
60 self.assertTrue(row.getPropertyValue("IsVisible"))
62 self.assertSeriesNames(gridwin)
64 # vim: set shiftwidth=4 softtabstop=4 expandtab: