Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / textToColumns / tdf82398.py
blobb0722fcbd14c2a6a1b5fb8d42c1f61e0fc04aa9b
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
11 from uitest.uihelper.calc import enter_text_to_cell
12 from libreoffice.calc.document import get_cell_by_position
13 from libreoffice.uno.propertyvalue import mkPropertyValues
14 #Bug 82398 - EDITING: "Text to Columns" not applied to selected cells after change 'Format Cells'
16 class tdf82398(UITestCase):
17 def test_tdf82398_text_to_columns(self):
18 with self.ui_test.create_doc_in_start_center("calc") as document:
19 xCalcDoc = self.xUITest.getTopFocusWindow()
20 gridwin = xCalcDoc.getChild("grid_window")
22 #Add data
23 enter_text_to_cell(gridwin, "A1", "afasdfs.fdfasd.fsadf.fasd")
24 enter_text_to_cell(gridwin, "A2", "3242.43242.3242.2342")
25 enter_text_to_cell(gridwin, "A3", "fdsfa.afsdfa.adfdas.fsad")
26 enter_text_to_cell(gridwin, "A4", "21312.1111.1111.111")
27 #select column A1:A4 / .uno:NumberFormatDate
28 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"}))
29 self.xUITest.executeCommand(".uno:NumberFormatDate")
30 # Data - Text to Columns
31 with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog:
32 xother = xDialog.getChild("other")
33 xinputother = xDialog.getChild("inputother")
35 if (get_state_as_dict(xother)["Selected"]) == "false":
36 xother.executeAction("CLICK", tuple())
37 xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."}))
38 # Click Ok
40 #Verify
41 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "afasdfs")
42 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242)
43 self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa")
44 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312)
45 self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "fdfasd")
46 self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242)
47 self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa")
48 self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111)
49 self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "fsadf")
50 self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242)
51 self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas")
52 self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111)
53 self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "fasd")
54 self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342)
55 self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad")
56 self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111)
59 # vim: set shiftwidth=4 softtabstop=4 expandtab: