diff options
author | Baole Fang <baole.fang@gmail.com> | 2023-07-06 12:03:31 -0400 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-07-29 03:53:28 +0200 |
commit | e26aeb882dd236adf19679d5df9b7ba5da1ed226 (patch) | |
tree | 7a144a0a6bc65f3fde49401be63dfd32c70f8d96 /sw | |
parent | e3d28846c2343072750197fcdeaf44a945ddcb61 (diff) |
tdf#156165: Fix replace custom styles while typing
Originally, Replace Custom Styles changes styles to text body by entering BuiltText. Since styles change to text body is removed from BuiltTest, it is converted independently.
Now, conversion is applied even during typing because m_aFlags.bChgUserColl is true (its default value) during typing. Therefore, its default value is changed to false.
Change-Id: I8ce067b311922b5e1bdcd84036229c369b50a977
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154144
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/uitest/data/tdf156165.odt | bin | 0 -> 10462 bytes | |||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf156165.py | 80 |
2 files changed, 80 insertions, 0 deletions
diff --git a/sw/qa/uitest/data/tdf156165.odt b/sw/qa/uitest/data/tdf156165.odt Binary files differnew file mode 100644 index 000000000000..aabcfef91499 --- /dev/null +++ b/sw/qa/uitest/data/tdf156165.odt diff --git a/sw/qa/uitest/writer_tests/tdf156165.py b/sw/qa/uitest/writer_tests/tdf156165.py new file mode 100644 index 000000000000..69d1928bb8ce --- /dev/null +++ b/sw/qa/uitest/writer_tests/tdf156165.py @@ -0,0 +1,80 @@ +# -*- 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, get_url_for_data_file +from uitest.uihelper.common import select_pos +from libreoffice.uno.propertyvalue import mkPropertyValues +from time import sleep + +class tdf156165(UITestCase): + + def test_tdf156165(self): + with self.ui_test.load_file(get_url_for_data_file("tdf156165.odt")): + xMainWindow = self.xUITest.getTopFocusWindow() + writer_edit = xMainWindow.getChild("writer_edit") + style=xMainWindow.getChild('applystyle') + + with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + options=xDialog.getChild('list') + checkbox=options.getChild("16") + self.assertEqual("Replace Custom Styles", get_state_as_dict(checkbox)["Text"]) + + # Replace Custom Styles is default to be false + self.assertEqual("false", get_state_as_dict(checkbox)["IsChecked"]) + + # Replace Custom Styles when applying manully with it disabled, should not change style + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"})) + self.xUITest.executeCommand(".uno:AutoFormatApply") + sleep(1) + self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") + + # Replace Custom Styles when typing with it disabled, should not change style + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "12", "START_POS": "12"})) + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + sleep(1) + self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # new line + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"})) + self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # original line + + with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + options=xDialog.getChild('list') + checkbox=options.getChild("16") + self.assertEqual("Replace Custom Styles", get_state_as_dict(checkbox)["Text"]) + + # set Replace Custom Styles to True + checkbox.executeAction("CLICK", tuple()) + self.assertEqual("true", get_state_as_dict(checkbox)["IsChecked"]) + + # Replace Custom Styles when applying manully with it enabled, should change style + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"})) + self.xUITest.executeCommand(".uno:AutoFormatApply") + sleep(1) + self.assertEqual(get_state_as_dict(style)["Text"], "Body Text") + + # Replace Custom Styles when typing with it enabled, should not change style + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "12", "START_POS": "12"})) + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + sleep(1) + self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # new line + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"})) + self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # original line + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |