Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / qa / uitest / calc_tests4 / tdf99208.py
blob94fed01c3ae29629389ab75a132493d86ae05466
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from uitest.framework import UITestCase
8 from uitest.uihelper.common import get_state_as_dict
9 from uitest.uihelper.common import select_pos
10 from uitest.uihelper.calc import enter_text_to_cell
11 from libreoffice.calc.document import get_cell_by_position
12 from libreoffice.uno.propertyvalue import mkPropertyValues
13 import org.libreoffice.unotest
14 import pathlib
15 #Bug 99208 - Spreadsheet sort hangs
16 def get_url_for_data_file(file_name):
17 return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
19 class tdf99208(UITestCase):
20 def test_td99627_natural_sort(self):
21 calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf99208.ods"))
22 xCalcDoc = self.xUITest.getTopFocusWindow()
23 gridwin = xCalcDoc.getChild("grid_window")
24 document = self.ui_test.get_component()
25 #select A3:C245
26 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C245"}))
28 #Menu 'Data -> Sort
29 #Column A - Ascending' <ok>
30 self.ui_test.execute_dialog_through_command(".uno:DataSort")
31 xDialog = self.xUITest.getTopFocusWindow()
32 xTabs = xDialog.getChild("tabcontrol")
33 select_pos(xTabs, "1")
34 xNatural = xDialog.getChild("naturalsort")
35 xtopdown = xDialog.getChild("topdown")
36 xHeader = xDialog.getChild("header")
37 xFormats = xDialog.getChild("formats")
38 if (get_state_as_dict(xNatural)["Selected"]) == "false":
39 xNatural.executeAction("CLICK", tuple())
40 if (get_state_as_dict(xHeader)["Selected"]) == "false":
41 xHeader.executeAction("CLICK", tuple())
42 if (get_state_as_dict(xFormats)["Selected"]) == "false":
43 xFormats.executeAction("CLICK", tuple())
44 xtopdown.executeAction("CLICK", tuple())
45 select_pos(xTabs, "0")
46 xSortKey1 = xDialog.getChild("sortlb")
47 xAsc = xDialog.getChild("up")
48 props = {"TEXT": "FODMAP"}
49 actionProps = mkPropertyValues(props)
50 xSortKey1.executeAction("SELECT", actionProps)
51 xAsc.executeAction("CLICK", tuple())
52 xOk = xDialog.getChild("ok")
53 self.ui_test.close_dialog_through_button(xOk)
54 #Verify Expected: Values column B sorted ascending, column "control" unsorted
55 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "FODMAP")
56 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "agave")
57 self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "almond milk")
58 self.assertEqual(get_cell_by_position(document, 0, 0, 244).getString(), "zucchini")
59 # UNDO
60 self.xUITest.executeCommand(".uno:Undo")
61 # Verify
62 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "FODMAP")
63 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "beef (grass fed, no breadcrumbs)")
64 self.assertEqual(get_cell_by_position(document, 0, 0, 244).getString(), "salsa")
66 self.ui_test.close_doc()
68 # vim: set shiftwidth=4 softtabstop=4 expandtab: