Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / textToColumns / tdf89907.py
blobef5f164f926117397f611dab182c6a26c688319d
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 from uitest.uihelper.common import change_measurement_unit
15 #Bug 89907 - Text to columns only affects first line when width is auto set
17 class tdf89907(UITestCase):
18 def test_tdf89907_text_to_columns(self):
19 with self.ui_test.create_doc_in_start_center("calc") as document:
21 with change_measurement_unit(self, "Centimeter"):
22 xCalcDoc = self.xUITest.getTopFocusWindow()
23 gridwin = xCalcDoc.getChild("grid_window")
25 #Add data
26 enter_text_to_cell(gridwin, "A1", "afasdfs.fdfasd.fsadf.fasd")
27 enter_text_to_cell(gridwin, "A2", "3242.43242.3242.2342")
28 enter_text_to_cell(gridwin, "A3", "fdsfa.afsdfa.adfdas.fsad")
29 enter_text_to_cell(gridwin, "A4", "21312.1111.1111.111")
30 #select column A
31 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
32 self.xUITest.executeCommand(".uno:SelectColumn")
33 #Optimal Width
34 with self.ui_test.execute_dialog_through_command(".uno:SetOptimalColumnWidth") as xDialog:
35 xvalue = xDialog.getChild("value")
36 self.assertEqual("0.20 cm", get_state_as_dict(xvalue)["Text"])
38 # Data - Text to Columns
39 with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog:
40 xother = xDialog.getChild("other")
41 xinputother = xDialog.getChild("inputother")
42 if (get_state_as_dict(xother)["Selected"]) == "false":
43 xother.executeAction("CLICK", tuple())
44 xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."}))
45 # Click Ok
47 #Verify
48 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "afasdfs")
49 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242)
50 self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa")
51 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312)
52 self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "fdfasd")
53 self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242)
54 self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa")
55 self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111)
56 self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "fsadf")
57 self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242)
58 self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas")
59 self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111)
60 self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "fasd")
61 self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342)
62 self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad")
63 self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111)
66 # vim: set shiftwidth=4 softtabstop=4 expandtab: