Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / pasteSpecial / tdf69450.py
blob133a4f67823a5cac1dce76f96867546d4ba8fbd3
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 libreoffice.uno.propertyvalue import mkPropertyValues
11 from uitest.uihelper.calc import enter_text_to_cell
12 from libreoffice.calc.document import get_cell_by_position
13 from libreoffice.calc.paste_special import reset_default_values
15 class tdf69450(UITestCase):
17 def test_tdf69450(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 text to A1 and B1
23 enter_text_to_cell(gridwin, "A1", "A")
24 enter_text_to_cell(gridwin, "B1", "B")
25 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
26 self.xUITest.executeCommand(".uno:Copy")
27 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"}))
28 with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xDialog:
29 reset_default_values(self, xDialog)
31 xtext = xDialog.getChild("text")
32 xnumbers = xDialog.getChild("numbers")
33 xdatetime = xDialog.getChild("datetime")
34 xformats = xDialog.getChild("formats")
36 xtext.executeAction("CLICK", tuple())
37 xnumbers.executeAction("CLICK", tuple())
38 xdatetime.executeAction("CLICK", tuple())
39 xformats.executeAction("CLICK", tuple())
41 #check B1 text
42 self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "B")
44 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"}))
45 self.xUITest.executeCommand(".uno:Bold")
46 self.xUITest.executeCommand(".uno:Copy")
47 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"}))
48 with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial"):
49 pass
51 #check B1 text
52 self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "B")
54 # vim: set shiftwidth=4 softtabstop=4 expandtab: