From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- sw/qa/uitest/findReplace/findReplace.py | 236 +++++++++++++++++++++++++++++ sw/qa/uitest/findReplace/findSimilarity.py | 73 +++++++++ sw/qa/uitest/findReplace/tdf106099.py | 37 +++++ sw/qa/uitest/findReplace/tdf118208.py | 56 +++++++ sw/qa/uitest/findReplace/tdf119462.py | 37 +++++ sw/qa/uitest/findReplace/tdf126627.py | 44 ++++++ sw/qa/uitest/findReplace/tdf137737.py | 50 ++++++ sw/qa/uitest/findReplace/tdf144089.py | 60 ++++++++ sw/qa/uitest/findReplace/tdf44837.py | 42 +++++ 9 files changed, 635 insertions(+) create mode 100644 sw/qa/uitest/findReplace/findReplace.py create mode 100644 sw/qa/uitest/findReplace/findSimilarity.py create mode 100644 sw/qa/uitest/findReplace/tdf106099.py create mode 100644 sw/qa/uitest/findReplace/tdf118208.py create mode 100644 sw/qa/uitest/findReplace/tdf119462.py create mode 100644 sw/qa/uitest/findReplace/tdf126627.py create mode 100644 sw/qa/uitest/findReplace/tdf137737.py create mode 100644 sw/qa/uitest/findReplace/tdf144089.py create mode 100644 sw/qa/uitest/findReplace/tdf44837.py (limited to 'sw/qa/uitest/findReplace') diff --git a/sw/qa/uitest/findReplace/findReplace.py b/sw/qa/uitest/findReplace/findReplace.py new file mode 100644 index 0000000000..7c9f5315e3 --- /dev/null +++ b/sw/qa/uitest/findReplace/findReplace.py @@ -0,0 +1,236 @@ +# -*- 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 select_pos +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, type_text + +class findReplace(UITestCase): + def test_find_writer(self): + with self.ui_test.load_file(get_url_for_data_file("findReplace.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"second"})) #2nd page + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"third"})) + xsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") #3rd page + + + #now open dialog and verify find="third" (remember last value); replace value with "First" ( click match case) with word "Replace" - click twice Replace button, check "Replace first first" + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + searchterm = xDialog.getChild("searchterm") + self.assertEqual(get_state_as_dict(searchterm)["Text"], "third") + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"First"})) + matchcase = xDialog.getChild("matchcase") + matchcase.executeAction("CLICK", tuple()) #click match case + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Replace"})) #replace textbox + replace = xDialog.getChild("replace") + replace.executeAction("CLICK", tuple()) + replace.executeAction("CLICK", tuple()) #click twice Replace button + #verify + self.assertEqual(writer_doc.Text.String[0:19], "Replace first first") + + #now replace first (uncheck match case) with word "aaa" - click once Replace All button, check "Replace aaa aaa" + replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"aaa"})) + matchcase.executeAction("CLICK", tuple()) #uncheck match case + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + #verify + self.assertEqual(writer_doc.Text.String[0:15], "Replace aaa aaa") + + #now delete strings in textbox Find and textbox Replace, click button Format, select Size=16 pt, Close OK, Find Next; verify Page=2; + #click No format button; close dialog + replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + + format = xDialog.getChild("format") + with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())) as dialog: + xTabs = dialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xSizeFont = dialog.getChild("cbWestSize") + xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"16"})) #set font size 16 + + # Verify these didn't get set again through SvxSearchController::StateChanged, timer- + # triggered from SfxBindings::NextJob while executing the Format dialog above: + self.assertEqual(get_state_as_dict(searchterm)["Text"], "") + self.assertEqual(get_state_as_dict(replaceterm)["Text"], "") + + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + noformat = xDialog.getChild("noformat") + noformat.executeAction("CLICK", tuple()) #click No format button + + + #Bug 39022 - find-replace->$1, not pattern + def test_tdf39022_replace_regexp(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + type_text(xWriterEdit, "test number1 testnot") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"T(est|other)\\>"})) #find + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"replaced$1"})) #replace + + # Deselect similarity before selecting regex + xSimilarity = xDialog.getChild("similarity") + if get_state_as_dict(xSimilarity)['Selected'] == 'true': + xSimilarity.executeAction("CLICK", tuple()) + + regexp = xDialog.getChild("regexp") + regexp.executeAction("CLICK", tuple()) + self.assertEqual("true", get_state_as_dict(regexp)['Selected']) + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + #verify + self.assertEqual(document.Text.String[0:27], "replacedest number1 testnot") + + # Deselect regex button, otherwise it might affect other tests + regexp.executeAction("CLICK", tuple()) + self.assertEqual("false", get_state_as_dict(regexp)['Selected']) + + #tdf116242 ţ ț + def test_tdf116242_replace_t_with_cedilla(self): + with self.ui_test.load_file(get_url_for_data_file("tdf116242.odt")) as writer_doc: + + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"ţ"})) #find + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"ț"})) #replace + includediacritics = xDialog.getChild("includediacritics") + if (get_state_as_dict(includediacritics)["Selected"]) == "false": + includediacritics.executeAction("CLICK", tuple()) + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + #verify + self.assertEqual(writer_doc.Text.String[0:13], "țoootdf116242") + + + #Bug 98417 - FIND & REPLACE: Add 'Find Previous' button + def test_tdf98417_find_previous_writer(self): + with self.ui_test.load_file(get_url_for_data_file("findReplace.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"third"})) + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") + xsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "4") #page 4 + backsearch = xDialog.getChild("backsearch") + backsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") + + def test_tdf136577(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + type_text(xWriterEdit, "x") + + self.assertEqual(document.Text.String, "x") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"x"})) + + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + + self.assertEqual(document.Text.String, "") + + self.xUITest.executeCommand(".uno:Undo") + + # Without the fix in place, this test would have failed with AssertionError: '' != 'x' + self.assertEqual(document.Text.String, "x") + + def test_tdf143128(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + type_text(xWriterEdit, "ß") + + self.assertEqual(document.Text.String, "ß") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"ẞ"})) + + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"SS"})) + + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + + # Without the fix in place, this test would have failed with + # AssertionError: 'ß' != 'SS' + self.assertEqual(document.Text.String, "SS") + + self.xUITest.executeCommand(".uno:Undo") + + self.assertEqual(document.Text.String, "ß") + + def test_tdf154818_search_history(self): + with self.ui_test.create_doc_in_start_center("writer"): + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + xSearchTerm = xDialog.getChild("searchterm") + # Search for an entry and check for the search history (A -> B -> C -> B) + searchTerms = ["A", "B", "C", "B"] + for searchTerm in searchTerms: + xSearchTerm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSearchTerm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xSearchTerm.executeAction("TYPE", mkPropertyValues({"TEXT":searchTerm})) + xSearchNext = xDialog.getChild("search") + xSearchNext.executeAction("CLICK", tuple()) + + # Check if the search history was respected + searchTerms = ["B", "C", "A"] + for searchTerm in searchTerms: + select_pos(xSearchTerm, str(searchTerms.index(searchTerm))) + # Without the fix in place, this test would have failed with + # AssertionError: 'B' != 'C' + # i.e., the search history was not respected + self.assertEqual(searchTerm, get_state_as_dict(xSearchTerm)["Text"]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/findReplace/findSimilarity.py b/sw/qa/uitest/findReplace/findSimilarity.py new file mode 100644 index 0000000000..f12dcaea27 --- /dev/null +++ b/sw/qa/uitest/findReplace/findSimilarity.py @@ -0,0 +1,73 @@ +# -*- 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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +#Find similarities + +class findSimilarities(UITestCase): + def test_find_similarities(self): + with self.ui_test.load_file(get_url_for_data_file("findReplace.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #verify: we are on page 1 + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") + # search and replace dialog + #find = seco + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="") as xDialog: + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"seco"})) #seco + # check similarities, button similarities, set values = 1; close dialog with OK + + similarity = xDialog.getChild("similarity") + if get_state_as_dict(similarity)['Selected'] == 'false': + similarity.executeAction("CLICK", tuple()) + + similaritybtn = xDialog.getChild("similaritybtn") + + with self.ui_test.execute_blocking_action(similaritybtn.executeAction, args=('CLICK', ())) as dialog: + otherfld = dialog.getChild("otherfld") + longerfld = dialog.getChild("longerfld") + shorterfld = dialog.getChild("shorterfld") + otherfld.executeAction("DOWN", tuple()) + longerfld.executeAction("DOWN", tuple()) + shorterfld.executeAction("DOWN", tuple()) + + #open dialog again, verify values = 1; close dialog with cancel + with self.ui_test.execute_blocking_action(similaritybtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog: + otherfld = dialog.getChild("otherfld") + longerfld = dialog.getChild("longerfld") + shorterfld = dialog.getChild("shorterfld") + self.assertEqual(get_state_as_dict(otherfld)["Text"], "1") + self.assertEqual(get_state_as_dict(longerfld)["Text"], "1") + self.assertEqual(get_state_as_dict(shorterfld)["Text"], "1") + + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + # Find next - not found + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") + #find = secon + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"secon"})) + # Find next - verify: we are on page 2 + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) #word "second" is selected + #find = irst + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"irst"})) + # Find next - verify: we are on page 1 + xsearch.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/findReplace/tdf106099.py b/sw/qa/uitest/findReplace/tdf106099.py new file mode 100644 index 0000000000..64fd4831f9 --- /dev/null +++ b/sw/qa/uitest/findReplace/tdf106099.py @@ -0,0 +1,37 @@ +# -*- 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 select_pos +from uitest.uihelper.common import select_by_text +from uitest.uihelper.common import get_state_as_dict + +#Bug 106099 - Find and replace by format, font color added by force + +class tdf106099(UITestCase): + def test_tdf106099_find_format_underline(self): + with self.ui_test.create_doc_in_start_center("writer"): + #Find and replace + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + #2. Choose Format + format = xDialog.getChild("format") + with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())) as dialog: + #Font effects - Underline Single. OK. + xTabs = dialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab font effects + underlinelb = dialog.getChild("underlinelb") + select_by_text(underlinelb, "Single") + + #verify label searchdesc + searchdesc = xDialog.getChild("searchdesc") + self.assertEqual(get_state_as_dict(searchdesc)["Text"], "Single underline") + noformat = xDialog.getChild("noformat") + noformat.executeAction("CLICK", tuple()) #click No format button + self.assertEqual(get_state_as_dict(searchdesc)["Text"], "") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/findReplace/tdf118208.py b/sw/qa/uitest/findReplace/tdf118208.py new file mode 100644 index 0000000000..3735c6cdab --- /dev/null +++ b/sw/qa/uitest/findReplace/tdf118208.py @@ -0,0 +1,56 @@ +# -*- 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 + +# Find and replace +# tdf118208/118212 - enabling either CJK or CTL, or both (Tools -> Options -> Languages and Locales -> General: Default Languages for Documents checkboxes) +# eliminates all crashes. Setting back to Western only recreates the crashes. - DONE + + +class tdf118208(UITestCase): + + def change_default_languages(self, enabled): + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog: + + xPages = xDialog.getChild("pages") + xLanguageEntry = xPages.getChild('2') # Languages and Locales + xLanguageEntry.executeAction("EXPAND", tuple()) + xxLanguageEntryGeneralEntry = xLanguageEntry.getChild('0') + xxLanguageEntryGeneralEntry.executeAction("SELECT", tuple()) # General + + asianlanguage = xDialog.getChild("asiansupport") + complexlanguage = xDialog.getChild("ctlsupport") + if (get_state_as_dict(asianlanguage)["Selected"]) != enabled: + asianlanguage.executeAction("CLICK", tuple()) + if (get_state_as_dict(complexlanguage)["Selected"]) != enabled: + complexlanguage.executeAction("CLICK", tuple()) + + def test_tdf118208_search_dialog_format_crash(self): + with self.ui_test.load_file(get_url_for_data_file("tdf118208.odt")) as writer_doc: + # 1. Open the attached file. + # 2. Press ctrl-H to show the search and replace dialog. + # 3. Press the "Format..." button. + # Libreoffice immediately crashed. + + try: + self.change_default_languages("false") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + + format = xDialog.getChild("format") + + with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())): + pass + + #verify + self.assertEqual(writer_doc.Text.String[0:14], "Aaaaaaaaaaaaaa") + finally: + self.change_default_languages("true") + diff --git a/sw/qa/uitest/findReplace/tdf119462.py b/sw/qa/uitest/findReplace/tdf119462.py new file mode 100644 index 0000000000..ce0aa9a6b2 --- /dev/null +++ b/sw/qa/uitest/findReplace/tdf119462.py @@ -0,0 +1,37 @@ +# -*- 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 select_pos +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict + +#Bug 119462 - Find with formatting adds 0pt text size + +class tdf119462(UITestCase): + def test_tdf119462_find_format(self): + with self.ui_test.create_doc_in_start_center("writer"): + #1. Choose Edit > Find and Replace + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + #2. Choose Format + format = xDialog.getChild("format") + with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())) as dialog: + #3. Choose Bold + xTabs = dialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = dialog.getChild("cbWestStyle") + xweststylelbcjk.executeAction("TYPE", mkPropertyValues({"TEXT":"Bold"})) + + #verify label searchdesc + searchdesc = xDialog.getChild("searchdesc") + self.assertEqual(get_state_as_dict(searchdesc)["Text"], "bold") + noformat = xDialog.getChild("noformat") + noformat.executeAction("CLICK", tuple()) #click No format button + self.assertEqual(get_state_as_dict(searchdesc)["Text"], "") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/findReplace/tdf126627.py b/sw/qa/uitest/findReplace/tdf126627.py new file mode 100644 index 0000000000..aba4658265 --- /dev/null +++ b/sw/qa/uitest/findReplace/tdf126627.py @@ -0,0 +1,44 @@ +# -*- 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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +#Bug 126627 - CRASH: undoing redlinehide deletion + +class tdf126627(UITestCase): + def test_tdf126627_crash_undo_deletion(self): + with self.ui_test.load_file(get_url_for_data_file("tdf126627.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"bar"})) + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + + #2. Place the cursor before 'bar' + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) + #3. Hit backspace 4 times -> Foo and bar are together + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + self.assertEqual(writer_doc.Text.String[0:6], "foobar") + #4. Undo once-> Crash + self.xUITest.executeCommand(".uno:Undo") + #verify that we have now two words + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close") as xDialog: + xselectwords = xDialog.getChild("selectwords") + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "2") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/findReplace/tdf137737.py b/sw/qa/uitest/findReplace/tdf137737.py new file mode 100644 index 0000000000..6e24a2ced4 --- /dev/null +++ b/sw/qa/uitest/findReplace/tdf137737.py @@ -0,0 +1,50 @@ +# -*- 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_url_for_data_file, get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf137737(UITestCase): + + def test_tdf137737(self): + with self.ui_test.load_file(get_url_for_data_file("tdf137737.odt")) as writer_doc: + + self.assertEqual(2, writer_doc.Endnotes.Count) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + xSearchterm = xDialog.getChild("searchterm") + xSearchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSearchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xSearchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"[:control:]"})) + + xReplaceterm = xDialog.getChild("replaceterm") + xReplaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"A"})) + + # Deselect similarity before selecting regex + xSimilarity = xDialog.getChild("similarity") + if get_state_as_dict(xSimilarity)['Selected'] == 'true': + xSimilarity.executeAction("CLICK", tuple()) + + xRegexp = xDialog.getChild("regexp") + xRegexp.executeAction("CLICK", tuple()) + self.assertEqual("true", get_state_as_dict(xRegexp)['Selected']) + + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + + # Deselect regex button, otherwise it might affect other tests + xRegexp.executeAction("CLICK", tuple()) + self.assertEqual("false", get_state_as_dict(xRegexp)['Selected']) + + # Without the fix in place, this test would have failed with + # AssertionError: 0 != 1 + self.assertEqual(0, writer_doc.Endnotes.Count) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/findReplace/tdf144089.py b/sw/qa/uitest/findReplace/tdf144089.py new file mode 100644 index 0000000000..ae26ffd24a --- /dev/null +++ b/sw/qa/uitest/findReplace/tdf144089.py @@ -0,0 +1,60 @@ +# -*- 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 type_text, get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf144089(UITestCase): + + def test_tdf144089(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + type_text(xWriterEdit, "This is a test") + xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "10", "END_POS": "14"})) + + self.assertEqual("test", document.CurrentSelection[0].String) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + xSearchterm = xDialog.getChild("searchterm") + xSearchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSearchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xSearchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"^."})) + + xReplaceterm = xDialog.getChild("replaceterm") + xReplaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"A"})) + + xSelectionOnly = xDialog.getChild("selection") + xSelectionOnly.executeAction("CLICK", tuple()) + + # Deselect similarity before selecting regex + xSimilarity = xDialog.getChild("similarity") + if get_state_as_dict(xSimilarity)['Selected'] == 'true': + xSimilarity.executeAction("CLICK", tuple()) + + xRegexp = xDialog.getChild("regexp") + xRegexp.executeAction("CLICK", tuple()) + self.assertEqual("true", get_state_as_dict(xRegexp)['Selected']) + + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + + # Deselect regex button, otherwise it might affect other tests + xRegexp.executeAction("CLICK", tuple()) + self.assertEqual("false", get_state_as_dict(xRegexp)['Selected']) + + # Without the fix in place, this test would have failed with + # AssertionError: 'This is a test' != 'This is a AAAA' + self.assertEqual("This is a test", document.Text.String) + + self.assertEqual("test", document.CurrentSelection[0].String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/findReplace/tdf44837.py b/sw/qa/uitest/findReplace/tdf44837.py new file mode 100644 index 0000000000..79189a55ef --- /dev/null +++ b/sw/qa/uitest/findReplace/tdf44837.py @@ -0,0 +1,42 @@ +# -*- 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 type_text +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 44837 - EDITING 'Replace All' clears current selection + +class tdf44837(UITestCase): + + def test_tdf448373_Replace_All_clears_current_selection(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + type_text(xWriterEdit, "asd asd") + self.xUITest.executeCommand(".uno:SelectAll") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"b"})) #replace textbox + + selectionOnly = xDialog.getChild("selection") + selectionOnly.executeAction("CLICK", tuple()) + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + + self.assertEqual(document.Text.String[0:8], "bsd bsd") + self.assertEqual(len(document.CurrentSelection[0].String) > 1, True) + #follow-up bug 125663 + +# vim: set shiftwidth=4 softtabstop=4 expandtab: -- cgit v1.2.3