summaryrefslogtreecommitdiff
path: root/sc/qa/uitest/autofilter2/tdf97340.py
blob: 922dd809d98dd7059abe9193cfb08c9a23791d25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# 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.common import get_state_as_dict, get_url_for_data_file
from libreoffice.uno.propertyvalue import mkPropertyValues

#Bug 97340 - Calc crashes on filtering with select checkbox with space bar

class tdf97340(UITestCase):
    def test_tdf97340_autofilter(self):
        with self.ui_test.load_file(get_url_for_data_file("autofilter.ods")) as calc_doc:
            xCalcDoc = self.xUITest.getTopFocusWindow()
            gridwin = xCalcDoc.getChild("grid_window")

            gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
            xFloatWindow = self.xUITest.getFloatWindow()

            xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
            xTreeList = xCheckListMenu.getChild("check_tree_box")
            self.assertEqual(2, len(xTreeList.getChildren()))
            self.assertEqual("2016", get_state_as_dict(xTreeList.getChild('0'))['Text'])
            self.assertEqual("2017", get_state_as_dict(xTreeList.getChild('1'))['Text'])

            xsearchEdit = xFloatWindow.getChild("search_edit")
            xsearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT":" "}))
            self.assertEqual(0, len(xTreeList.getChildren()))

            xsearchEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))

            #tdf#133785, without the fix in place, it would have been 0
            self.assertEqual(2, len(xTreeList.getChildren()))
            self.assertEqual("2016", get_state_as_dict(xTreeList.getChild('0'))['Text'])
            self.assertEqual("2017", get_state_as_dict(xTreeList.getChild('1'))['Text'])

# vim: set shiftwidth=4 softtabstop=4 expandtab: