Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / qa / uitest / sort / tdf53482.py
blobfbcbac0a854954a8a8706fd98cbce0b13aca10a1
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 uitest.uihelper.common import select_by_text
13 from uitest.uihelper.calc import enter_text_to_cell
14 from libreoffice.calc.document import get_cell_by_position
15 from libreoffice.uno.propertyvalue import mkPropertyValues
17 #Bug 53482 - UI: Option 'Range contains column headings' ignored
19 class tdf53482(UITestCase):
21 def test_tdf53482_Range_contains_column_headings_file(self):
22 with self.ui_test.load_file(get_url_for_data_file("tdf53482.ods")) as calc_doc:
23 xCalcDoc = self.xUITest.getTopFocusWindow()
24 gridwin = xCalcDoc.getChild("grid_window")
25 #1. Highlight cells to be sorted A8:J124
26 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:J124"}))
27 #2. Click Data menu, Sort
28 with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog:
29 xTabs = xDialog.getChild("tabcontrol")
30 select_pos(xTabs, "1")
31 #3. On Options tab, tick 'Range contains column labels'
32 xHeader = xDialog.getChild("cbHeader")
33 xHeader.executeAction("CLICK", tuple())
34 if (get_state_as_dict(xHeader)["Selected"]) == "false":
35 xHeader.executeAction("CLICK", tuple())
36 #4. On Sort Criteria tab, set appropriate criteria
37 select_pos(xTabs, "0")
38 xDown = xDialog.getChild("down")
39 xDown.executeAction("CLICK", tuple())
40 xSortKey1 = xDialog.getChild("sortlb")
41 select_by_text(xSortKey1, "Occupation")
42 #5. Click Ok
43 #6. Expected behavior: Ignore column labels when sorting
44 self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 7).getString(), "Occupation")
45 self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 8).getString(), "Travel Industry")
46 self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 123).getString(), "13")
48 def test_tdf53482_Range_contains_column_headings(self):
49 with self.ui_test.create_doc_in_start_center("calc") as document:
50 xCalcDoc = self.xUITest.getTopFocusWindow()
51 gridwin = xCalcDoc.getChild("grid_window")
52 #In column A enter: Misc; s; d; f; g
53 enter_text_to_cell(gridwin, "A1", "Misc")
54 enter_text_to_cell(gridwin, "A2", "s")
55 enter_text_to_cell(gridwin, "A3", "d")
56 enter_text_to_cell(gridwin, "A4", "f")
57 enter_text_to_cell(gridwin, "A5", "g")
58 #1. Highlight cells to be sorted
59 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"}))
60 #2. Click Data menu, Sort
61 with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog:
62 xTabs = xDialog.getChild("tabcontrol")
63 select_pos(xTabs, "0")
64 #3. On Options tab, tick 'Range contains column labels'
65 xHeader = xDialog.getChild("cbHeader")
66 xHeader.executeAction("CLICK", tuple())
67 if (get_state_as_dict(xHeader)["Selected"]) == "false":
68 xHeader.executeAction("CLICK", tuple())
69 #4. On Sort Criteria tab, set appropriate criteria
70 xDown = xDialog.getChild("down")
71 xDown.executeAction("CLICK", tuple())
72 #5. Click Ok
73 #6. Expected behavior: Ignore column labels when sorting
74 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Misc")
75 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "s")
76 self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "g")
77 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "f")
78 self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "d")
81 # vim: set shiftwidth=4 softtabstop=4 expandtab: