Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / sort / tdf105301.py
blobc215e95bc819dc6c7a8095f6b63f17b1babc93be
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
11 from uitest.uihelper.common import select_pos
12 from libreoffice.uno.propertyvalue import mkPropertyValues
14 class tdf105301(UITestCase):
16 def test_tdf105301(self):
17 with self.ui_test.load_file(get_url_for_data_file("tdf105301.ods")):
18 xCalcDoc = self.xUITest.getTopFocusWindow()
19 gridwin = xCalcDoc.getChild("grid_window")
21 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:R9"}))
23 with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog:
24 xTabs = xDialog.getChild("tabcontrol")
25 select_pos(xTabs, "0")
26 self.assertEqual("B", get_state_as_dict(xDialog.getChild("sortlb"))['DisplayText'])
27 self.assertEqual("C", get_state_as_dict(xDialog.getChild("sortlb2"))['DisplayText'])
28 self.assertEqual("D", get_state_as_dict(xDialog.getChild("sortlb3"))['DisplayText'])
30 # Without the fix in place, this test would have failed with
31 # AssertionError: 'E' != '- undefined -'
32 self.assertEqual("E", get_state_as_dict(xDialog.getChild("sortlb4"))['DisplayText'])
33 self.assertEqual("F", get_state_as_dict(xDialog.getChild("sortlb5"))['DisplayText'])
34 self.assertEqual("G", get_state_as_dict(xDialog.getChild("sortlb6"))['DisplayText'])
36 # tdf#51828: Without the fix in place, this test would have failed here
37 self.assertEqual("- undefined -", get_state_as_dict(xDialog.getChild("sortlb7"))['DisplayText'])
40 # vim: set shiftwidth=4 softtabstop=4 expandtab: