tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / qa / uitest / sort / tdf49531.py
blob6e0498cfafd270a3c7007de3df8d69d0f53a1787
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_by_text, select_pos
13 from libreoffice.calc.document import get_cell_by_position
14 from libreoffice.uno.propertyvalue import mkPropertyValues
17 # Bug 49531 - EDITING: Sort rows for will sort columns
18 # Bug 49520 - EDITING: CRASH when undo sort with chart
19 class tdf49531(UITestCase):
20 def test_td49531_sort_undo_crash(self):
21 with self.ui_test.load_file(get_url_for_data_file("tdf49531.ods")) as calc_doc:
22 xCalcDoc = self.xUITest.getTopFocusWindow()
23 gridwin = xCalcDoc.getChild("grid_window")
24 #select A3:C147
25 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A3:C147"}))
27 #Menu 'Data -> Sort -> Top to bottom - all otheroptions unchecked
28 #Column B - Ascending' <ok>
29 with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog:
30 xTabs = xDialog.getChild("tabcontrol")
31 select_pos(xTabs, "1")
32 xNatural = xDialog.getChild("naturalsort")
33 if (get_state_as_dict(xNatural)["Selected"]) == "true":
34 xNatural.executeAction("CLICK", tuple())
35 select_pos(xTabs, "0")
36 xtopdown = xDialog.getChild("rbTopDown")
37 xHeader = xDialog.getChild("cbHeader")
38 if (get_state_as_dict(xHeader)["Selected"]) == "true":
39 xHeader.executeAction("CLICK", tuple())
40 xtopdown.executeAction("CLICK", tuple())
41 xSortKey1 = xDialog.getChild("sortlb")
42 xAsc = xDialog.getChild("up")
43 select_by_text(xSortKey1, "B")
44 xAsc.executeAction("CLICK", tuple())
45 #Verify
46 self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "x")
47 self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "0")
48 self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 2).getValue(), 111)
49 self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 3).getValue(), 48)
50 # UNDO Bug 49520 - EDITING: CRASH when undo sort with chart
51 self.xUITest.executeCommand(".uno:Undo")
52 # Verify
53 self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "x")
54 self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "0")
55 self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 2).getValue(), 2)
56 self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 3).getValue(), 3)
58 # vim: set shiftwidth=4 softtabstop=4 expandtab: