From cb4e90c05fb26f37124b5d4bcf15bd1736c05850 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Fri, 14 Jan 2022 16:00:05 +0100 Subject: tdf#146375: sw: add UItest Change-Id: I8d165b257f4bee3921f1a4624a7797ed22327e40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128419 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sw/qa/uitest/writer_dialogs/openDialogs.py | 3 +- sw/qa/uitest/writer_tests2/tdf146375.py | 76 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 sw/qa/uitest/writer_tests2/tdf146375.py (limited to 'sw') 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: -- cgit