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 libreoffice
.uno
.propertyvalue
import mkPropertyValues
11 from libreoffice
.calc
.document
import is_row_hidden
12 from uitest
.uihelper
.common
import get_url_for_data_file
14 #Bug 117276 - Autofilter settings being reset in some cases
16 class tdf117276(UITestCase
):
17 def test_tdf117276_autofilter(self
):
18 with self
.ui_test
.load_file(get_url_for_data_file("tdf117276.ods")) as calc_doc
:
19 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
20 gridwin
= xCalcDoc
.getChild("grid_window")
21 # 1. open attached file
22 # 2. open filter of column B (Fabrikat) and deselect (Citroen, Fiat, Ford, Opel, Peugeot, Renault, Tesla)
23 gridwin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"}))
24 xFloatWindow
= self
.xUITest
.getFloatWindow()
25 xCheckListMenu
= xFloatWindow
.getChild("FilterDropDown")
26 xTreeList
= xCheckListMenu
.getChild("check_list_box")
28 xCitroenEntry
= xTreeList
.getChild("2")
29 xCitroenEntry
.executeAction("CLICK", tuple()) #Citroen
30 xFiatEntry
= xTreeList
.getChild("3")
31 xFiatEntry
.executeAction("CLICK", tuple()) #Fiat
32 xFordEntry
= xTreeList
.getChild("4")
33 xFordEntry
.executeAction("CLICK", tuple()) #Ford
34 xOpelEntry
= xTreeList
.getChild("6")
35 xOpelEntry
.executeAction("CLICK", tuple()) #Opel
36 xPeugeotEntry
= xTreeList
.getChild("7")
37 xPeugeotEntry
.executeAction("CLICK", tuple()) #Peugeot
38 xRenaultEntry
= xTreeList
.getChild("9")
39 xRenaultEntry
.executeAction("CLICK", tuple()) #Renault
40 xTeslaEntry
= xTreeList
.getChild("10")
41 xTeslaEntry
.executeAction("CLICK", tuple()) #Tesla
43 xOkBtn
= xFloatWindow
.getChild("ok")
44 xOkBtn
.executeAction("CLICK", tuple())
46 self
.assertFalse(is_row_hidden(calc_doc
, 0))
47 self
.assertFalse(is_row_hidden(calc_doc
, 1))
48 self
.assertTrue(is_row_hidden(calc_doc
, 3))
50 # 3. open filter of column I (Wert) and deselect 8000 (Values 7000 and 9000 are not shown)
51 gridwin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "8", "ROW": "0"}))
52 xFloatWindow
= self
.xUITest
.getFloatWindow()
53 xCheckListMenu
= xFloatWindow
.getChild("FilterDropDown")
54 xTreeList
= xCheckListMenu
.getChild("check_list_box")
56 xCitroenEntry
= xTreeList
.getChild("0")
57 xCitroenEntry
.executeAction("CLICK", tuple())
59 xOkBtn
= xFloatWindow
.getChild("ok")
60 xOkBtn
.executeAction("CLICK", tuple())
62 self
.assertFalse(is_row_hidden(calc_doc
, 0))
63 self
.assertFalse(is_row_hidden(calc_doc
, 1))
64 self
.assertTrue(is_row_hidden(calc_doc
, 9))
66 # 4. open filter of column B and select Tesla
67 gridwin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"}))
68 xFloatWindow
= self
.xUITest
.getFloatWindow()
69 xCheckListMenu
= xFloatWindow
.getChild("FilterDropDown")
70 xTreeList
= xCheckListMenu
.getChild("check_list_box")
71 xTeslaEntry
= xTreeList
.getChild("4")
72 xTeslaEntry
.executeAction("CLICK", tuple()) #Tesla
74 xOkBtn
= xFloatWindow
.getChild("ok")
75 xOkBtn
.executeAction("CLICK", tuple())
76 self
.assertFalse(is_row_hidden(calc_doc
, 0))
77 self
.assertFalse(is_row_hidden(calc_doc
, 1))
78 self
.assertFalse(is_row_hidden(calc_doc
, 21))
80 # 5. open filter of column I and select 7000 --> 8000 because:new strategy of the filter is implemented
81 #(which strings to show and which to hide, when multiple filters are in used).
82 gridwin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "8", "ROW": "0"}))
83 xFloatWindow
= self
.xUITest
.getFloatWindow()
84 xCheckListMenu
= xFloatWindow
.getChild("FilterDropDown")
85 xTreeList
= xCheckListMenu
.getChild("check_list_box")
87 x8000Entry
= xTreeList
.getChild("1") # check "8000"
88 x8000Entry
.executeAction("CLICK", tuple())
90 xOkBtn
= xFloatWindow
.getChild("ok")
91 xOkBtn
.executeAction("CLICK", tuple())
93 self
.assertFalse(is_row_hidden(calc_doc
, 0))
94 self
.assertFalse(is_row_hidden(calc_doc
, 1))
95 self
.assertFalse(is_row_hidden(calc_doc
, 7))
97 # vim: set shiftwidth=4 softtabstop=4 expandtab: