sc/qa/uitest/autofilter/tdf92767.py | 58 ++++++++++++++++++++++++++++++ sc/qa/uitest/data/autofilter/tdf92767.ods |binary uitest/uitest/uihelper/common.py | 5 ++ vcl/source/treelist/uiobject.cxx | 4 ++ 4 files changed, 67 insertions(+)
New commits: commit 91d856847d6cd149757e99935779487e13c2558a Author: Xisco Fauli <[email protected]> AuthorDate: Tue Feb 2 19:55:19 2021 +0100 Commit: Gabor Kelemen <[email protected]> CommitDate: Thu Aug 19 19:15:11 2021 +0200 tdf#92767: sc: Add UItest Change-Id: I9f1d82d81364ee0ee833b4505e6925cce5e3e787 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110332 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> (cherry picked from commit 14d064cee7b76e8a2a2201d4da423336f68fe624) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120718 Tested-by: Gabor Kelemen <[email protected]> Reviewed-by: Gabor Kelemen <[email protected]> diff --git a/sc/qa/uitest/autofilter/tdf92767.py b/sc/qa/uitest/autofilter/tdf92767.py new file mode 100644 index 000000000000..859620b73a8a --- /dev/null +++ b/sc/qa/uitest/autofilter/tdf92767.py @@ -0,0 +1,58 @@ +# -*- 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 libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_row +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +def is_row_hidden(doc, index): + row = get_row(doc, index) + val = row.getPropertyValue("IsVisible") + return not val + +class tdf92767(UITestCase): + + def test_tdf92767(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf92767.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + for i in range(0,25): + self.assertFalse(is_row_hidden(calc_doc, i)) + + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xTreeList = xFloatWindow.getChild("check_tree_box") + xFirstEntry = xTreeList.getChild("0") + self.assertEqual('2015', get_state_as_dict(xFirstEntry)["Text"]) + self.assertEqual('7', get_state_as_dict(xFirstEntry)["Children"]) + + # Deselect all the options but the last one + for i in range(6): + xChild = xFirstEntry.getChild(str(i)) + xChild.executeAction("CLICK", tuple()) + self.assertEqual('false', get_state_as_dict(xChild)['IsChecked']) + + xLastChild = xFirstEntry.getChild('6') + self.assertEqual('true', get_state_as_dict(xLastChild)['IsChecked']) + self.assertEqual('July', get_state_as_dict(xLastChild)['Text']) + + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + for i in range(1,22): + self.assertTrue(is_row_hidden(calc_doc, i)) + + # Without the fix in place, this test would have failed here + self.assertFalse(is_row_hidden(calc_doc, 23)) + self.assertFalse(is_row_hidden(calc_doc, 24)) + self.assertFalse(is_row_hidden(calc_doc, 25)) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/autofilter/tdf92767.ods b/sc/qa/uitest/data/autofilter/tdf92767.ods new file mode 100644 index 000000000000..34dfb002e2d0 Binary files /dev/null and b/sc/qa/uitest/data/autofilter/tdf92767.ods differ diff --git a/uitest/uitest/uihelper/common.py b/uitest/uitest/uihelper/common.py index cf3a277aa15b..972452d6de07 100644 --- a/uitest/uitest/uihelper/common.py +++ b/uitest/uitest/uihelper/common.py @@ -6,6 +6,8 @@ # from libreoffice.uno.propertyvalue import convert_property_values_to_dict, mkPropertyValues +import org.libreoffice.unotest +import pathlib def get_state_as_dict(ui_object): return convert_property_values_to_dict(ui_object.getState()) @@ -19,6 +21,9 @@ def select_pos(ui_object, pos): def select_text(ui_object, from_pos, to): ui_object.executeAction("SELECT", mkPropertyValues({"FROM": from_pos, "TO": to})) +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + def change_measurement_unit(UITestCase, unit): UITestCase.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") xDialogOpt = UITestCase.xUITest.getTopFocusWindow() diff --git a/vcl/source/treelist/uiobject.cxx b/vcl/source/treelist/uiobject.cxx index e7fb516b5d21..0caea7163f76 100644 --- a/vcl/source/treelist/uiobject.cxx +++ b/vcl/source/treelist/uiobject.cxx @@ -108,6 +108,10 @@ StringMap TreeListEntryUIObject::get_state() aMap["VisibleChildCount"] = OUString::number(mxTreeList->GetVisibleChildCount(mpEntry)); aMap["IsSelected"] = OUString::boolean(mxTreeList->IsSelected(mpEntry)); + SvLBoxButton* pItem = static_cast<SvLBoxButton*>(mpEntry->GetFirstItem(SvLBoxItemType::Button)); + if (pItem) + aMap["IsChecked"] = OUString::boolean(pItem->IsStateChecked()); + return aMap; }
