Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / qa / uitest / conditional_format / tdf96453.py
blob696fff87da3f9f94fee6bb6864877165799fed7c
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/.
8 from uitest.framework import UITestCase
10 import os
12 from uitest.uihelper.common import get_state_as_dict
13 from uitest.path import get_srcdir_url
15 from libreoffice.calc.document import get_sheet_from_doc
16 from libreoffice.calc.conditional_format import get_conditional_format_from_sheet
18 def get_url_for_data_file(file_name):
19 return get_srcdir_url() + "/uitest/calc_tests/data/" + file_name
21 class ConditionalFormatDlgTest(UITestCase):
23 def test_simple_open_manager(self):
25 calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf96453.ods"))
27 self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog")
29 xCondFormatMgr = self.xUITest.getTopFocusWindow()
31 xCancelBtn = xCondFormatMgr.getChild("cancel")
32 xCancelBtn.executeAction("CLICK", tuple())
34 self.ui_test.close_doc()
36 def test_tdf96453(self):
38 calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf96453.ods"))
40 sheet = get_sheet_from_doc(calc_doc, 0)
41 conditional_format_list = get_conditional_format_from_sheet(sheet)
42 self.assertEqual(conditional_format_list.getLength(), 2)
44 self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog")
46 xCondFormatMgr = self.xUITest.getTopFocusWindow()
48 # check that we have exactly two conditional formats in the beginning
49 xList = xCondFormatMgr.getChild("CONTAINER")
50 list_state = get_state_as_dict(xList)
51 self.assertEqual(list_state['Children'], '2')
53 # remove one conditional format
54 xRemoveBtn = xCondFormatMgr.getChild("remove")
55 xRemoveBtn.executeAction("CLICK", tuple())
57 # check that the table only shows one
58 # but the document still contains two
59 list_state = get_state_as_dict(xList)
60 self.assertEqual(list_state['Children'], '1')
62 self.assertEqual(conditional_format_list.getLength(), 2)
64 # add a new conditional format through the add button
65 xAddBtn = xCondFormatMgr.getChild("add")
66 self.ui_test.execute_dialog_through_action(xAddBtn, "CLICK", event_name = "ModelessDialogVisible")
68 xCondFormatDlg = self.xUITest.getTopFocusWindow()
69 xCondFormatOkBtn = xCondFormatDlg.getChild("ok")
70 self.ui_test.close_dialog_through_button(xCondFormatOkBtn)
72 # we need to get a pointer again as the old window has been deleted
73 xCondFormatMgr = self.xUITest.getTopFocusWindow()
75 # check again that we now have 2 and not 3 entries in the list
76 # and still only 2 conditional formats in the document
77 xList = xCondFormatMgr.getChild("CONTAINER")
78 list_state = get_state_as_dict(xList)
79 self.assertEqual(list_state['Children'], '2')
81 self.assertEqual(conditional_format_list.getLength(), 2)
83 # close the conditional format manager
84 xCancelBtn = xCondFormatMgr.getChild("cancel")
85 self.ui_test.close_dialog_through_button(xCancelBtn)
87 self.ui_test.close_doc()
89 # vim: set shiftwidth=4 softtabstop=4 expandtab: