Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / chart2 / tdf123013.py
blobd7a0b32c87ddc2c65db5f4bba3b9c4332a982d80
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
13 from libreoffice.uno.propertyvalue import mkPropertyValues
16 # Bug 123013 - Can not change Trendline name in charts
17 class tdf123013(UITestCase):
18 def test_tdf96432_chart_trendline_name(self):
19 with self.ui_test.load_file(get_url_for_data_file("tdf123013.ods")):
20 xCalcDoc = self.xUITest.getTopFocusWindow()
21 gridwin = xCalcDoc.getChild("grid_window")
22 gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
23 gridwin.executeAction("ACTIVATE", tuple())
24 xChartMainTop = self.xUITest.getTopFocusWindow()
25 xChartMain = xChartMainTop.getChild("chart_window")
26 xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
27 with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatTrendline"})) as xDialog:
28 #Click on tab "Type".
29 tabcontrol = xDialog.getChild("tabcontrol")
30 select_pos(tabcontrol, "0")
31 #add name
32 xentryname = xDialog.getChild("entry_name")
33 xentryname.executeAction("TYPE", mkPropertyValues({"TEXT":"Tline"}))
35 #reopen and try again
36 gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
37 gridwin.executeAction("ACTIVATE", tuple())
38 xChartMainTop = self.xUITest.getTopFocusWindow()
39 xChartMain = xChartMainTop.getChild("chart_window")
41 #Right-click on the chart; from the pop-up menu select "Format Y bars
42 # The program presents dialog "Format Y bars", tab "Line".
43 xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
44 with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatTrendline"})) as xDialog:
45 #Click on tab "Type".
46 tabcontrol = xDialog.getChild("tabcontrol")
47 select_pos(tabcontrol, "0")
48 #add name
49 xentryname = xDialog.getChild("entry_name")
50 self.assertEqual(get_state_as_dict(xentryname)["Text"], "Tline")
52 # vim: set shiftwidth=4 softtabstop=4 expandtab: