Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / calc_tests9 / tdf135761.py
blob5de390b3e46da21367651b632f3b2d8950c632a3
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/.
10 from uitest.framework import UITestCase
11 from libreoffice.uno.propertyvalue import mkPropertyValues
12 from libreoffice.calc.document import get_cell_by_position
14 class tdf135761(UITestCase):
15 def test_tdf135761_ctrl_backspace(self):
16 with self.ui_test.create_doc_in_start_center("calc") as document:
17 xCalcDoc = self.xUITest.getTopFocusWindow()
18 xGridWindow = xCalcDoc.getChild("grid_window")
20 # Enter text including two whitespaces in the text, and delete the left part of the text
21 xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
22 xGridWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "a b"}))
23 xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"F2"}))
24 xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"}))
25 xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"}))
26 xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+BACKSPACE"}))
27 xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
29 # Without the fix in place, this test would have failed with
30 # AssertionError: ' b' != 'a b'
31 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), " b")
33 # vim: set shiftwidth=4 softtabstop=4 expandtab: