diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-01-14 16:00:05 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-01-14 18:54:27 +0100 |
commit | cb4e90c05fb26f37124b5d4bcf15bd1736c05850 (patch) | |
tree | 53e982e793896229a7164ba625763a0cd4efa904 /sw | |
parent | 7d990aafdc363b2a12b5db78637d7f3bef7780bd (diff) |
tdf#146375: sw: add UItest
Change-Id: I8d165b257f4bee3921f1a4624a7797ed22327e40
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128419
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/uitest/writer_dialogs/openDialogs.py | 3 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests2/tdf146375.py | 76 |
2 files changed, 78 insertions, 1 deletions
diff --git a/sw/qa/uitest/writer_dialogs/openDialogs.py b/sw/qa/uitest/writer_dialogs/openDialogs.py index beac14eb9d08..b4537836ec00 100644 --- a/sw/qa/uitest/writer_dialogs/openDialogs.py +++ b/sw/qa/uitest/writer_dialogs/openDialogs.py @@ -13,7 +13,8 @@ from uitest.uihelper.testDialog import testDialog dialogs = [ {"command": ".uno:OpenRemote", "closeButton": "cancel"}, - {"command": ".uno:NewDoc", "closeButton": "close"}, + #{"command": ".uno:NewDoc", "closeButton": "close"}, + # tested in sw/qa/uitest/writer_tests2/tdf146375.py {"command": ".uno:SaveAsTemplate", "closeButton": "cancel"}, #{"command": ".uno:ExportToPDF", "closeButton": "cancel", "skipTestOK": True}, # tested in sw/qa/uitest/writer_tests4/exportToPDF.py diff --git a/sw/qa/uitest/writer_tests2/tdf146375.py b/sw/qa/uitest/writer_tests2/tdf146375.py new file mode 100644 index 000000000000..e22e6c4d3dc2 --- /dev/null +++ b/sw/qa/uitest/writer_tests2/tdf146375.py @@ -0,0 +1,76 @@ +# -*- 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/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues +import random +import string + +class Tdf146375(UITestCase): + + def test_tdf146375(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + + count = 0 + # Use a random name + categoryName = ''.join(random.choice(string.ascii_lowercase) for i in range(15)) + renamedCategory = categoryName + "-renamed" + + with self.ui_test.execute_dialog_through_command(".uno:NewDoc", close_button="close") as xDialog: + xFilterFolder = xDialog.getChild("filter_folder") + self.assertEqual("All Categories", get_state_as_dict(xFilterFolder)["SelectEntryText"]) + count = int(get_state_as_dict(xFilterFolder)["EntryCount"]) + + xActionMenu = xDialog.getChild("action_menu") + + # Create a new category + with self.ui_test.execute_blocking_action( + xActionMenu.executeAction, args=('OPENFROMLIST', mkPropertyValues({"POS": "0"}))) as xNameDialog: + xEntry = xNameDialog.getChild("entry") + xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xEntry.executeAction("TYPE", mkPropertyValues({"TEXT": categoryName})) + + self.assertEqual(count + 1, int(get_state_as_dict(xFilterFolder)["EntryCount"])) + + select_by_text(xFilterFolder, categoryName) + self.assertEqual(categoryName, get_state_as_dict(xFilterFolder)["SelectEntryText"]) + + # Rename the category + with self.ui_test.execute_blocking_action( + xActionMenu.executeAction, args=('OPENFROMLIST', mkPropertyValues({"POS": "1"}))) as xNameDialog: + xEntry = xNameDialog.getChild("entry") + xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xEntry.executeAction("TYPE", mkPropertyValues({"TEXT": renamedCategory})) + + self.assertEqual(count + 1, int(get_state_as_dict(xFilterFolder)["EntryCount"])) + self.assertEqual(renamedCategory, get_state_as_dict(xFilterFolder)["SelectEntryText"]) + + with self.ui_test.execute_dialog_through_command(".uno:NewDoc", close_button="close") as xDialog: + xFilterFolder = xDialog.getChild("filter_folder") + self.assertEqual(count + 1, int(get_state_as_dict(xFilterFolder)["EntryCount"])) + + select_by_text(xFilterFolder, renamedCategory) + + # Without the fix in place, this test would have failed with + # AssertionError: 'zwpyzgwuwleanap-renamed' != 'All Categories' + self.assertEqual(renamedCategory, get_state_as_dict(xFilterFolder)["SelectEntryText"]) + + xActionMenu = xDialog.getChild("action_menu") + + # Delete the category + with self.ui_test.execute_blocking_action( + xActionMenu.executeAction, args=('OPENFROMLIST', mkPropertyValues({"POS": "2"})), close_button="yes") as xNameDialog: + pass + + self.assertEqual(count, int(get_state_as_dict(xFilterFolder)["EntryCount"])) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |