diff options
Diffstat (limited to 'sc/qa/uitest/sort')
-rw-r--r-- | sc/qa/uitest/sort/naturalSort.py | 101 | ||||
-rw-r--r-- | sc/qa/uitest/sort/sorting.py | 273 | ||||
-rw-r--r-- | sc/qa/uitest/sort/stableSorting.py | 95 | ||||
-rw-r--r-- | sc/qa/uitest/sort/subtotals.py | 140 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf100517.py | 77 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf105301.py | 40 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf126678.py | 72 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf49531.py | 58 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf53482.py | 81 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf54018.py | 40 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf57465.py | 48 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf91305.py | 105 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf95192.py | 43 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf99208.py | 60 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf99627.py | 43 | ||||
-rw-r--r-- | sc/qa/uitest/sort/tdf99773.py | 47 |
16 files changed, 1323 insertions, 0 deletions
diff --git a/sc/qa/uitest/sort/naturalSort.py b/sc/qa/uitest/sort/naturalSort.py new file mode 100644 index 000000000..91c2f35c3 --- /dev/null +++ b/sc/qa/uitest/sort/naturalSort.py @@ -0,0 +1,101 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict, select_pos + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Testcases Sorting TCS_Sorting +class CalcNaturalSorting(UITestCase): + + def test_natural_sorting_rows(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "MW100SSMOU456.996JIL4") + enter_text_to_cell(gridwin, "A2", "MW180SSMOU456.996JIL4") + enter_text_to_cell(gridwin, "A3", "MW110SSMOU456.993JIL4") + enter_text_to_cell(gridwin, "A4", "MW180SSMOU456.994JIL4") + enter_text_to_cell(gridwin, "A5", "MW101SSMOU456.996JIL4") + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xNatural = xDialog.getChild("naturalsort") + xNatural.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW100SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "MW101SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "MW110SSMOU456.993JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "MW180SSMOU456.994JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "MW180SSMOU456.996JIL4") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW100SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "MW180SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "MW110SSMOU456.993JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "MW180SSMOU456.994JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "MW101SSMOU456.996JIL4") + #enter data + enter_text_to_cell(gridwin, "D1", "MW-2") + enter_text_to_cell(gridwin, "D2", "MW-20") + enter_text_to_cell(gridwin, "D3", "MW-1") + enter_text_to_cell(gridwin, "D4", "MW-18") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "D1:D4"})) + + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "MW-1") + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "MW-2") + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "MW-18") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getString(), "MW-20") + + + def test_natural_sorting_columns(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "MW-2") + enter_text_to_cell(gridwin, "B1", "MW-20") + enter_text_to_cell(gridwin, "C1", "MW-1") + enter_text_to_cell(gridwin, "D1", "MW-18") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D1"})) + + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xleftright = xDialog.getChild("rbLeftRight") + xleftright.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW-1") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "MW-2") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "MW-18") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "MW-20") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/sorting.py b/sc/qa/uitest/sort/sorting.py new file mode 100644 index 000000000..b78eae4c7 --- /dev/null +++ b/sc/qa/uitest/sort/sorting.py @@ -0,0 +1,273 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict, select_pos + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Testcases Sorting TCS_Sorting +class CalcSorting(UITestCase): + + def test_Sortingbuttons_detect_columnheaders(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that cell A1 still contains "Number" and B1 "Misc" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that cell A1 still contains "Number" and B1 "Misc" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Open sort dialog by DATA - SORT /Switch to tabpage Options + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #Verify that option "Range contains column labels" is set + xHeader = xDialog.getChild("cbHeader") + self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true") + #Cancel dialog + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Press toolbarbutton for descending sorting + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that cell A1 still contains "Number" and B1 "Misc" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + + def test_Sortingbuttons_list_has_not_columnheaders(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: 5; 3; 4; 6; 2 / In column B enter: e; s; d; f; g + enter_text_to_cell(gridwin, "A1", "5") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "e") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that cell A1 no longer contains "5" and B1 no longer contains "e" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() != "5", True) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString() != "e", True) + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Open sort dialog by DATA - SORT /Switch to tabpage Options + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #Verify that option "Range contains column labels" is not set + xHeader = xDialog.getChild("cbHeader") + self.assertEqual(get_state_as_dict(xHeader)["Selected"], "false") + #Cancel dialog + + def test_Sorting_default_to_selected_column(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that the sortorder was determined for column A (Number;2;3;4;6) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 2) + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the sortorder was determined for column B (Misc;s;g;f;d) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "d") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "f") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "g") + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "s") + + + def test_Sorting_default_to_selected_TAB_A_column(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column A by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the sortorder was determined for column A (Number;2;3;4;6) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 6) + + + def test_Sorting_default_to_selected_TAB_B_column(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column B by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the sortorder was determined for column B (Misc;d;f;g;s) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "d") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "f") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "g") + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "s") + + + def test_Sorting_sort_criteria(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Number(ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Misc (ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column A by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Number(ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column B by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Misc (ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/stableSorting.py b/sc/qa/uitest/sort/stableSorting.py new file mode 100644 index 000000000..162bf9d7f --- /dev/null +++ b/sc/qa/uitest/sort/stableSorting.py @@ -0,0 +1,95 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Testcases Sorting TCS_Sorting Stable sorting +class CalcStableSorting(UITestCase): + + def test_Must_keep_sort_order_previous_sorting_toolbar_button_Ascending(self): + with self.ui_test.load_file(get_url_for_data_file("stableSorting.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #Select cell E1 ("Sales") and press toolbar button for ascending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + self.xUITest.executeCommand(".uno:SortAscending") + #Select cell D1 ("Product") and press toolbar button for ascending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:SortAscending") + #Select cell C1 ("Salesman") and press toolbar button for ascending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.xUITest.executeCommand(".uno:SortAscending") + # Select cell B1 ("Region") and press toolbar button for ascending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the numbers in column "CheckOrder" are ascending + for i in range(1, 501): + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, i).getValue(), i) + + def test_Must_keep_sort_order_previous_sorting_toolbar_button_Descending(self): + with self.ui_test.load_file(get_url_for_data_file("stableSorting.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #Select cell E1 ("Sales") and press toolbar button for descending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + self.xUITest.executeCommand(".uno:SortDescending") + #Select cell D1 ("Product") and press toolbar button for descending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:SortDescending") + #Select cell C1 ("Salesman") and press toolbar button for descending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.xUITest.executeCommand(".uno:SortDescending") + # Select cell B1 ("Region") and press toolbar button for descending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that the numbers in column "CheckOrder" are ascending + for i in range(1, 501): + j = 501 - i + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, i).getValue(), j) + + # def test_Must_keep_sort_order_previous_sorting_using_sort_dialog(self): +# cannot test for now - criteria names are identical - Markus https://gerrit.libreoffice.org/#/c/52534/ + # calc_doc = self.ui_test.load_file(get_url_for_data_file("stableSorting.ods")) + # xCalcDoc = self.xUITest.getTopFocusWindow() + # gridwin = xCalcDoc.getChild("grid_window") + # document = self.ui_test.get_component() +# Select cell A1 and open sort dialog by DATA - SORT + # gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) +# Open sort dialog by DATA - SORT /Switch to tabpage Options + # self.ui_test.execute_dialog_through_command(".uno:DataSort") + # xDialog = self.xUITest.getTopFocusWindow() + # xTabs = xDialog.getChild("tabcontrol") + # select_pos(xTabs, "1") +# Check option "Range contains column labels" + # xHeader = xDialog.getChild("header") + # self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true") +# Switch to tabpage "Sort Criteria" + # select_pos(xTabs, "0") +# Choose "Salesman(ascending)" as first criteria + # xSortKey1 = xDialog.getChild("sortlb") + # xAsc = xDialog.getChild("up") + # props = {"TEXT": "Salesman"} + # actionProps = mkPropertyValues(props) + # xSortKey1.executeAction("SELECT", actionProps) + # self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Choose "Product (ascending)" as second criteria + # xSortKey2 = xDialog.getChild("sortuserlb") + # xAsc = xDialog.getChild("up") + # props = {"TEXT": "Salesman"} + # actionProps = mkPropertyValues(props) + # xSortKey1.executeAction("SELECT", actionProps) + # self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + # self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/subtotals.py b/sc/qa/uitest/sort/subtotals.py new file mode 100644 index 000000000..b824dcab9 --- /dev/null +++ b/sc/qa/uitest/sort/subtotals.py @@ -0,0 +1,140 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import select_by_text, select_pos +from uitest.uihelper.common import get_url_for_data_file + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class Subtotals(UITestCase): + + def test_tdf114720(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + XcalcDoc = self.xUITest.getTopFocusWindow() + gridwin = XcalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "A3", "1") + enter_text_to_cell(gridwin, "A4", "1") + enter_text_to_cell(gridwin, "A5", "1") + enter_text_to_cell(gridwin, "A6", "1") + enter_text_to_cell(gridwin, "A7", "1") + enter_text_to_cell(gridwin, "A8", "1") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A9"})) + + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals"): + pass + + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "") + + # check cancel button + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals", close_button="cancel"): + pass + + + def test_tdf88792(self): + with self.ui_test.load_file(get_url_for_data_file("tdf88792.ods")) as calc_doc: + XcalcDoc = self.xUITest.getTopFocusWindow() + gridwin = XcalcDoc.getChild("grid_window") + + # go to cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + # Select from the menu bar Data + # Select option subtotal + # Subtotal dialog displays + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") as xDialog: + # Select group by: Category + xGroupBy = xDialog.getChild("group_by1") + select_by_text(xGroupBy, "Category") + # Select calculate subtotals for the months - selected by default + # Select tab options + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") + # select option include formats + xformats = xDialog.getChild("formats") + xformats.executeAction("CLICK", tuple()) + # apply with OK + + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 5).getValue(), 28000) + + def test_tdf88735(self): + with self.ui_test.load_file(get_url_for_data_file("tdf88735.ods")) as calc_doc: + # 1 select all cells + self.xUITest.executeCommand(".uno:SelectAll")#use uno command Menu Edit->Select All + # 2 invoke sub-total menu and select none + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") as xDialog: + xGroupBy = xDialog.getChild("group_by1") + select_by_text(xGroupBy, "- none -") + # 2 invoke sort menu and... crash + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel"): + pass + + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 8).getString(), "z") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 8).getValue(), 8) + + def test_tdf56958(self): + with self.ui_test.load_file(get_url_for_data_file("tdf56958.ods")) as calc_doc: + # 1. Open the test file + # 2. Data->Subtotals + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") as xDialog: + # 3. Group by->Trans date + xGroupBy = xDialog.getChild("group_by1") + select_by_text(xGroupBy, "Trans Date") + # 4. Tick 'Calculate subtotals for' -> Amount (grid1) + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns1") + xFirstEntry = xTreeList.getChild("2") + xFirstEntry.executeAction("CLICK", tuple()) + # 5. Click OK + # 6. Data->Subtotals + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") as xDialog: + # 7. Group by->-none- + xGroupBy = xDialog.getChild("group_by1") + select_by_text(xGroupBy, "- none -") + # 8. Untick 'Calculate subtotals for' -> Amount + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns1") + xFirstEntry = xTreeList.getChild("2") + xFirstEntry.executeAction("CLICK", tuple()) + # 9. Click OK + # 10. Data->Sort + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + # 11. Sort key 1->Post Date. + sortkey1 = xDialog.getChild("sortlb") + select_by_text(sortkey1, "Post Date") + # 12. Sort key 2->-undefined- + sortkey2 = xDialog.getChild("sortuserlb") + select_by_text(sortkey2, "- undefined -") + # 13. Click OK + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 1).getValue(), -0.25) + + def test_tdf55734(self): + with self.ui_test.load_file(get_url_for_data_file("tdf55734.ods")) as calc_doc: + XcalcDoc = self.xUITest.getTopFocusWindow() + gridwin = XcalcDoc.getChild("grid_window") + # 1. Open attached document + # 2. Place cursor in cell outside of subtotals range (e.g. B7) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"})) + # 3. Data → Subtotals + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") as xDialog: + # 4. Group by: "- none -" + xGroupBy = xDialog.getChild("group_by1") + select_by_text(xGroupBy, "- none -") + # 5. Press "OK" and watch LibreOffice crash. + + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getValue(), 1) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 1).getValue(), 2) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf100517.py b/sc/qa/uitest/sort/tdf100517.py new file mode 100644 index 000000000..d5a6097f5 --- /dev/null +++ b/sc/qa/uitest/sort/tdf100517.py @@ -0,0 +1,77 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf100517(UITestCase): + + def execute_sort_dialog(self, gridwin, bIncludeNotes): + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B3"})) + + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + + xIncludeNotes = xDialog.getChild("includenotes") + + if (get_state_as_dict(xIncludeNotes)["Selected"]) != bIncludeNotes: + xIncludeNotes.executeAction("CLICK", tuple()) + + + def test_tdf100517(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "Text 2") + enter_text_to_cell(gridwin, "A2", "Text 3") + enter_text_to_cell(gridwin, "A3", "Text 1") + + for i in ['B1', 'B2', 'B3']: + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": i})) + xArgs = mkPropertyValues({"Text": i}) + + self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs) + + self.execute_sort_dialog(gridwin, "true") + + self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) + + self.assertEqual("B3", get_cell_by_position(document, 0, 1, 0).Annotation.String) + self.assertEqual("B1", get_cell_by_position(document, 0, 1, 1).Annotation.String) + self.assertEqual("B2", get_cell_by_position(document, 0, 1, 2).Annotation.String) + + self.xUITest.executeCommand(".uno:Undo") + + self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 2).getString()) + + self.assertEqual("B1", get_cell_by_position(document, 0, 1, 0).Annotation.String) + self.assertEqual("B2", get_cell_by_position(document, 0, 1, 1).Annotation.String) + self.assertEqual("B3", get_cell_by_position(document, 0, 1, 2).Annotation.String) + + self.execute_sort_dialog(gridwin, "false") + + self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) + + self.assertEqual("B1", get_cell_by_position(document, 0, 1, 0).Annotation.String) + self.assertEqual("B2", get_cell_by_position(document, 0, 1, 1).Annotation.String) + self.assertEqual("B3", get_cell_by_position(document, 0, 1, 2).Annotation.String) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf105301.py b/sc/qa/uitest/sort/tdf105301.py new file mode 100644 index 000000000..c215e95bc --- /dev/null +++ b/sc/qa/uitest/sort/tdf105301.py @@ -0,0 +1,40 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_pos +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf105301(UITestCase): + + def test_tdf105301(self): + with self.ui_test.load_file(get_url_for_data_file("tdf105301.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:R9"})) + + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + self.assertEqual("B", get_state_as_dict(xDialog.getChild("sortlb"))['DisplayText']) + self.assertEqual("C", get_state_as_dict(xDialog.getChild("sortlb2"))['DisplayText']) + self.assertEqual("D", get_state_as_dict(xDialog.getChild("sortlb3"))['DisplayText']) + + # Without the fix in place, this test would have failed with + # AssertionError: 'E' != '- undefined -' + self.assertEqual("E", get_state_as_dict(xDialog.getChild("sortlb4"))['DisplayText']) + self.assertEqual("F", get_state_as_dict(xDialog.getChild("sortlb5"))['DisplayText']) + self.assertEqual("G", get_state_as_dict(xDialog.getChild("sortlb6"))['DisplayText']) + + # tdf#51828: Without the fix in place, this test would have failed here + self.assertEqual("- undefined -", get_state_as_dict(xDialog.getChild("sortlb7"))['DisplayText']) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf126678.py b/sc/qa/uitest/sort/tdf126678.py new file mode 100644 index 000000000..80e12a5da --- /dev/null +++ b/sc/qa/uitest/sort/tdf126678.py @@ -0,0 +1,72 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf126678(UITestCase): + + def execute_sort_dialog(self, gridwin, bIncludeFormats): + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B3"})) + + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + + xIncludeFormats = xDialog.getChild("formats") + + if (get_state_as_dict(xIncludeFormats)["Selected"]) != bIncludeFormats: + xIncludeFormats.executeAction("CLICK", tuple()) + + + def test_tdf126678(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "Text 2") + enter_text_to_cell(gridwin, "A2", "Text 3") + enter_text_to_cell(gridwin, "A3", "Text 1") + + # Set the background of the corresponding cell + colorProperty = mkPropertyValues({"BackgroundColor": 16776960}) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + self.xUITest.executeCommandWithParameters(".uno:BackgroundColor", colorProperty) + + self.execute_sort_dialog(gridwin, "false") + + self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) + + # Sorting without option "including formats" does not include cells with cell formats + self.assertEqual(get_cell_by_position(document, 0, 1, 0).CellBackColor, -1) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).CellBackColor, 16776960) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).CellBackColor, -1) + + self.xUITest.executeCommand(".uno:Undo") + + self.execute_sort_dialog(gridwin, "true") + + self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) + + # Sorting with option "including formats" includes all cells with visible cell formats + # tdf126678 - Without the fix in place, the test would have failed with + # AssertionError: -1 != 16776960 + self.assertEqual(get_cell_by_position(document, 0, 1, 0).CellBackColor, -1) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).CellBackColor, -1) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).CellBackColor, 16776960) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf49531.py b/sc/qa/uitest/sort/tdf49531.py new file mode 100644 index 000000000..6e0498cfa --- /dev/null +++ b/sc/qa/uitest/sort/tdf49531.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_by_text, select_pos + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 49531 - EDITING: Sort rows for will sort columns +# Bug 49520 - EDITING: CRASH when undo sort with chart +class tdf49531(UITestCase): + def test_td49531_sort_undo_crash(self): + with self.ui_test.load_file(get_url_for_data_file("tdf49531.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A3:C147 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A3:C147"})) + + #Menu 'Data -> Sort -> Top to bottom - all otheroptions unchecked + #Column B - Ascending' <ok> + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "true": + xNatural.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xtopdown = xDialog.getChild("rbTopDown") + xHeader = xDialog.getChild("cbHeader") + if (get_state_as_dict(xHeader)["Selected"]) == "true": + xHeader.executeAction("CLICK", tuple()) + xtopdown.executeAction("CLICK", tuple()) + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + select_by_text(xSortKey1, "B") + xAsc.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "x") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "0") + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 2).getValue(), 111) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 3).getValue(), 48) + # UNDO Bug 49520 - EDITING: CRASH when undo sort with chart + self.xUITest.executeCommand(".uno:Undo") + # Verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "x") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "0") + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 3).getValue(), 3) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf53482.py b/sc/qa/uitest/sort/tdf53482.py new file mode 100644 index 000000000..fbcbac0a8 --- /dev/null +++ b/sc/qa/uitest/sort/tdf53482.py @@ -0,0 +1,81 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import select_by_text +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 53482 - UI: Option 'Range contains column headings' ignored + +class tdf53482(UITestCase): + + def test_tdf53482_Range_contains_column_headings_file(self): + with self.ui_test.load_file(get_url_for_data_file("tdf53482.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #1. Highlight cells to be sorted A8:J124 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:J124"})) + #2. Click Data menu, Sort + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #3. On Options tab, tick 'Range contains column labels' + xHeader = xDialog.getChild("cbHeader") + xHeader.executeAction("CLICK", tuple()) + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + #4. On Sort Criteria tab, set appropriate criteria + select_pos(xTabs, "0") + xDown = xDialog.getChild("down") + xDown.executeAction("CLICK", tuple()) + xSortKey1 = xDialog.getChild("sortlb") + select_by_text(xSortKey1, "Occupation") + #5. Click Ok + #6. Expected behavior: Ignore column labels when sorting + self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 7).getString(), "Occupation") + self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 8).getString(), "Travel Industry") + self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 123).getString(), "13") + + def test_tdf53482_Range_contains_column_headings(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Misc") + enter_text_to_cell(gridwin, "A2", "s") + enter_text_to_cell(gridwin, "A3", "d") + enter_text_to_cell(gridwin, "A4", "f") + enter_text_to_cell(gridwin, "A5", "g") + #1. Highlight cells to be sorted + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) + #2. Click Data menu, Sort + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #3. On Options tab, tick 'Range contains column labels' + xHeader = xDialog.getChild("cbHeader") + xHeader.executeAction("CLICK", tuple()) + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + #4. On Sort Criteria tab, set appropriate criteria + xDown = xDialog.getChild("down") + xDown.executeAction("CLICK", tuple()) + #5. Click Ok + #6. Expected behavior: Ignore column labels when sorting + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Misc") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "s") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "g") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "f") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "d") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf54018.py b/sc/qa/uitest/sort/tdf54018.py new file mode 100644 index 000000000..147fb8fa9 --- /dev/null +++ b/sc/qa/uitest/sort/tdf54018.py @@ -0,0 +1,40 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +from uitest.uihelper.common import select_by_text, select_pos + +from libreoffice.calc.document import get_cell_by_position + + +# Bug 54018 - EDITING: CRASH sorting cells range with Comments +class tdf54018(UITestCase): + def test_td54018_sort_with_comments(self): + with self.ui_test.load_file(get_url_for_data_file("tdf54018.ods")) as calc_doc: + #click top left columns / rows heading field to select all cells + self.xUITest.executeCommand(".uno:SelectAll") + #Menu 'Data -> Sort -> Column D -> Descending' <ok> + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xSortKey1 = xDialog.getChild("sortlb") + xdown = xDialog.getChild("down") + select_by_text(xSortKey1, "Column B") + xdown.executeAction("CLICK", tuple()) + #Bug: When progress bar reaches 40% LibO Stops responding + #Verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 0).getString(), "7") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 1).getString(), "6") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 2).getString(), "5") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 3).getString(), "4") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 4).getString(), "3") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 5).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 6).getString(), "1") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf57465.py b/sc/qa/uitest/sort/tdf57465.py new file mode 100644 index 000000000..bd7efaabc --- /dev/null +++ b/sc/qa/uitest/sort/tdf57465.py @@ -0,0 +1,48 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_pos +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf57465(UITestCase): + + def test_tdf57465(self): + with self.ui_test.load_file(get_url_for_data_file("tdf57465.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:G4"})) + + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + + xHeader = xDialog.getChild("cbHeader") + if (get_state_as_dict(xHeader)["Selected"]) == 'true': + xHeader.executeAction("CLICK", tuple()) + + xLeftRight = xDialog.getChild("rbLeftRight") + xLeftRight.executeAction("CLICK", tuple()) + + self.assertEqual("1", get_state_as_dict(xDialog.getChild("sortlb"))['DisplayText']) + + + self.assertEqual("a", get_cell_by_position(calc_doc, 0, 1, 1).getString()) + + # Without the fix in place, this test would have failed with + # AssertionError: 'b' != '' + self.assertEqual("b", get_cell_by_position(calc_doc, 0, 2, 2).getString()) + self.assertEqual("c", get_cell_by_position(calc_doc, 0, 3, 3).getString()) + self.assertEqual("d", get_cell_by_position(calc_doc, 0, 4, 1).getString()) + self.assertEqual("e", get_cell_by_position(calc_doc, 0, 5, 2).getString()) + self.assertEqual("f", get_cell_by_position(calc_doc, 0, 6, 3).getString()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf91305.py b/sc/qa/uitest/sort/tdf91305.py new file mode 100644 index 000000000..bc0b8738f --- /dev/null +++ b/sc/qa/uitest/sort/tdf91305.py @@ -0,0 +1,105 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 91305 - Sort button does not sort first cell if it has text format +class tdf91305(UITestCase): + + def test_tdf91305_sort_text_cells_columns(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter texts + enter_text_to_cell(gridwin, "A1", "cc") + enter_text_to_cell(gridwin, "B1", "ff") + enter_text_to_cell(gridwin, "C1", "aa") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C1"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("rbLeftRight") + select_pos(xTabs, "0") + xleftright.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "ff") + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("rbLeftRight") + xdown = xDialog.getChild("down") + select_pos(xTabs, "0") + xleftright.executeAction("CLICK", tuple()) + xdown.executeAction("CLICK", tuple()) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "aa") + + #comment 6 - Additional sub-bugs: + def test_tdf91305_sort_text_cells_rows(self): + #Selecting some empty cells and pressing SORT causes empty cells to move below. + #No matter if you sort from A to Z or from Z to A. + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter text + enter_text_to_cell(gridwin, "A5", "ff") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + #sorting + self.xUITest.executeCommand(".uno:SortAscending") + self.xUITest.executeCommand(".uno:SortDescending") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "ff") + # Assert that the correct range has been selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A1:Sheet1.A4") + + + #2) Placing digit to the header position and running set of sorts will make digit to be on 2nd or last position. + def test_tdf91305_sort_text_cells_1st_row_digit(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter texts + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "ff") + enter_text_to_cell(gridwin, "A3", "aa") + enter_text_to_cell(gridwin, "A4", "cc") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + #Press toolbarbutton for ascending sorting .uno:SortAsc + self.xUITest.executeCommand(".uno:SortAscending") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "ff") + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "1") + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "ff") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf95192.py b/sc/qa/uitest/sort/tdf95192.py new file mode 100644 index 000000000..1c33f56f7 --- /dev/null +++ b/sc/qa/uitest/sort/tdf95192.py @@ -0,0 +1,43 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file, select_pos + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 95192 - SORTING Natural sorting not working with non-letter,non-number content +class tdf95192(UITestCase): + def test_td99627_natural_sort(self): + with self.ui_test.load_file(get_url_for_data_file("tdf95192.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xNatural.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "Sal. Capra 1/17") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "Sal. Capra 1/20") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 2).getString(), "Sal. Oregina 1/2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 41).getString(), "Vico Chiuso Cinque Santi 18/10") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "Sal. Oregina 1/2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "Via A. Centurione 11/7") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 41).getString(), "Vico Chiuso Cinque Santi 18/10") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf99208.py b/sc/qa/uitest/sort/tdf99208.py new file mode 100644 index 000000000..e740a9c4a --- /dev/null +++ b/sc/qa/uitest/sort/tdf99208.py @@ -0,0 +1,60 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_by_text, select_pos + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 99208 - Spreadsheet sort hangs +class tdf99208(UITestCase): + def test_td99627_natural_sort(self): + with self.ui_test.load_file(get_url_for_data_file("tdf99208.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A3:C245 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C245"})) + + #Menu 'Data -> Sort + #Column A - Ascending' <ok> + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xFormats = xDialog.getChild("formats") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + if (get_state_as_dict(xFormats)["Selected"]) == "false": + xFormats.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xtopdown = xDialog.getChild("rbTopDown") + xHeader = xDialog.getChild("cbHeader") + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + xtopdown.executeAction("CLICK", tuple()) + + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + select_by_text(xSortKey1, "FODMAP") + xAsc.executeAction("CLICK", tuple()) + #Verify Expected: Values column B sorted ascending, column "control" unsorted + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "FODMAP") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "agave") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 2).getString(), "almond milk") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 244).getString(), "zucchini") + # UNDO + self.xUITest.executeCommand(".uno:Undo") + # Verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "FODMAP") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "beef (grass fed, no breadcrumbs)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 244).getString(), "salsa") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf99627.py b/sc/qa/uitest/sort/tdf99627.py new file mode 100644 index 000000000..281f4340d --- /dev/null +++ b/sc/qa/uitest/sort/tdf99627.py @@ -0,0 +1,43 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file, select_pos + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 99627 - Calc freezes when applying natural sorting on text columns +class tdf99627(UITestCase): + def test_td99627_natural_sort(self): + with self.ui_test.load_file(get_url_for_data_file("tdf99627.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xdown = xDialog.getChild("down") + xNatural.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xdown.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "2998") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 2998).getString(), "1") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "1") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 2998).getString(), "2998") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf99773.py b/sc/qa/uitest/sort/tdf99773.py new file mode 100644 index 000000000..49775899f --- /dev/null +++ b/sc/qa/uitest/sort/tdf99773.py @@ -0,0 +1,47 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict, select_pos + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 99773 - EDITING: calc freezes if sorting in natural mode +class tdf99773(UITestCase): + def test_tdf99773_natural_sorting_space(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "A 11") + enter_text_to_cell(gridwin, "A2", "A 2") + enter_text_to_cell(gridwin, "A3", "B 2") + enter_text_to_cell(gridwin, "A4", "A 5") + enter_text_to_cell(gridwin, "A5", "A 50") + enter_text_to_cell(gridwin, "A6", "B 20") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A6"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A 2") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "A 5") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "A 11") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "A 50") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "B 2") + self.assertEqual(get_cell_by_position(document, 0, 0, 5).getString(), "B 20") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |