Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / search_replace / tdf39959.py
blobf08019ab0afa0bdd4fb4d7b53ecc85150a9492ba
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_url_for_data_file
12 from libreoffice.calc.document import get_cell_by_position
13 from libreoffice.uno.propertyvalue import mkPropertyValues
16 # Bug 39959 - Find-and-replace doesn't search all tables anymore
17 class tdf39959(UITestCase):
18 def test_tdf39959_find_replace_all_sheets(self):
19 with self.ui_test.load_file(get_url_for_data_file("tdf39959.ods")) as calc_doc:
20 # 1. Open a new document
21 # 2. Enter "asdf" in A1
22 # 3. Activate Sheet2
23 # 4. Try Find-and-replace (Ctrl+Alt+F) to search for "asdf"
24 # Whether the checkbox "in allen Tabellen suchen" is activated or not: LibO Calc never seems to find the text
25 with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog:
26 searchterm = xDialog.getChild("searchterm")
27 searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
28 searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
29 searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"asdf"}))
30 replaceterm = xDialog.getChild("replaceterm")
31 replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"bbb"})) #replace textbox
32 allsheets = xDialog.getChild("allsheets")
33 allsheets.executeAction("CLICK", tuple())
34 replaceall = xDialog.getChild("replaceall")
35 replaceall.executeAction("CLICK", tuple())
37 #verify Sheet2.A1 = "bbb"
38 self.assertEqual(get_cell_by_position(calc_doc, 1, 0, 0).getString(), "bbb ")
39 self.assertEqual(get_cell_by_position(calc_doc, 1, 0, 2).getString(), "abc")
40 #Undo
41 self.xUITest.executeCommand(".uno:Undo")
42 self.assertEqual(get_cell_by_position(calc_doc, 1, 0, 0).getString(), "asdf ")
43 # vim: set shiftwidth=4 softtabstop=4 expandtab: