Get the style color and number just once
[LibreOffice.git] / sw / qa / uitest / writer_tests3 / customizeDialog.py
blobc7b1a68e8123ac1077f32450345163437104c504
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/.
10 import time
12 from uitest.framework import UITestCase
13 from libreoffice.uno.propertyvalue import mkPropertyValues
14 from uitest.uihelper.common import get_state_as_dict
15 from uitest.uihelper.common import select_pos
17 class ConfigureDialog(UITestCase):
19 def test_search_filter(self):
20 with self.ui_test.create_doc_in_start_center("writer"):
21 with self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog", close_button="cancel") as xDialog:
23 xfunc = xDialog.getChild("functions")
24 xSearch = xDialog.getChild("searchEntry")
26 initialEntryCount = get_state_as_dict(xfunc)["Children"]
27 self.assertTrue(initialEntryCount != 0)
29 xSearch.executeAction("TYPE", mkPropertyValues({"TEXT":"format"}))
31 # Wait for the search/filter op to be completed
32 timeout = time.time() + 1
33 while time.time() < timeout:
34 filteredEntryCount = get_state_as_dict(xfunc)["Children"]
35 if filteredEntryCount != initialEntryCount:
36 break
37 time.sleep(0.1)
39 self.assertTrue(filteredEntryCount < initialEntryCount)
41 xSearch.executeAction("CLEAR", tuple())
43 # Wait for the search/filter op to be completed
44 timeout = time.time() + 1
45 while time.time() < timeout:
46 finalEntryCount = get_state_as_dict(xfunc)["Children"]
47 if finalEntryCount != filteredEntryCount:
48 break
49 time.sleep(0.1)
51 self.assertEqual(initialEntryCount, finalEntryCount)
53 def test_category_listbox(self):
54 with self.ui_test.create_doc_in_start_center("writer"):
55 with self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog", close_button="cancel") as xDialog:
57 xFunc = xDialog.getChild("functions")
58 xCategory = xDialog.getChild("commandcategorylist")
60 initialEntryCount = get_state_as_dict(xFunc)["Children"]
61 self.assertTrue(initialEntryCount != 0)
63 select_pos(xCategory, "1")
64 filteredEntryCount = get_state_as_dict(xFunc)["Children"]
65 self.assertTrue(filteredEntryCount < initialEntryCount)
67 select_pos(xCategory, "0")
68 finalEntryCount = get_state_as_dict(xFunc)["Children"]
69 self.assertEqual(initialEntryCount, finalEntryCount)
71 def test_tdf133862(self):
72 with self.ui_test.create_doc_in_start_center("writer"):
74 self.xUITest.executeCommand(".uno:InsertObjectStarMath")
76 # Without the fix in place, calling customize dialog after inserting
77 # a formula object would crash
78 with self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog", close_button="cancel"):
79 pass
81 def test_gear_button_menu(self):
82 with self.ui_test.create_doc_in_start_center("writer"):
84 with self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog", close_button="cancel") as xDialog:
86 # Open the New Menu Dialog with id = 0
87 xmenugearbtn=xDialog.getChild("menugearbtn")
88 with self.ui_test.execute_blocking_action(
89 xmenugearbtn.executeAction, args=("OPENFROMLIST", mkPropertyValues({"POS": "0"})), close_button="cancel"):
90 pass
92 # Open the Rename Menu Dialog with id = 2
93 with self.ui_test.execute_blocking_action(
94 xmenugearbtn.executeAction, args=("OPENFROMLIST", mkPropertyValues({"POS": "2"})), close_button="cancel"):
95 pass
97 def test_add_remove_items(self):
98 with self.ui_test.create_doc_in_start_center("writer"):
100 with self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog") as xDialog:
101 xTab = xDialog.getChild("tabcontrol")
102 select_pos(xTab, "0")
104 xFunctions = xDialog.getChild("functions")
105 xMenuContents = xDialog.getChild("menucontents")
106 xAddBtn = xDialog.getChild("add")
107 xRemoveBtn = xDialog.getChild("remove")
109 self.assertEqual("1", get_state_as_dict(xFunctions)['SelectionCount'])
110 sSelectEntryText = get_state_as_dict(xFunctions)['SelectEntryText']
111 nChildrenCount = int(get_state_as_dict(xMenuContents)['Children'])
113 self.assertEqual('true',get_state_as_dict(xAddBtn)['Enabled'])
114 self.assertEqual('false',get_state_as_dict(xRemoveBtn)['Enabled'])
116 xAddBtn.executeAction("CLICK", tuple())
118 self.assertEqual(nChildrenCount + 1, int(get_state_as_dict(xMenuContents)['Children']))
119 self.assertEqual(sSelectEntryText, get_state_as_dict(xMenuContents)['SelectEntryText'])
121 self.assertEqual('false',get_state_as_dict(xAddBtn)['Enabled'])
122 self.assertEqual('true',get_state_as_dict(xRemoveBtn)['Enabled'])
124 xRemoveBtn.executeAction("CLICK", tuple())
126 self.assertEqual(nChildrenCount, int(get_state_as_dict(xMenuContents)['Children']))
129 # vim: set shiftwidth=4 softtabstop=4 expandtab: