sc/qa/uitest/autofilter/data/tdf117276.ods |binary sc/qa/uitest/autofilter/data/tdf122260.ods |binary sc/qa/uitest/autofilter/tdf117276.py | 115 +++++++++++++++++++++++++++++ sc/qa/uitest/autofilter/tdf122260.py | 102 +++++++++++++++++++++++++ sc/source/ui/view/gridwin.cxx | 1 5 files changed, 218 insertions(+)
New commits: commit 275c3bc2f2a7c26338ae37d57d59d54beebe539c Author: Zdeněk Crhonek <zcrho...@gmail.com> AuthorDate: Fri Dec 21 18:17:07 2018 +0100 Commit: Thorsten Behrens <thorsten.behr...@cib.de> CommitDate: Sun Feb 3 20:09:31 2019 +0100 tdf#122260 sc: Autofilters not properly cleared incl. uitest for bug tdf#117276 Change-Id: Ib61eee95d7ed4e6ede9455b058406eccd140e31c Reviewed-on: https://gerrit.libreoffice.org/65555 Tested-by: Jenkins Reviewed-by: Zdenek Crhonek <zcrho...@gmail.com> tdf#122260 sc: Autofilters not properly cleared Change-Id: I301b9ae8640e93b1ecf9e6818c9792ce45993cba Reviewed-on: https://gerrit.libreoffice.org/67001 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Reviewed-on: https://gerrit.libreoffice.org/67304 Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sc/qa/uitest/autofilter/data/tdf117276.ods b/sc/qa/uitest/autofilter/data/tdf117276.ods new file mode 100644 index 000000000000..d1310526e727 Binary files /dev/null and b/sc/qa/uitest/autofilter/data/tdf117276.ods differ diff --git a/sc/qa/uitest/autofilter/data/tdf122260.ods b/sc/qa/uitest/autofilter/data/tdf122260.ods new file mode 100644 index 000000000000..00c86d00a398 Binary files /dev/null and b/sc/qa/uitest/autofilter/data/tdf122260.ods differ diff --git a/sc/qa/uitest/autofilter/tdf117276.py b/sc/qa/uitest/autofilter/tdf117276.py new file mode 100644 index 000000000000..acd7d11899b5 --- /dev/null +++ b/sc/qa/uitest/autofilter/tdf117276.py @@ -0,0 +1,115 @@ +# -*- 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 +from libreoffice.calc.document import get_row +# import org.libreoffice.unotest +# import pathlib +from uitest.path import get_srcdir_url + +def get_url_for_data_file(file_name): +# return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + return get_srcdir_url() + "/sc/qa/uitest/autofilter/data/" + file_name + +def is_row_hidden(doc, index): + row = get_row(doc, index) + val = row.getPropertyValue("IsVisible") + return not val + +#Bug 117276 - Autofilter settings being reset in some cases + +class tdf117276(UITestCase): + def test_tdf117276_autofilter(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf117276.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + # 1. open attached file + # 2. open filter of column B (Fabrikat) and deselect (Citroen, Fiat, Ford, Opel, Peugeot, Renault, Tesla) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xTreeList = xCheckListMenu.getChild("check_list_box") + + xCitroenEntry = xTreeList.getChild("2") + xCitroenEntry.executeAction("CLICK", tuple()) #Citroen + xFiatEntry = xTreeList.getChild("3") + xFiatEntry.executeAction("CLICK", tuple()) #Fiat + xFordEntry = xTreeList.getChild("4") + xFordEntry.executeAction("CLICK", tuple()) #Ford + xOpelEntry = xTreeList.getChild("6") + xOpelEntry.executeAction("CLICK", tuple()) #Opel + xPeugeotEntry = xTreeList.getChild("7") + xPeugeotEntry.executeAction("CLICK", tuple()) #Peugeot + xRenaultEntry = xTreeList.getChild("9") + xRenaultEntry.executeAction("CLICK", tuple()) #Renault + xTeslaEntry = xTreeList.getChild("10") + xTeslaEntry.executeAction("CLICK", tuple()) #Tesla + + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + self.assertFalse(is_row_hidden(calc_doc, 0)) + self.assertFalse(is_row_hidden(calc_doc, 1)) + self.assertTrue(is_row_hidden(calc_doc, 3)) + + # 3. open filter of column I (Wert) and deselect 8000 (Values 7000 and 9000 are not shown) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "8", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xTreeList = xCheckListMenu.getChild("check_list_box") + + xCitroenEntry = xTreeList.getChild("0") + xCitroenEntry.executeAction("CLICK", tuple()) + + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + self.assertFalse(is_row_hidden(calc_doc, 0)) + self.assertFalse(is_row_hidden(calc_doc, 1)) + self.assertTrue(is_row_hidden(calc_doc, 9)) + + # 4. open filter of column B and select Tesla + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xTreeList = xCheckListMenu.getChild("check_list_box") + xTeslaEntry = xTreeList.getChild("4") + xTeslaEntry.executeAction("CLICK", tuple()) #Tesla + + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + self.assertFalse(is_row_hidden(calc_doc, 0)) + self.assertFalse(is_row_hidden(calc_doc, 1)) + self.assertFalse(is_row_hidden(calc_doc, 21)) + + # 5. open filter of column I and select 7000 --> 8000 because:new strategy of the filter is implemented + #(which strings to show and which to hide, when multiple filters are in used). + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "8", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xTreeList = xCheckListMenu.getChild("check_list_box") + + x8000Entry = xTreeList.getChild("1") # check "8000" + x8000Entry.executeAction("CLICK", tuple()) + + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + self.assertFalse(is_row_hidden(calc_doc, 0)) + self.assertFalse(is_row_hidden(calc_doc, 1)) + self.assertFalse(is_row_hidden(calc_doc, 7)) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/autofilter/tdf122260.py b/sc/qa/uitest/autofilter/tdf122260.py new file mode 100644 index 000000000000..7d9df8564ab7 --- /dev/null +++ b/sc/qa/uitest/autofilter/tdf122260.py @@ -0,0 +1,102 @@ +# -*- 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 libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_row + + +from uitest.path import get_srcdir_url +def get_url_for_data_file(file_name): + return get_srcdir_url() + "/sc/qa/uitest/autofilter/data/" + file_name + +def is_row_hidden(doc, index): + row = get_row(doc, index) + val = row.getPropertyValue("IsVisible") + return not val + +#Bug 122260 - EDITING Autofilters not properly cleared +class tdf122260(UITestCase): + def check_value_in_AutoFilter(self, gridwin, columnIndex, valueIndex): + # open filter pop-up window + self.assertIsNotNone(gridwin) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": columnIndex, "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + self.assertIsNotNone(xFloatWindow) + + # get check list + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + self.assertIsNotNone(xCheckListMenu) + + xTreeList = xCheckListMenu.getChild("check_list_box") + self.assertIsNotNone(xTreeList) + + # on/off required checkbox + xEntry = xTreeList.getChild(valueIndex) + self.assertIsNotNone(xEntry) + xEntry.executeAction("CLICK", tuple()) + + # close pop-up window + xOkBtn = xFloatWindow.getChild("ok") + self.assertIsNotNone(xOkBtn) + xOkBtn.executeAction("CLICK", tuple()) + + def get_values_count_in_AutoFilter(self, gridwin, columnIndex): + # open filter pop-up window + self.assertIsNotNone(gridwin) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": columnIndex, "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + self.assertIsNotNone(xFloatWindow) + + # get check list + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + self.assertIsNotNone(xCheckListMenu) + + xTreeList = xCheckListMenu.getChild("check_list_box") + self.assertIsNotNone(xTreeList) + + valuesCount = len(xTreeList.getChildren()) + + # close pop-up window + xOkBtn = xFloatWindow.getChild("ok") + self.assertIsNotNone(xOkBtn) + xOkBtn.executeAction("CLICK", tuple()) + + return valuesCount + + def test_tdf122260_autofilter(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf122260.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + self.assertIsNotNone(gridwin) + + # filter out b1 + self.check_value_in_AutoFilter(gridwin, "1", "0") + # filter out a2 (as a1 is filtered out a2 is the first item) + self.check_value_in_AutoFilter(gridwin, "0", "0") + # return back a2 (as a1 is filtered out a2 is the first item) + self.check_value_in_AutoFilter(gridwin, "0", "0") + + # check rows visibility + # row-0 is row with headers + self.assertTrue(is_row_hidden(calc_doc, 1)) + self.assertFalse(is_row_hidden(calc_doc, 2)) + self.assertFalse(is_row_hidden(calc_doc, 3)) + self.assertFalse(is_row_hidden(calc_doc, 4)) + + # check if "b1" is accessible in filter of the column-b + # (so all values of the column B are available) + self.assertEqual(4, self.get_values_count_in_AutoFilter(gridwin, "1")) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index b9a4afc12874..cc39d6118c3a 100755 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -846,6 +846,7 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode) // Remove old entries. aParam.RemoveEntryByField(rPos.Col()); + if( !(eMode == AutoFilterMode::Normal && mpAutoFilterPopup->isAllSelected() ) ) { // Try to use the existing entry for the column (if one exists). ScQueryEntry* pEntry = aParam.FindEntryByField(rPos.Col(), true); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits