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 99208 - Spreadsheet sort hangs
18 class tdf99208(UITestCase
):
19 def test_td99627_natural_sort(self
):
20 with self
.ui_test
.load_file(get_url_for_data_file("tdf99208.ods")) as calc_doc
:
21 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
22 gridwin
= xCalcDoc
.getChild("grid_window")
24 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C245"}))
27 #Column A - Ascending' <ok>
28 with self
.ui_test
.execute_dialog_through_command(".uno:DataSort") as xDialog
:
29 xTabs
= xDialog
.getChild("tabcontrol")
30 select_pos(xTabs
, "1")
31 xNatural
= xDialog
.getChild("naturalsort")
32 xFormats
= xDialog
.getChild("formats")
33 if (get_state_as_dict(xNatural
)["Selected"]) == "false":
34 xNatural
.executeAction("CLICK", tuple())
35 if (get_state_as_dict(xFormats
)["Selected"]) == "false":
36 xFormats
.executeAction("CLICK", tuple())
37 select_pos(xTabs
, "0")
38 xtopdown
= xDialog
.getChild("rbTopDown")
39 xHeader
= xDialog
.getChild("cbHeader")
40 if (get_state_as_dict(xHeader
)["Selected"]) == "false":
41 xHeader
.executeAction("CLICK", tuple())
42 xtopdown
.executeAction("CLICK", tuple())
44 xSortKey1
= xDialog
.getChild("sortlb")
45 xAsc
= xDialog
.getChild("up")
46 select_by_text(xSortKey1
, "FODMAP")
47 xAsc
.executeAction("CLICK", tuple())
48 #Verify Expected: Values column B sorted ascending, column "control" unsorted
49 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 0, 0).getString(), "FODMAP")
50 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 0, 1).getString(), "agave")
51 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 0, 2).getString(), "almond milk")
52 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 0, 244).getString(), "zucchini")
54 self
.xUITest
.executeCommand(".uno:Undo")
56 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 0, 0).getString(), "FODMAP")
57 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 0, 1).getString(), "beef (grass fed, no breadcrumbs)")
58 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 0, 244).getString(), "salsa")
60 # vim: set shiftwidth=4 softtabstop=4 expandtab: