Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / textToColumns / tdf85979.py
blobca5808947e706cf5eaff7244ed6954ce9ef66467
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.calc.document import get_cell_by_position
12 from libreoffice.uno.propertyvalue import mkPropertyValues
14 #Bug 85979 - Crash: data text to columns
16 class tdf85979(UITestCase):
17 def test_td85979_text_to_columns(self):
18 with self.ui_test.load_file(get_url_for_data_file("tdf85979.ods")) as calc_doc:
19 xCalcDoc = self.xUITest.getTopFocusWindow()
20 gridwin = xCalcDoc.getChild("grid_window")
22 #(I selected C1 to C5, then Text to Columns, unselected "Tab" and selected "Space")
23 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C5"}))
24 # Data - Text to Columns
25 with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog:
26 xspace = xDialog.getChild("space")
27 if (get_state_as_dict(xspace)["Selected"]) == "false":
28 xspace.executeAction("CLICK", tuple())
29 # Click Ok
31 #Verify
32 self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 0).getValue(), 99)
33 self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 1).getValue(), 4)
34 self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 2).getValue(), 9)
35 self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 3).getValue(), 9)
36 self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 0).getValue(), 260)
37 self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 1).getValue(), 10)
38 self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 2).getValue(), 23)
39 self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 3).getValue(), 23)
40 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 0).getValue(), 149)
41 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 1).getValue(), 6)
42 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 2).getValue(), 14)
43 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 3).getValue(), 14)
44 self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 0).getValue(), 0)
45 self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 1).getValue(), 16)
46 self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 2).getValue(), 35)
47 self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 3).getValue(), 35)
49 # vim: set shiftwidth=4 softtabstop=4 expandtab: