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 get_state_as_dict
12 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
13 from libreoffice
.calc
.document
import is_row_hidden
15 class tdf159420(UITestCase
):
17 def testTdf159420(self
):
18 with self
.ui_test
.create_doc_in_start_center("calc") as calcDoc
:
19 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
20 xGridWin
= xCalcDoc
.getChild("grid_window")
22 # Fill the sheet with test data
23 enter_text_to_cell(xGridWin
, "A1", "a")
24 enter_text_to_cell(xGridWin
, "A2", "2")
25 enter_text_to_cell(xGridWin
, "A3", "2")
26 enter_text_to_cell(xGridWin
, "A4", "2")
27 enter_text_to_cell(xGridWin
, "A5", "4")
29 enter_text_to_cell(xGridWin
, "B1", "b")
30 enter_text_to_cell(xGridWin
, "B2", "")
31 enter_text_to_cell(xGridWin
, "B3", "")
32 enter_text_to_cell(xGridWin
, "B4", "8")
33 enter_text_to_cell(xGridWin
, "B5", "8")
35 enter_text_to_cell(xGridWin
, "C1", "c")
37 # Select the data range and set autofilter
38 xGridWin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C5"}))
39 self
.xUITest
.executeCommand(".uno:DataFilterAutoFilter")
41 # Click the autofilter dropdown in column A
42 xGridWin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
43 xFloatWindow
= self
.xUITest
.getFloatWindow()
44 xCheckListMenu
= xFloatWindow
.getChild("FilterDropDown")
45 xTreeList
= xCheckListMenu
.getChild("check_list_box")
47 self
.assertEqual(2, len(xTreeList
.getChildren()))
49 xEntry1
= xTreeList
.getChild(0)
50 self
.assertEqual("2", get_state_as_dict(xEntry1
)['Text'])
51 self
.assertEqual("true", get_state_as_dict(xEntry1
)['IsChecked'])
52 self
.assertEqual("false", get_state_as_dict(xEntry1
)['IsSemiTransparent'])
54 xEntry2
= xTreeList
.getChild(1)
55 self
.assertEqual("4", get_state_as_dict(xEntry2
)['Text'])
56 self
.assertEqual("true", get_state_as_dict(xEntry2
)['IsChecked'])
57 self
.assertEqual("false", get_state_as_dict(xEntry2
)['IsSemiTransparent'])
59 # Uncheck the second entry
60 xEntry2
.executeAction("CLICK", tuple())
62 xOkButton
= xFloatWindow
.getChild("ok")
63 xOkButton
.executeAction("CLICK", tuple())
65 # Check that only row#2 is visible
66 self
.assertFalse(is_row_hidden(calcDoc
, 1))
67 self
.assertFalse(is_row_hidden(calcDoc
, 2))
68 self
.assertFalse(is_row_hidden(calcDoc
, 3))
69 self
.assertTrue(is_row_hidden(calcDoc
, 4))
71 # Click the autofilter dropdown in column B
72 xGridWin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"}))
73 xFloatWindow
= self
.xUITest
.getFloatWindow()
74 xCheckListMenu
= xFloatWindow
.getChild("FilterDropDown")
75 xTreeList
= xCheckListMenu
.getChild("check_list_box")
77 self
.assertEqual(2, len(xTreeList
.getChildren()))
79 xEntry1
= xTreeList
.getChild(0)
80 self
.assertEqual("(empty)", get_state_as_dict(xEntry1
)['Text'])
81 self
.assertEqual("true", get_state_as_dict(xEntry1
)['IsChecked'])
82 self
.assertEqual("false", get_state_as_dict(xEntry1
)['IsSemiTransparent'])
84 xEntry2
= xTreeList
.getChild(1)
85 self
.assertEqual("8", get_state_as_dict(xEntry2
)['Text'])
86 self
.assertEqual("true", get_state_as_dict(xEntry2
)['IsChecked'])
87 self
.assertEqual("false", get_state_as_dict(xEntry2
)['IsSemiTransparent'])
89 # Uncheck the first entry
90 xEntry1
.executeAction("CLICK", tuple())
92 # Close the popup window
93 xOkButton
= xFloatWindow
.getChild("ok")
94 xOkButton
.executeAction("CLICK", tuple())
96 self
.assertTrue(is_row_hidden(calcDoc
, 1))
97 self
.assertTrue(is_row_hidden(calcDoc
, 2))
98 self
.assertFalse(is_row_hidden(calcDoc
, 3))
99 self
.assertTrue(is_row_hidden(calcDoc
, 4))
101 # Click the autofilter dropdown in column C
102 xGridWin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "2", "ROW": "0"}))
103 xFloatWindow
= self
.xUITest
.getFloatWindow()
104 xCheckListMenu
= xFloatWindow
.getChild("FilterDropDown")
105 xTreeList
= xCheckListMenu
.getChild("check_list_box")
107 self
.assertEqual(1, len(xTreeList
.getChildren()))
109 xEntry1
= xTreeList
.getChild(0)
110 self
.assertEqual("(empty)", get_state_as_dict(xEntry1
)['Text'])
112 # Without the fix in place, this test would have failed with
113 # AssertionError: 'true' != 'false'
114 self
.assertEqual("true", get_state_as_dict(xEntry1
)['IsChecked'])
115 self
.assertEqual("false", get_state_as_dict(xEntry1
)['IsSemiTransparent'])
117 # Close the popup window
118 xOkButton
= xFloatWindow
.getChild("ok")
119 xOkButton
.executeAction("CLICK", tuple())
121 self
.assertTrue(is_row_hidden(calcDoc
, 1))
122 self
.assertTrue(is_row_hidden(calcDoc
, 2))
123 self
.assertFalse(is_row_hidden(calcDoc
, 3))
124 self
.assertTrue(is_row_hidden(calcDoc
, 4))
126 # vim: set shiftwidth=4 softtabstop=4 expandtab: