summaryrefslogtreecommitdiff
path: root/sc/qa/uitest
diff options
context:
space:
mode:
authorKevin Suo <suokunlong@126.com>2024-01-16 10:13:59 +0800
committerKevin Suo <suokunlong@126.com>2024-01-18 13:08:22 +0100
commit89e032e9c4c51f52680c7d8bacf59ab2a34f2180 (patch)
tree1616d789157eda4b1e156f4084d9edffeaa8670d /sc/qa/uitest
parentab7893544dc6be6dc192dffefd57cd5ddd421c35 (diff)
tdf#158314: show Empty and Error entries as non-selected and inactive...
...when hidden by autofilter. The "show hidden filter elements as inactive" feature was added and improved by: commit 2d1df9f3dccc10f13b8585ad18afce1542ebc4d1 (tdf#117276 sc: Show hidden filter elements as inactive elements) commit 2085e90fe8ac129bc4dbac4612d1ea7544335dae (FilteredRow is not a property of the column, tdf#117276 follow-up) commit 7321db3cadc8c0e4437ca04e5dcb652734ea9c26 (Related tdf#117276 sc: Show hidden filter elements as inactive elements) commit 19533948370dc1ccd7334dbe1a8b7fc8330b10c0 (Name FilteredRow what it is, not hidden; tdf#117276 follow-up) Those changes correctly made normal hidden filter elements as inactive, but failed to do so for Empty and Error entries. This patch shows the hidden Empty and Error entries as inactive and unselected. Also, do not show the Empty entry at the top of the list in case it is inactive. Change-Id: Ibcd758cebc0692b04b162cdfc3e06eceb86b17da Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162166 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Kevin Suo <suokunlong@126.com> Tested-by: Kevin Suo <suokunlong@126.com>
Diffstat (limited to 'sc/qa/uitest')
-rw-r--r--sc/qa/uitest/autofilter2/tdf158314_EmptyError.py94
1 files changed, 94 insertions, 0 deletions
diff --git a/sc/qa/uitest/autofilter2/tdf158314_EmptyError.py b/sc/qa/uitest/autofilter2/tdf158314_EmptyError.py
new file mode 100644
index 000000000000..2ced88c80db3
--- /dev/null
+++ b/sc/qa/uitest/autofilter2/tdf158314_EmptyError.py
@@ -0,0 +1,94 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.calc import enter_text_to_cell
+from uitest.uihelper.common import get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from libreoffice.calc.document import is_row_hidden
+
+# Bug 158314 - Autofilter dropdown list always shows "Empty" entry as active
+
+class tdf158314_EmptyEntries(UITestCase):
+ def testTdf158314(self):
+ with self.ui_test.create_doc_in_start_center("calc") as calcDoc:
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWin = xCalcDoc.getChild("grid_window")
+
+ # Fill the sheet with test data
+ enter_text_to_cell(xGridWin, "A1", "a")
+ enter_text_to_cell(xGridWin, "A2", "1")
+ enter_text_to_cell(xGridWin, "A3", "2")
+ enter_text_to_cell(xGridWin, "A4", "3")
+ enter_text_to_cell(xGridWin, "A5", "4")
+
+ enter_text_to_cell(xGridWin, "B1", "b")
+ enter_text_to_cell(xGridWin, "B2", "5")
+ enter_text_to_cell(xGridWin, "B3", "")
+ enter_text_to_cell(xGridWin, "B4", "=1/0")
+ enter_text_to_cell(xGridWin, "B5", "8")
+
+ # Select the data range and set autofilter
+ xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"}))
+ self.xUITest.executeCommand(".uno:DataFilterAutoFilter")
+
+ # Click the autofilter dropdown in column A
+ xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
+ xFloatWindow = self.xUITest.getFloatWindow()
+ xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
+ xTreeList = xCheckListMenu.getChild("check_list_box")
+
+ # Select the first entry only. Uncheck all other entries.
+ for i in xTreeList.getChildren():
+ if i != "0":
+ xEntry = xTreeList.getChild(i)
+ xEntry.executeAction("CLICK", tuple())
+
+ xOkButton = xFloatWindow.getChild("ok")
+ xOkButton.executeAction("CLICK", tuple())
+
+ # Check that only row#2 is visible
+ self.assertFalse(is_row_hidden(calcDoc, 1))
+ self.assertTrue(is_row_hidden(calcDoc, 2))
+ self.assertTrue(is_row_hidden(calcDoc, 3))
+ self.assertTrue(is_row_hidden(calcDoc, 4))
+
+ # Click the autofilter dropdown in column B
+ xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"}))
+ xFloatWindow = self.xUITest.getFloatWindow()
+ xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
+ xTreeList = xCheckListMenu.getChild("check_list_box")
+
+ # There should be at least one entry in the dropdown
+ # (i.e., the feature of showing inactive autofilter entries may be disabled)
+ self.assertEqual(True, len(xTreeList.getChildren()) >= 1)
+
+ for i in xTreeList.getChildren():
+ state = get_state_as_dict(xTreeList.getChild(i))
+ # The Text of the first element should be '5' and it should be checked and active
+ if i == "0":
+ self.assertEqual("5", state["Text"])
+ self.assertEqual("true", state["IsChecked"])
+ self.assertEqual("true", state["IsSelected"])
+ self.assertEqual("false", state["IsSemiTransparent"])
+ # All other elements (including the Empty and #DIV/0!) should be unchecked and inactive
+ else:
+ self.assertEqual("false", state["IsChecked"])
+ self.assertEqual("false", state["IsSelected"])
+ self.assertEqual("true", state["IsSemiTransparent"])
+
+ # Close the popup window
+ xOkButton = xFloatWindow.getChild("ok")
+ xOkButton.executeAction("CLICK", tuple())
+
+ # Check again that only row#2 is visible
+ self.assertFalse(is_row_hidden(calcDoc, 1))
+ self.assertTrue(is_row_hidden(calcDoc, 2))
+ self.assertTrue(is_row_hidden(calcDoc, 3))
+ self.assertTrue(is_row_hidden(calcDoc, 4))
+# vim: set shiftwidth=4 softtabstop=4 expandtab: