diff options
Diffstat (limited to 'sw/qa/uitest/writer_tests3/customizeDialog.py')
-rw-r--r-- | sw/qa/uitest/writer_tests3/customizeDialog.py | 174 |
1 files changed, 84 insertions, 90 deletions
diff --git a/sw/qa/uitest/writer_tests3/customizeDialog.py b/sw/qa/uitest/writer_tests3/customizeDialog.py index 52adae2b0ee1..c7b1a68e8123 100644 --- a/sw/qa/uitest/writer_tests3/customizeDialog.py +++ b/sw/qa/uitest/writer_tests3/customizeDialog.py @@ -1,8 +1,11 @@ # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- # +# This file is part of the LibreOffice project. +# # 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/. +# import time @@ -13,123 +16,114 @@ from uitest.uihelper.common import select_pos class ConfigureDialog(UITestCase): - def test_open_ConfigureDialog_writer(self): + def test_search_filter(self): + with self.ui_test.create_doc_in_start_center("writer"): + with self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog", close_button="cancel") as xDialog: - self.ui_test.create_doc_in_start_center("writer") - self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog") - xDialog = self.xUITest.getTopFocusWindow() + xfunc = xDialog.getChild("functions") + xSearch = xDialog.getChild("searchEntry") - xcancBtn = xDialog.getChild("cancel") - xcancBtn.executeAction("CLICK", tuple()) + initialEntryCount = get_state_as_dict(xfunc)["Children"] + self.assertTrue(initialEntryCount != 0) - self.ui_test.close_doc() + xSearch.executeAction("TYPE", mkPropertyValues({"TEXT":"format"})) - def test_search_filter(self): - self.ui_test.create_doc_in_start_center("writer") - self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog") - xDialog = self.xUITest.getTopFocusWindow() + # Wait for the search/filter op to be completed + timeout = time.time() + 1 + while time.time() < timeout: + filteredEntryCount = get_state_as_dict(xfunc)["Children"] + if filteredEntryCount != initialEntryCount: + break + time.sleep(0.1) - xfunc = xDialog.getChild("functions") - xSearch = xDialog.getChild("searchEntry") + self.assertTrue(filteredEntryCount < initialEntryCount) - initialEntryCount = get_state_as_dict(xfunc)["Children"] - self.assertTrue(initialEntryCount != 0) + xSearch.executeAction("CLEAR", tuple()) - xSearch.executeAction("TYPE", mkPropertyValues({"TEXT":"format"})) + # Wait for the search/filter op to be completed + timeout = time.time() + 1 + while time.time() < timeout: + finalEntryCount = get_state_as_dict(xfunc)["Children"] + if finalEntryCount != filteredEntryCount: + break + time.sleep(0.1) - # Wait for the search/filter op to be completed - timeout = time.time() + 1 - while time.time() < timeout: - filteredEntryCount = get_state_as_dict(xfunc)["Children"] - if filteredEntryCount != initialEntryCount: - break - time.sleep(0.1) + self.assertEqual(initialEntryCount, finalEntryCount) - self.assertTrue(filteredEntryCount < initialEntryCount) + def test_category_listbox(self): + with self.ui_test.create_doc_in_start_center("writer"): + with self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog", close_button="cancel") as xDialog: - xSearch.executeAction("CLEAR", tuple()) + xFunc = xDialog.getChild("functions") + xCategory = xDialog.getChild("commandcategorylist") - # Wait for the search/filter op to be completed - timeout = time.time() + 1 - while time.time() < timeout: - finalEntryCount = get_state_as_dict(xfunc)["Children"] - if finalEntryCount != filteredEntryCount: - break - time.sleep(0.1) + initialEntryCount = get_state_as_dict(xFunc)["Children"] + self.assertTrue(initialEntryCount != 0) - self.assertEqual(initialEntryCount, finalEntryCount) + select_pos(xCategory, "1") + filteredEntryCount = get_state_as_dict(xFunc)["Children"] + self.assertTrue(filteredEntryCount < initialEntryCount) + select_pos(xCategory, "0") + finalEntryCount = get_state_as_dict(xFunc)["Children"] + self.assertEqual(initialEntryCount, finalEntryCount) - xcancBtn = xDialog.getChild("cancel") #button Cancel - xcancBtn.executeAction("CLICK", tuple()) #click the button + def test_tdf133862(self): + with self.ui_test.create_doc_in_start_center("writer"): - self.ui_test.close_doc() + self.xUITest.executeCommand(".uno:InsertObjectStarMath") - def test_category_listbox(self): - self.ui_test.create_doc_in_start_center("writer") - self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog") - xDialog = self.xUITest.getTopFocusWindow() + # Without the fix in place, calling customize dialog after inserting + # a formula object would crash + with self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog", close_button="cancel"): + pass - xFunc = xDialog.getChild("functions") - xCategory = xDialog.getChild("commandcategorylist") + def test_gear_button_menu(self): + with self.ui_test.create_doc_in_start_center("writer"): - initialEntryCount = get_state_as_dict(xFunc)["Children"] - self.assertTrue(initialEntryCount != 0) + with self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog", close_button="cancel") as xDialog: - select_pos(xCategory, "1") - filteredEntryCount = get_state_as_dict(xFunc)["Children"] - self.assertTrue(filteredEntryCount < initialEntryCount) + # Open the New Menu Dialog with id = 0 + xmenugearbtn=xDialog.getChild("menugearbtn") + with self.ui_test.execute_blocking_action( + xmenugearbtn.executeAction, args=("OPENFROMLIST", mkPropertyValues({"POS": "0"})), close_button="cancel"): + pass - select_pos(xCategory, "0") - finalEntryCount = get_state_as_dict(xFunc)["Children"] - self.assertEqual(initialEntryCount, finalEntryCount) + # Open the Rename Menu Dialog with id = 2 + with self.ui_test.execute_blocking_action( + xmenugearbtn.executeAction, args=("OPENFROMLIST", mkPropertyValues({"POS": "2"})), close_button="cancel"): + pass - xcancBtn = xDialog.getChild("cancel") #button Cancel - xcancBtn.executeAction("CLICK", tuple()) #click the button + def test_add_remove_items(self): + with self.ui_test.create_doc_in_start_center("writer"): - self.ui_test.close_doc() + with self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") - def test_tdf133862(self): - self.ui_test.create_doc_in_start_center("writer") + xFunctions = xDialog.getChild("functions") + xMenuContents = xDialog.getChild("menucontents") + xAddBtn = xDialog.getChild("add") + xRemoveBtn = xDialog.getChild("remove") - self.xUITest.executeCommand(".uno:InsertObjectStarMath") + self.assertEqual("1", get_state_as_dict(xFunctions)['SelectionCount']) + sSelectEntryText = get_state_as_dict(xFunctions)['SelectEntryText'] + nChildrenCount = int(get_state_as_dict(xMenuContents)['Children']) - # Without the fix in place, calling customize dialog after inserting - # a formula object would crash - self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog") - xDialog = self.xUITest.getTopFocusWindow() + self.assertEqual('true',get_state_as_dict(xAddBtn)['Enabled']) + self.assertEqual('false',get_state_as_dict(xRemoveBtn)['Enabled']) - xcancBtn = xDialog.getChild("cancel") - xcancBtn.executeAction("CLICK", tuple()) + xAddBtn.executeAction("CLICK", tuple()) - self.ui_test.close_doc() + self.assertEqual(nChildrenCount + 1, int(get_state_as_dict(xMenuContents)['Children'])) + self.assertEqual(sSelectEntryText, get_state_as_dict(xMenuContents)['SelectEntryText']) + + self.assertEqual('false',get_state_as_dict(xAddBtn)['Enabled']) + self.assertEqual('true',get_state_as_dict(xRemoveBtn)['Enabled']) + + xRemoveBtn.executeAction("CLICK", tuple()) + + self.assertEqual(nChildrenCount, int(get_state_as_dict(xMenuContents)['Children'])) - def test_gear_button_menu(self): - self.ui_test.create_doc_in_start_center("writer") - - self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog") - def close_dialog(dlg): - CancelBtn = dlg.getChild("cancel") - self.ui_test.close_dialog_through_button(CancelBtn) - - # Open the New Menu Dialog with id = 0 - xDialog = self.xUITest.getTopFocusWindow() - xmenugearbtn=xDialog.getChild("menugearbtn") - def show_dialog0(): - xmenugearbtn.executeAction("OPENFROMLIST", mkPropertyValues({"POS": "0" })) - self.ui_test.execute_blocking_action( action=show_dialog0, dialog_handler=close_dialog) - - # Open the Rename Menu Dialog with id = 2 - xDialog = self.xUITest.getTopFocusWindow() - xmenugearbtn=xDialog.getChild("menugearbtn") - def show_dialog2(): - xmenugearbtn.executeAction("OPENFROMLIST", mkPropertyValues({"POS": "2"})) - self.ui_test.execute_blocking_action( action=show_dialog2, dialog_handler=close_dialog) - - xDialog = self.xUITest.getTopFocusWindow() - xcancBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xcancBtn) - - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: |