Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / pasteSpecial / tdf74577.py
blob87fdd2f9a1469a38b32766df3cf52476d88b537a
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, get_url_for_data_file
12 from libreoffice.calc.document import get_cell_by_position
15 class tdf74577(UITestCase):
17 def test_tdf74577(self):
19 # Open the HTML in writer
20 with self.ui_test.load_file(get_url_for_data_file("tdf74577.html")):
22 # Use SelectAll twice to select the table
23 self.xUITest.executeCommand(".uno:SelectAll")
24 self.xUITest.executeCommand(".uno:SelectAll")
26 self.xUITest.executeCommand(".uno:Copy")
28 with self.ui_test.load_empty_file("calc") as calc_document:
29 with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial", close_button="") as xDialog:
31 xList = xDialog.getChild('list')
33 for childName in xList.getChildren():
34 xChild = xList.getChild(childName)
35 if get_state_as_dict(xChild)['Text'] == "HyperText Markup Language (HTML)":
36 break
38 xChild.executeAction("SELECT", tuple())
39 self.assertEqual(
40 get_state_as_dict(xList)['SelectEntryText'], "HyperText Markup Language (HTML)")
42 xOkBtn = xDialog.getChild("ok")
44 with self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ())):
45 pass
47 self.assertEqual("Cell1", get_cell_by_position(calc_document, 0, 0, 0).getString())
48 self.assertEqual("Cell1", get_cell_by_position(calc_document, 0, 0, 1).getString())
49 self.assertEqual("Cell1 + Cell2", get_cell_by_position(calc_document, 0, 0, 2).getString())
50 self.assertEqual("Cell1 + Cell2 + Cell3", get_cell_by_position(calc_document, 0, 0, 3).getString())
51 self.assertEqual("Cell1 + Cell2", get_cell_by_position(calc_document, 0, 0, 4).getString())
53 self.assertEqual("Cell2 + 3", get_cell_by_position(calc_document, 0, 1, 0).getString())
54 self.assertEqual("Cell2", get_cell_by_position(calc_document, 0, 1, 1).getString())
55 self.assertEqual("Cell3", get_cell_by_position(calc_document, 0, 2, 1).getString())
57 # Without the fix in place, this test would have failed with
58 # AssertionError: 'Cell3' != ''
59 self.assertEqual("Cell3", get_cell_by_position(calc_document, 0, 2, 2).getString())
61 self.assertEqual("Cell2 + Cell3", get_cell_by_position(calc_document, 0, 1, 4).getString())
62 self.assertEqual("Cell2", get_cell_by_position(calc_document, 0, 1, 5).getString())
63 self.assertEqual("Cell3", get_cell_by_position(calc_document, 0, 2, 5).getString())
65 # vim: set shiftwidth=4 softtabstop=4 expandtab: