1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from uitest
.framework
import UITestCase
8 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
9 from libreoffice
.calc
.document
import get_row
10 import org
.libreoffice
.unotest
13 def get_url_for_data_file(file_name
):
14 return pathlib
.Path(org
.libreoffice
.unotest
.makeCopyFromTDOC(file_name
)).as_uri()
16 def is_row_hidden(doc
, index
):
17 row
= get_row(doc
, index
)
18 val
= row
.getPropertyValue("IsVisible")
21 #Bug 122260 - EDITING Autofilters not properly cleared
22 class tdf122260(UITestCase
):
23 def check_value_in_AutoFilter(self
, gridwin
, columnIndex
, valueIndex
):
24 # open filter pop-up window
25 self
.assertIsNotNone(gridwin
)
26 gridwin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": columnIndex
, "ROW": "0"}))
27 xFloatWindow
= self
.xUITest
.getFloatWindow()
28 self
.assertIsNotNone(xFloatWindow
)
31 xCheckListMenu
= xFloatWindow
.getChild("check_list_menu")
32 self
.assertIsNotNone(xCheckListMenu
)
34 xTreeList
= xCheckListMenu
.getChild("check_list_box")
35 self
.assertIsNotNone(xTreeList
)
37 # on/off required checkbox
38 xEntry
= xTreeList
.getChild(valueIndex
)
39 self
.assertIsNotNone(xEntry
)
40 xEntry
.executeAction("CLICK", tuple())
43 xOkBtn
= xFloatWindow
.getChild("ok")
44 self
.assertIsNotNone(xOkBtn
)
45 xOkBtn
.executeAction("CLICK", tuple())
47 def get_values_count_in_AutoFilter(self
, gridwin
, columnIndex
):
48 # open filter pop-up window
49 self
.assertIsNotNone(gridwin
)
50 gridwin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": columnIndex
, "ROW": "0"}))
51 xFloatWindow
= self
.xUITest
.getFloatWindow()
52 self
.assertIsNotNone(xFloatWindow
)
55 xCheckListMenu
= xFloatWindow
.getChild("check_list_menu")
56 self
.assertIsNotNone(xCheckListMenu
)
58 xTreeList
= xCheckListMenu
.getChild("check_list_box")
59 self
.assertIsNotNone(xTreeList
)
61 valuesCount
= len(xTreeList
.getChildren())
64 xOkBtn
= xFloatWindow
.getChild("ok")
65 self
.assertIsNotNone(xOkBtn
)
66 xOkBtn
.executeAction("CLICK", tuple())
70 def test_tdf122260_autofilter(self
):
71 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("tdf122260.ods"))
72 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
73 gridwin
= xCalcDoc
.getChild("grid_window")
74 self
.assertIsNotNone(gridwin
)
77 self
.check_value_in_AutoFilter(gridwin
, "1", "0")
78 # filter out a2 (as a1 is filtered out a2 is the first item)
79 self
.check_value_in_AutoFilter(gridwin
, "0", "0")
80 # return back a2 (as a1 is filtered out a2 is the first item)
81 self
.check_value_in_AutoFilter(gridwin
, "0", "0")
83 # check rows visibility
84 # row-0 is row with headers
85 self
.assertTrue(is_row_hidden(calc_doc
, 1))
86 self
.assertFalse(is_row_hidden(calc_doc
, 2))
87 self
.assertFalse(is_row_hidden(calc_doc
, 3))
88 self
.assertFalse(is_row_hidden(calc_doc
, 4))
90 # check if "b1" is accessible in filter of the column-b
91 # (so all values of the column B are available)
92 self
.assertEqual(4, self
.get_values_count_in_AutoFilter(gridwin
, "1"))
94 self
.ui_test
.close_doc()
96 # vim: set shiftwidth=4 softtabstop=4 expandtab: