1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 from uitest
.framework
import UITestCase
10 from uitest
.uihelper
.calc
import enter_text_to_cell
11 from uitest
.uihelper
.common
import select_by_text
12 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
13 from libreoffice
.calc
.document
import get_row
14 from uitest
.uihelper
.common
import get_state_as_dict
16 #Bug 141559 - Add Clear Standard Filter to Autofilter widget
18 class tdf141559(UITestCase
):
19 def test_tdf141559_clear_filter(self
):
20 with self
.ui_test
.create_doc_in_start_center("calc") as document
:
21 calcDoc
= self
.xUITest
.getTopFocusWindow()
22 gridwin
= calcDoc
.getChild("grid_window")
24 enter_text_to_cell(gridwin
, "A1", "A")
25 enter_text_to_cell(gridwin
, "A2", "1")
26 enter_text_to_cell(gridwin
, "A3", "2")
27 enter_text_to_cell(gridwin
, "A4", "3")
29 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"}))
31 self
.xUITest
.executeCommand(".uno:DataFilterAutoFilter")
33 gridwin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
34 xFloatWindow
= self
.xUITest
.getFloatWindow()
35 #Choose Standard Filter... button
36 xMenu
= xFloatWindow
.getChild("menu")
38 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
39 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
40 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
41 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
42 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
43 xSubFloatWindow
= self
.xUITest
.getFloatWindow()
44 xSubMenu
= xSubFloatWindow
.getChild("menu")
46 nLastIdx
= int(get_state_as_dict(xSubMenu
)['Children']) - 1
47 self
.assertEqual(5, nLastIdx
)
49 # check last item: 'Standard Filter...' (new menu item 'Clear Filter' is optional)
50 self
.assertEqual('Standard Filter...', get_state_as_dict(xSubMenu
.getChild(str(nLastIdx
)))['Text'])
52 xSubMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
53 xSubMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
54 xSubMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
55 xSubMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
56 self
.assertEqual("Standard Filter...", get_state_as_dict(xSubMenu
)['SelectEntryText'])
57 xSubMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
59 xDialog
= self
.xUITest
.getTopFocusWindow()
60 xfield1
= xDialog
.getChild("field1")
61 xcond1
= xDialog
.getChild("cond1")
62 xval1
= xDialog
.getChild("val1")
64 select_by_text(xfield1
, "A")
65 select_by_text(xcond1
, ">")
66 xval1
.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
67 xOKBtn
= xDialog
.getChild("ok")
68 self
.ui_test
.close_dialog_through_button(xOKBtn
)
70 row
= get_row(document
, 1)
71 self
.assertFalse(row
.getPropertyValue("IsVisible"))
73 gridwin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
74 xFloatWindow
= self
.xUITest
.getFloatWindow()
75 #Choose Clear Filter button
76 xMenu
= xFloatWindow
.getChild("menu")
78 # check last item: 'Clear Filter'
79 nLastIdx
= int(get_state_as_dict(xMenu
)['Children']) - 1
80 self
.assertEqual(6, nLastIdx
)
81 self
.assertEqual('Clear Filter', get_state_as_dict(xMenu
.getChild(str(nLastIdx
)))['Text'])
83 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
84 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
85 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
86 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
87 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
88 # Use new menu item "Clear Filter" to remove the standard filter condition
89 self
.assertEqual("Clear Filter", get_state_as_dict(xMenu
)['SelectEntryText'])
90 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
92 self
.assertTrue(row
.getPropertyValue("IsVisible"))
95 # vim: set shiftwidth=4 softtabstop=4 expandtab: