From 19a2ea083355344acaaff4bdd2d83f76935da099 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Tue, 16 Feb 2021 10:31:40 +0100 Subject: uitest: sc: move these tests to 'sort' folder Change-Id: Ib91417c3edd5f449074f55b2a1628e4ee2df4a6c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110980 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sc/qa/uitest/calc_tests/naturalSort.py | 113 ----------- sc/qa/uitest/calc_tests/sorting.py | 303 ------------------------------ sc/qa/uitest/calc_tests2/stableSorting.py | 100 ---------- sc/qa/uitest/calc_tests2/subtotals.py | 189 ------------------- sc/qa/uitest/calc_tests2/tdf53482.py | 92 --------- sc/qa/uitest/calc_tests2/tdf54018.py | 50 ----- sc/qa/uitest/calc_tests4/tdf91305.py | 140 -------------- sc/qa/uitest/calc_tests4/tdf95192.py | 47 ----- sc/qa/uitest/calc_tests4/tdf99208.py | 65 ------- sc/qa/uitest/calc_tests4/tdf99627.py | 48 ----- sc/qa/uitest/calc_tests4/tdf99773.py | 52 ----- sc/qa/uitest/sort/naturalSort.py | 113 +++++++++++ sc/qa/uitest/sort/sorting.py | 303 ++++++++++++++++++++++++++++++ sc/qa/uitest/sort/stableSorting.py | 100 ++++++++++ sc/qa/uitest/sort/subtotals.py | 189 +++++++++++++++++++ sc/qa/uitest/sort/tdf53482.py | 92 +++++++++ sc/qa/uitest/sort/tdf54018.py | 50 +++++ sc/qa/uitest/sort/tdf91305.py | 140 ++++++++++++++ sc/qa/uitest/sort/tdf95192.py | 47 +++++ sc/qa/uitest/sort/tdf99208.py | 65 +++++++ sc/qa/uitest/sort/tdf99627.py | 48 +++++ sc/qa/uitest/sort/tdf99773.py | 52 +++++ 22 files changed, 1199 insertions(+), 1199 deletions(-) delete mode 100644 sc/qa/uitest/calc_tests/naturalSort.py delete mode 100644 sc/qa/uitest/calc_tests/sorting.py delete mode 100644 sc/qa/uitest/calc_tests2/stableSorting.py delete mode 100644 sc/qa/uitest/calc_tests2/subtotals.py delete mode 100644 sc/qa/uitest/calc_tests2/tdf53482.py delete mode 100644 sc/qa/uitest/calc_tests2/tdf54018.py delete mode 100644 sc/qa/uitest/calc_tests4/tdf91305.py delete mode 100644 sc/qa/uitest/calc_tests4/tdf95192.py delete mode 100644 sc/qa/uitest/calc_tests4/tdf99208.py delete mode 100644 sc/qa/uitest/calc_tests4/tdf99627.py delete mode 100644 sc/qa/uitest/calc_tests4/tdf99773.py create mode 100644 sc/qa/uitest/sort/naturalSort.py create mode 100644 sc/qa/uitest/sort/sorting.py create mode 100644 sc/qa/uitest/sort/stableSorting.py create mode 100644 sc/qa/uitest/sort/subtotals.py create mode 100644 sc/qa/uitest/sort/tdf53482.py create mode 100644 sc/qa/uitest/sort/tdf54018.py create mode 100644 sc/qa/uitest/sort/tdf91305.py create mode 100644 sc/qa/uitest/sort/tdf95192.py create mode 100644 sc/qa/uitest/sort/tdf99208.py create mode 100644 sc/qa/uitest/sort/tdf99627.py create mode 100644 sc/qa/uitest/sort/tdf99773.py diff --git a/sc/qa/uitest/calc_tests/naturalSort.py b/sc/qa/uitest/calc_tests/naturalSort.py deleted file mode 100644 index bd583a3c9a2c..000000000000 --- a/sc/qa/uitest/calc_tests/naturalSort.py +++ /dev/null @@ -1,113 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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_sheet_from_doc -from libreoffice.calc.conditional_format import get_conditional_format_from_sheet -from uitest.debug import sleep -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): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xNatural = xDialog.getChild("naturalsort") - xNatural.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) - - 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") - - self.ui_test.close_doc() - - def test_natural_sorting_columns(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - xleftright = xDialog.getChild("leftright") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - xleftright.executeAction("CLICK", tuple()) - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) - - #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") - - self.ui_test.close_doc() -# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/sorting.py b/sc/qa/uitest/calc_tests/sorting.py deleted file mode 100644 index 4b56ceea7c5b..000000000000 --- a/sc/qa/uitest/calc_tests/sorting.py +++ /dev/null @@ -1,303 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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_sheet_from_doc -from libreoffice.calc.conditional_format import get_conditional_format_from_sheet -from uitest.debug import sleep -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): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #Verify that option "Range contains column labels" is set - xHeader = xDialog.getChild("header") - self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true") - #Cancel dialog - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) - #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") - self.ui_test.close_doc() - - def test_Sortingbuttons_list_has_not_columnheaders(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #Verify that option "Range contains column labels" is not set - xHeader = xDialog.getChild("header") - self.assertEqual(get_state_as_dict(xHeader)["Selected"], "false") - #Cancel dialog - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) - self.ui_test.close_doc() - - def test_Sorting_default_to_selected_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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") - - self.ui_test.close_doc() - - def test_Sorting_default_to_selected_TAB_A_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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) - - self.ui_test.close_doc() - - def test_Sorting_default_to_selected_TAB_B_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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") - - self.ui_test.close_doc() - - def test_Sorting_sort_criteria(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - 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 - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) - #Select cell B3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) - #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - 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 - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - 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 - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - 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 - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) - - self.ui_test.close_doc() -# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/stableSorting.py b/sc/qa/uitest/calc_tests2/stableSorting.py deleted file mode 100644 index 269bd5252f2b..000000000000 --- a/sc/qa/uitest/calc_tests2/stableSorting.py +++ /dev/null @@ -1,100 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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.calc import enter_text_to_cell -from libreoffice.calc.document import get_sheet_from_doc -from libreoffice.calc.conditional_format import get_conditional_format_from_sheet -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): - 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 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(document, 0, 5, i).getValue(), i) - self.ui_test.close_doc() - - def test_Must_keep_sort_order_previous_sorting_toolbar_button_Descending(self): - 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 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(document, 0, 5, i).getValue(), j) - self.ui_test.close_doc() - - # 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/calc_tests2/subtotals.py b/sc/qa/uitest/calc_tests2/subtotals.py deleted file mode 100644 index 3a48cd21335a..000000000000 --- a/sc/qa/uitest/calc_tests2/subtotals.py +++ /dev/null @@ -1,189 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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 libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.framework import UITestCase -from libreoffice.calc.document import get_column -from uitest.uihelper.calc import enter_text_to_cell -from libreoffice.calc.document import get_cell_by_position -from uitest.uihelper.common import select_pos -from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file - -class Subtotals(UITestCase): - - def test_tdf114720(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - XcalcDoc = self.xUITest.getTopFocusWindow() - document = self.ui_test.get_component() - 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"})) - - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - 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 - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) - - self.ui_test.close_doc() - - def test_tdf88792(self): - calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf88792.ods")) - XcalcDoc = self.xUITest.getTopFocusWindow() - document = self.ui_test.get_component() - 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 - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - # Select group by: Category - xGroupBy = xDialog.getChild("group_by") - props = {"TEXT": "Category"} - actionProps = mkPropertyValues(props) - xGroupBy.executeAction("SELECT", actionProps) - # 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 - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.assertEqual(get_cell_by_position(document, 0, 3, 5).getValue(), 28000) - self.ui_test.close_doc() - - def test_tdf88735(self): - calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf88735.ods")) - XcalcDoc = self.xUITest.getTopFocusWindow() - document = self.ui_test.get_component() - gridwin = XcalcDoc.getChild("grid_window") - # 1 select all cells - self.xUITest.executeCommand(".uno:SelectAll")#use uno command Menu Edit->Select All - # 2 invoke sub-total menu and select none - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - xGroupBy = xDialog.getChild("group_by") - props = {"TEXT": "- none -"} - actionProps = mkPropertyValues(props) - xGroupBy.executeAction("SELECT", actionProps) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - # 2 invoke sort menu and... crash - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) - - self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "z") - self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 8) - self.ui_test.close_doc() - - def test_tdf56958(self): - calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf56958.ods")) - XcalcDoc = self.xUITest.getTopFocusWindow() - document = self.ui_test.get_component() - gridwin = XcalcDoc.getChild("grid_window") - # 1. Open the test file - # 2. Data->Subtotals - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - # 3. Group by->Trans date - xGroupBy = xDialog.getChild("group_by") - props = {"TEXT": "Trans Date"} - actionProps = mkPropertyValues(props) - xGroupBy.executeAction("SELECT", actionProps) - # 4. Tick 'Calculate subtotals for' -> Amount (grid1) - xCheckListMenu = xDialog.getChild("grid1") - xTreeList = xCheckListMenu.getChild("columns") - xFirstEntry = xTreeList.getChild("2") - xFirstEntry.executeAction("CLICK", tuple()) - # 5. Click OK - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - # 6. Data->Subtotals - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - # 7. Group by->-none- - xGroupBy = xDialog.getChild("group_by") - props = {"TEXT": "- none -"} - actionProps = mkPropertyValues(props) - xGroupBy.executeAction("SELECT", actionProps) - # 8. Untick 'Calculate subtotals for' -> Amount - xCheckListMenu = xDialog.getChild("grid1") - xTreeList = xCheckListMenu.getChild("columns") - xFirstEntry = xTreeList.getChild("2") - xFirstEntry.executeAction("CLICK", tuple()) - # 9. Click OK - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - # 10. Data->Sort - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - # 11. Sort key 1->Post Date. - sortkey1 = xDialog.getChild("sortlb") - props = {"TEXT": "Post Date"} - actionProps = mkPropertyValues(props) - sortkey1.executeAction("SELECT", actionProps) - # 12. Sort key 2->-undefined- - sortkey2 = xDialog.getChild("sortuserlb") - props = {"TEXT": "- undefined -"} - actionProps = mkPropertyValues(props) - sortkey2.executeAction("SELECT", actionProps) - # 13. Click OK - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), -0.25) - self.ui_test.close_doc() - - def test_tdf55734(self): - calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf55734.ods")) - XcalcDoc = self.xUITest.getTopFocusWindow() - document = self.ui_test.get_component() - 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 - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - # 4. Group by: "- none -" - xGroupBy = xDialog.getChild("group_by") - props = {"TEXT": "- none -"} - actionProps = mkPropertyValues(props) - xGroupBy.executeAction("SELECT", actionProps) - # 5. Press "OK" and watch LibreOffice crash. - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 2) - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf53482.py b/sc/qa/uitest/calc_tests2/tdf53482.py deleted file mode 100644 index 95e2533849f0..000000000000 --- a/sc/qa/uitest/calc_tests2/tdf53482.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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.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): - calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf53482.ods")) - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #1. Highlight cells to be sorted A8:J124 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:J124"})) - #2. Click Data menu, Sort - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #3. On Options tab, tick 'Range contains column labels' - xHeader = xDialog.getChild("header") - 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") - props = {"TEXT": "Occupation"} - actionProps = mkPropertyValues(props) - xSortKey1.executeAction("SELECT", actionProps) - #5. Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) - #6. Expected behavior: Ignore column labels when sorting - self.assertEqual(get_cell_by_position(document, 0, 6, 7).getString(), "Occupation") - self.assertEqual(get_cell_by_position(document, 0, 6, 8).getString(), "Travel Industry") - self.assertEqual(get_cell_by_position(document, 0, 6, 123).getString(), "13") - - self.ui_test.close_doc() - - def test_tdf53482_Range_contains_column_headings(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #3. On Options tab, tick 'Range contains column labels' - xHeader = xDialog.getChild("header") - 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()) - #5. Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) - #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") - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/tdf54018.py b/sc/qa/uitest/calc_tests2/tdf54018.py deleted file mode 100644 index ea9fc2994e2e..000000000000 --- a/sc/qa/uitest/calc_tests2/tdf54018.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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.calc import enter_text_to_cell -from libreoffice.calc.document import get_cell_by_position -from libreoffice.uno.propertyvalue import mkPropertyValues - -#Bug 54018 - EDITING: CRASH sorting cells range with Comments - -class tdf54018(UITestCase): - def test_td54018_sort_with_comments(self): - calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf54018.ods")) - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - #click top left columns / rows heading field to select all cells - self.xUITest.executeCommand(".uno:SelectAll") - #Menu 'Data -> Sort -> Column D -> Descending' - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xSortKey1 = xDialog.getChild("sortlb") - xdown = xDialog.getChild("down") - props = {"TEXT": "Column B"} - actionProps = mkPropertyValues(props) - xSortKey1.executeAction("SELECT", actionProps) - xdown.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Bug: When progress bar reaches 40% LibO Stops responding - #Verify - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "7") - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "6") - self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "5") - self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "4") - self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "3") - self.assertEqual(get_cell_by_position(document, 0, 1, 5).getString(), "2") - self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "1") - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf91305.py b/sc/qa/uitest/calc_tests4/tdf91305.py deleted file mode 100644 index eae7e8c4555e..000000000000 --- a/sc/qa/uitest/calc_tests4/tdf91305.py +++ /dev/null @@ -1,140 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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_sheet_from_doc -from libreoffice.calc.conditional_format import get_conditional_format_from_sheet -from uitest.debug import sleep -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_rows(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter texts - enter_text_to_cell(gridwin, "A1", "cc") - enter_text_to_cell(gridwin, "A2", "ff") - enter_text_to_cell(gridwin, "A3", "aa") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) - #Press toolbarbutton for ascending sorting .uno:SortAsc - self.xUITest.executeCommand(".uno:SortAscending") - #verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).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") - - def test_tdf91305_sort_text_cells_columns(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - xleftright = xDialog.getChild("leftright") - select_pos(xTabs, "1") - xleftright.executeAction("CLICK", tuple()) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - xleftright = xDialog.getChild("leftright") - xdown = xDialog.getChild("down") - select_pos(xTabs, "1") - xleftright.executeAction("CLICK", tuple()) - select_pos(xTabs, "0") - xdown.executeAction("CLICK", tuple()) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) - 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") - self.ui_test.close_doc() - - #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. - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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") - - self.ui_test.close_doc() - - #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): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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") - - self.ui_test.close_doc() -# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf95192.py b/sc/qa/uitest/calc_tests4/tdf95192.py deleted file mode 100644 index be310f6a4eb1..000000000000 --- a/sc/qa/uitest/calc_tests4/tdf95192.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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.calc import enter_text_to_cell -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): - calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf95192.ods")) - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - - #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - xNatural.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Sal. Capra 1/17") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Sal. Capra 1/20") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "Sal. Oregina 1/2") - self.assertEqual(get_cell_by_position(document, 0, 0, 41).getString(), "Vico Chiuso Cinque Santi 18/10") - #UNDO - self.xUITest.executeCommand(".uno:Undo") - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Sal. Oregina 1/2") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Via A. Centurione 11/7") - self.assertEqual(get_cell_by_position(document, 0, 0, 41).getString(), "Vico Chiuso Cinque Santi 18/10") - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf99208.py b/sc/qa/uitest/calc_tests4/tdf99208.py deleted file mode 100644 index f590b9f2063e..000000000000 --- a/sc/qa/uitest/calc_tests4/tdf99208.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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.calc import enter_text_to_cell -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): - calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf99208.ods")) - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select A3:C245 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C245"})) - - #Menu 'Data -> Sort - #Column A - Ascending' - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - xtopdown = xDialog.getChild("topdown") - xHeader = xDialog.getChild("header") - xFormats = xDialog.getChild("formats") - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) - if (get_state_as_dict(xHeader)["Selected"]) == "false": - xHeader.executeAction("CLICK", tuple()) - if (get_state_as_dict(xFormats)["Selected"]) == "false": - xFormats.executeAction("CLICK", tuple()) - xtopdown.executeAction("CLICK", tuple()) - select_pos(xTabs, "0") - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - props = {"TEXT": "FODMAP"} - actionProps = mkPropertyValues(props) - xSortKey1.executeAction("SELECT", actionProps) - xAsc.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) - #Verify Expected: Values column B sorted ascending, column "control" unsorted - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "FODMAP") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "agave") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "almond milk") - self.assertEqual(get_cell_by_position(document, 0, 0, 244).getString(), "zucchini") - # UNDO - self.xUITest.executeCommand(".uno:Undo") - # Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "FODMAP") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "beef (grass fed, no breadcrumbs)") - self.assertEqual(get_cell_by_position(document, 0, 0, 244).getString(), "salsa") - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf99627.py b/sc/qa/uitest/calc_tests4/tdf99627.py deleted file mode 100644 index d5071adeae79..000000000000 --- a/sc/qa/uitest/calc_tests4/tdf99627.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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.calc import enter_text_to_cell -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): - calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf99627.ods")) - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - - #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - 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()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "2998") - self.assertEqual(get_cell_by_position(document, 0, 0, 2998).getString(), "1") - #UNDO - self.xUITest.executeCommand(".uno:Undo") - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "1") - self.assertEqual(get_cell_by_position(document, 0, 0, 2998).getString(), "2998") - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf99773.py b/sc/qa/uitest/calc_tests4/tdf99773.py deleted file mode 100644 index 099788fa1428..000000000000 --- a/sc/qa/uitest/calc_tests4/tdf99773.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# 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_sheet_from_doc -from libreoffice.calc.conditional_format import get_conditional_format_from_sheet -from uitest.debug import sleep -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): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #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 - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) - #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") - - self.ui_test.close_doc() -# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/naturalSort.py b/sc/qa/uitest/sort/naturalSort.py new file mode 100644 index 000000000000..bd583a3c9a2c --- /dev/null +++ b/sc/qa/uitest/sort/naturalSort.py @@ -0,0 +1,113 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +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): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xNatural = xDialog.getChild("naturalsort") + xNatural.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + + 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") + + self.ui_test.close_doc() + + def test_natural_sorting_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xleftright.executeAction("CLICK", tuple()) + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + + #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") + + self.ui_test.close_doc() +# 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 000000000000..4b56ceea7c5b --- /dev/null +++ b/sc/qa/uitest/sort/sorting.py @@ -0,0 +1,303 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +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): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #Verify that option "Range contains column labels" is set + xHeader = xDialog.getChild("header") + self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true") + #Cancel dialog + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + #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") + self.ui_test.close_doc() + + def test_Sortingbuttons_list_has_not_columnheaders(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #Verify that option "Range contains column labels" is not set + xHeader = xDialog.getChild("header") + self.assertEqual(get_state_as_dict(xHeader)["Selected"], "false") + #Cancel dialog + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + self.ui_test.close_doc() + + def test_Sorting_default_to_selected_column(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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") + + self.ui_test.close_doc() + + def test_Sorting_default_to_selected_TAB_A_column(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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) + + self.ui_test.close_doc() + + def test_Sorting_default_to_selected_TAB_B_column(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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") + + self.ui_test.close_doc() + + def test_Sorting_sort_criteria(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + 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 + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + 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 + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + 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 + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + 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 + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/sort/stableSorting.py b/sc/qa/uitest/sort/stableSorting.py new file mode 100644 index 000000000000..269bd5252f2b --- /dev/null +++ b/sc/qa/uitest/sort/stableSorting.py @@ -0,0 +1,100 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +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): + 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 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(document, 0, 5, i).getValue(), i) + self.ui_test.close_doc() + + def test_Must_keep_sort_order_previous_sorting_toolbar_button_Descending(self): + 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 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(document, 0, 5, i).getValue(), j) + self.ui_test.close_doc() + + # 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 000000000000..3a48cd21335a --- /dev/null +++ b/sc/qa/uitest/sort/subtotals.py @@ -0,0 +1,189 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from libreoffice.calc.document import get_column +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class Subtotals(UITestCase): + + def test_tdf114720(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + 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"})) + + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + 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 + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + + def test_tdf88792(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf88792.ods")) + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + 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 + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + # Select group by: Category + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "Category"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # 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 + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.assertEqual(get_cell_by_position(document, 0, 3, 5).getValue(), 28000) + self.ui_test.close_doc() + + def test_tdf88735(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf88735.ods")) + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = XcalcDoc.getChild("grid_window") + # 1 select all cells + self.xUITest.executeCommand(".uno:SelectAll")#use uno command Menu Edit->Select All + # 2 invoke sub-total menu and select none + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "- none -"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + # 2 invoke sort menu and... crash + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "z") + self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 8) + self.ui_test.close_doc() + + def test_tdf56958(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf56958.ods")) + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = XcalcDoc.getChild("grid_window") + # 1. Open the test file + # 2. Data->Subtotals + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + # 3. Group by->Trans date + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "Trans Date"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # 4. Tick 'Calculate subtotals for' -> Amount (grid1) + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns") + xFirstEntry = xTreeList.getChild("2") + xFirstEntry.executeAction("CLICK", tuple()) + # 5. Click OK + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + # 6. Data->Subtotals + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + # 7. Group by->-none- + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "- none -"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # 8. Untick 'Calculate subtotals for' -> Amount + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns") + xFirstEntry = xTreeList.getChild("2") + xFirstEntry.executeAction("CLICK", tuple()) + # 9. Click OK + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + # 10. Data->Sort + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + # 11. Sort key 1->Post Date. + sortkey1 = xDialog.getChild("sortlb") + props = {"TEXT": "Post Date"} + actionProps = mkPropertyValues(props) + sortkey1.executeAction("SELECT", actionProps) + # 12. Sort key 2->-undefined- + sortkey2 = xDialog.getChild("sortuserlb") + props = {"TEXT": "- undefined -"} + actionProps = mkPropertyValues(props) + sortkey2.executeAction("SELECT", actionProps) + # 13. Click OK + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), -0.25) + self.ui_test.close_doc() + + def test_tdf55734(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf55734.ods")) + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + 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 + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + # 4. Group by: "- none -" + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "- none -"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # 5. Press "OK" and watch LibreOffice crash. + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 2) + self.ui_test.close_doc() + +# 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 000000000000..95e2533849f0 --- /dev/null +++ b/sc/qa/uitest/sort/tdf53482.py @@ -0,0 +1,92 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.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): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf53482.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #1. Highlight cells to be sorted A8:J124 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:J124"})) + #2. Click Data menu, Sort + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #3. On Options tab, tick 'Range contains column labels' + xHeader = xDialog.getChild("header") + 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") + props = {"TEXT": "Occupation"} + actionProps = mkPropertyValues(props) + xSortKey1.executeAction("SELECT", actionProps) + #5. Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #6. Expected behavior: Ignore column labels when sorting + self.assertEqual(get_cell_by_position(document, 0, 6, 7).getString(), "Occupation") + self.assertEqual(get_cell_by_position(document, 0, 6, 8).getString(), "Travel Industry") + self.assertEqual(get_cell_by_position(document, 0, 6, 123).getString(), "13") + + self.ui_test.close_doc() + + def test_tdf53482_Range_contains_column_headings(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #3. On Options tab, tick 'Range contains column labels' + xHeader = xDialog.getChild("header") + 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()) + #5. Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #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") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/sort/tdf54018.py b/sc/qa/uitest/sort/tdf54018.py new file mode 100644 index 000000000000..ea9fc2994e2e --- /dev/null +++ b/sc/qa/uitest/sort/tdf54018.py @@ -0,0 +1,50 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 54018 - EDITING: CRASH sorting cells range with Comments + +class tdf54018(UITestCase): + def test_td54018_sort_with_comments(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf54018.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #click top left columns / rows heading field to select all cells + self.xUITest.executeCommand(".uno:SelectAll") + #Menu 'Data -> Sort -> Column D -> Descending' + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xSortKey1 = xDialog.getChild("sortlb") + xdown = xDialog.getChild("down") + props = {"TEXT": "Column B"} + actionProps = mkPropertyValues(props) + xSortKey1.executeAction("SELECT", actionProps) + xdown.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Bug: When progress bar reaches 40% LibO Stops responding + #Verify + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "7") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "6") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "5") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "4") + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "3") + self.assertEqual(get_cell_by_position(document, 0, 1, 5).getString(), "2") + self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "1") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/sort/tdf91305.py b/sc/qa/uitest/sort/tdf91305.py new file mode 100644 index 000000000000..eae7e8c4555e --- /dev/null +++ b/sc/qa/uitest/sort/tdf91305.py @@ -0,0 +1,140 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +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_rows(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter texts + enter_text_to_cell(gridwin, "A1", "cc") + enter_text_to_cell(gridwin, "A2", "ff") + enter_text_to_cell(gridwin, "A3", "aa") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + #Press toolbarbutton for ascending sorting .uno:SortAsc + self.xUITest.executeCommand(".uno:SortAscending") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).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") + + def test_tdf91305_sort_text_cells_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + select_pos(xTabs, "1") + xleftright.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + xdown = xDialog.getChild("down") + select_pos(xTabs, "1") + xleftright.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xdown.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + 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") + self.ui_test.close_doc() + + #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. + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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") + + self.ui_test.close_doc() + + #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): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/sort/tdf95192.py b/sc/qa/uitest/sort/tdf95192.py new file mode 100644 index 000000000000..be310f6a4eb1 --- /dev/null +++ b/sc/qa/uitest/sort/tdf95192.py @@ -0,0 +1,47 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc import enter_text_to_cell +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): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf95192.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xNatural.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Sal. Capra 1/17") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Sal. Capra 1/20") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "Sal. Oregina 1/2") + self.assertEqual(get_cell_by_position(document, 0, 0, 41).getString(), "Vico Chiuso Cinque Santi 18/10") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Sal. Oregina 1/2") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Via A. Centurione 11/7") + self.assertEqual(get_cell_by_position(document, 0, 0, 41).getString(), "Vico Chiuso Cinque Santi 18/10") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/sort/tdf99208.py b/sc/qa/uitest/sort/tdf99208.py new file mode 100644 index 000000000000..f590b9f2063e --- /dev/null +++ b/sc/qa/uitest/sort/tdf99208.py @@ -0,0 +1,65 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc import enter_text_to_cell +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): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf99208.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select A3:C245 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C245"})) + + #Menu 'Data -> Sort + #Column A - Ascending' + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xtopdown = xDialog.getChild("topdown") + xHeader = xDialog.getChild("header") + xFormats = xDialog.getChild("formats") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + if (get_state_as_dict(xFormats)["Selected"]) == "false": + xFormats.executeAction("CLICK", tuple()) + xtopdown.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + props = {"TEXT": "FODMAP"} + actionProps = mkPropertyValues(props) + xSortKey1.executeAction("SELECT", actionProps) + xAsc.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #Verify Expected: Values column B sorted ascending, column "control" unsorted + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "FODMAP") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "agave") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "almond milk") + self.assertEqual(get_cell_by_position(document, 0, 0, 244).getString(), "zucchini") + # UNDO + self.xUITest.executeCommand(".uno:Undo") + # Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "FODMAP") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "beef (grass fed, no breadcrumbs)") + self.assertEqual(get_cell_by_position(document, 0, 0, 244).getString(), "salsa") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/sort/tdf99627.py b/sc/qa/uitest/sort/tdf99627.py new file mode 100644 index 000000000000..d5071adeae79 --- /dev/null +++ b/sc/qa/uitest/sort/tdf99627.py @@ -0,0 +1,48 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc import enter_text_to_cell +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): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf99627.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + 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()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "2998") + self.assertEqual(get_cell_by_position(document, 0, 0, 2998).getString(), "1") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 2998).getString(), "2998") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file diff --git a/sc/qa/uitest/sort/tdf99773.py b/sc/qa/uitest/sort/tdf99773.py new file mode 100644 index 000000000000..099788fa1428 --- /dev/null +++ b/sc/qa/uitest/sort/tdf99773.py @@ -0,0 +1,52 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +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): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #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 + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #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") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: -- cgit