Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / pasteSpecial / tdf86253.py
blob6e6e1bcd498335cb55e0200ef95158cbdb5293fe
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 libreoffice.uno.propertyvalue import mkPropertyValues
12 from libreoffice.calc.paste_special import reset_default_values
14 class tdf86253(UITestCase):
16 def test_tdf86253(self):
17 with self.ui_test.load_file(get_url_for_data_file("tdf86253.ods")):
18 xCalcDoc = self.xUITest.getTopFocusWindow()
19 gridwin = xCalcDoc.getChild("grid_window")
21 #* Copy A1, then paste special only "formatting" to C1:C17;
22 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
23 self.xUITest.executeCommand(".uno:Copy")
24 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C17"}))
25 with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xDialog:
26 reset_default_values(self, xDialog)
28 xtext = xDialog.getChild("text")
29 xnumbers = xDialog.getChild("numbers")
30 xdatetime = xDialog.getChild("datetime")
31 xformats = xDialog.getChild("formats")
33 xtext.executeAction("CLICK", tuple())
34 xnumbers.executeAction("CLICK", tuple())
35 xdatetime.executeAction("CLICK", tuple())
36 xformats.executeAction("CLICK", tuple())
39 #--> Cell formatting for C1:C17 is changed. But, if you go to "Format - Conditional Formatting - Manage",
40 #you will see that a new formatting condition is created with the range "C1:C6", rather than "C1:C17". This is wrong behavior.
41 with self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog", close_button="cancel") as xCondFormatMgr:
44 # check that we have exactly 1 conditional format and range is C1:C17
45 xList = xCondFormatMgr.getChild("CONTAINER")
46 list_state = get_state_as_dict(xList)
47 self.assertEqual(list_state['Children'], '1')
49 xTreeEntry = xList.getChild('0')
50 self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "A1:A6,C1:C17\tCell value >= 0")
52 # vim: set shiftwidth=4 softtabstop=4 expandtab: