Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / calc_tests / autosum.py
blobdb3334c36725942e2fb7a32e8a6e878bd1377c3a
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
11 from libreoffice.calc.document import get_cell_by_position
12 from libreoffice.uno.propertyvalue import mkPropertyValues
14 #AutoSum feature test
16 class calcAutosum(UITestCase):
18 def test_autosum_test8(self):
19 #8.Autosum on rows without selected empty cell for result
20 with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc:
21 xCalcDoc = self.xUITest.getTopFocusWindow()
22 gridwin = xCalcDoc.getChild("grid_window")
24 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B126:D126"}))
25 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B128:D128", "EXTEND":"1"}))
26 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B130:D130", "EXTEND":"1"}))
27 self.xUITest.executeCommand(".uno:AutoSum")
29 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 125).getValue(), 30)
30 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 125).getFormula(), "=SUM(B126:D126)")
31 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 127).getValue(), 90)
32 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 127).getFormula(), "=SUM(B128:D128)")
33 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 129).getValue(), 150)
34 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 129).getFormula(), "=SUM(B130:D130)")
36 # vim: set shiftwidth=4 softtabstop=4 expandtab: