summaryrefslogtreecommitdiffstats
path: root/sw/qa/uitest/findBar
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /sw/qa/uitest/findBar
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/qa/uitest/findBar')
-rw-r--r--sw/qa/uitest/findBar/findbar.py68
-rw-r--r--sw/qa/uitest/findBar/tdf136941.py67
-rw-r--r--sw/qa/uitest/findBar/tdf138232.py52
-rwxr-xr-xsw/qa/uitest/findBar/tdf154269.py36
-rw-r--r--sw/qa/uitest/findBar/tdf154818.py65
-rw-r--r--sw/qa/uitest/findBar/tdf88608.py56
6 files changed, 344 insertions, 0 deletions
diff --git a/sw/qa/uitest/findBar/findbar.py b/sw/qa/uitest/findBar/findbar.py
new file mode 100644
index 0000000000..577885411c
--- /dev/null
+++ b/sw/qa/uitest/findBar/findbar.py
@@ -0,0 +1,68 @@
+# -*- 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
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+#test Find Bar
+class FindBar(UITestCase):
+
+ def test_find_bar(self):
+
+ with self.ui_test.create_doc_in_start_center("writer"):
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+ # Type some lines to search for words on them
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice Writer"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice Calc"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "The Document Foundation"}))
+
+ # open the Find Bar
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+f"}))
+
+ # Type the Word that we want to search for it
+ xfind = xWriterDoc.getChild("find")
+ xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "Libre"}))
+
+ # Select the Find Bar
+ xfind_bar = xWriterDoc.getChild("FindBar")
+ self.assertEqual(get_state_as_dict(xfind_bar)["ItemCount"], "14")
+
+ # Press on FindAll in the Find Bar
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
+ self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemID"], "5") # 5 is FindAll id for Pos 4
+ self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemText"], "Find All")
+ self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemCommand"], ".uno:FindAll")
+ self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "LibreLibreLibre")
+
+ # Press on Find Next in the Find Bar
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) # 3 is Find Next pos
+ self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemID"], "4")
+ self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemText"], "Find Next")
+ self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemCommand"], ".uno:DownSearch")
+ self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "Libre")
+
+ # Press on Find Previous in the Find Bar
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) # 2 is Find Previous pos
+ self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemID"], "3")
+ self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemText"], "Find Previous")
+ self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemCommand"], ".uno:UpSearch")
+ self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "Libre")
+
+ # Close the Find Bar
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 0 is pos for close
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findBar/tdf136941.py b/sw/qa/uitest/findBar/tdf136941.py
new file mode 100644
index 0000000000..f1d147b1a4
--- /dev/null
+++ b/sw/qa/uitest/findBar/tdf136941.py
@@ -0,0 +1,67 @@
+# -*- 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
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf136941(UITestCase):
+
+ def test_tdf136941(self):
+
+ with self.ui_test.create_doc_in_start_center("writer"):
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello World"}))
+
+ self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
+
+ xfind = xWriterDoc.getChild("find")
+ xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
+
+ self.assertEqual("Hello", get_state_as_dict(xfind)['Text'])
+
+ xfind_bar = xWriterDoc.getChild("FindBar")
+
+ # Search Next
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
+
+ # Close button
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "0"}))
+
+ # Check the toolbar is closed
+ self.assertTrue("find" not in xWriterDoc.getChildren())
+ self.assertEqual("Hello", get_state_as_dict(xWriterEdit)['SelectedText'])
+
+ self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
+
+ xfind = xWriterDoc.getChild("find")
+ self.ui_test.wait_until_property_is_updated(xfind, 'SelectedText', "Hello")
+ self.assertEqual("Hello", get_state_as_dict(xfind)['SelectedText'])
+
+ xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "World"}))
+
+ # Without the fix in place, this test would have failed with
+ # AssertionError: 'World' != 'WorldHello'
+ self.assertEqual("World", get_state_as_dict(xfind)['Text'])
+
+ xfind_bar = xWriterDoc.getChild("FindBar")
+
+ # Search Next
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
+
+ # Close button
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "0"}))
+
+ # Check the toolbar is closed
+ self.assertTrue("find" not in xWriterDoc.getChildren())
+ self.assertEqual("World", get_state_as_dict(xWriterEdit)['SelectedText'])
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findBar/tdf138232.py b/sw/qa/uitest/findBar/tdf138232.py
new file mode 100644
index 0000000000..060fe8de29
--- /dev/null
+++ b/sw/qa/uitest/findBar/tdf138232.py
@@ -0,0 +1,52 @@
+# -*- 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
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf138232(UITestCase):
+
+ def test_tdf138232(self):
+
+ with self.ui_test.create_doc_in_start_center("writer"):
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
+
+ self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
+
+ xfind = xWriterDoc.getChild("find")
+ self.ui_test.wait_until_property_is_updated(xfind, 'HasFocus', "true")
+ self.assertEqual("true", get_state_as_dict(xfind)['HasFocus'])
+
+ xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
+ self.assertEqual("Hello", get_state_as_dict(xfind)['Text'])
+
+ xfind_bar = xWriterDoc.getChild("FindBar")
+
+ # Click on Find All
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
+
+ self.assertEqual("HelloHello", get_state_as_dict(xWriterEdit)['SelectedText'])
+
+ xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "World"}))
+
+ # Without the fix in place, this test would have failed with
+ # AssertionError: 'HelloWorld' != 'World'
+ self.assertEqual("HelloWorld", get_state_as_dict(xfind)['Text'])
+
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
+
+ self.assertEqual("", get_state_as_dict(xWriterEdit)['SelectedText'])
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findBar/tdf154269.py b/sw/qa/uitest/findBar/tdf154269.py
new file mode 100755
index 0000000000..aebab770ca
--- /dev/null
+++ b/sw/qa/uitest/findBar/tdf154269.py
@@ -0,0 +1,36 @@
+# -*- 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
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf154269(UITestCase):
+
+ def test_tdf154269(self):
+
+ with self.ui_test.create_doc_in_start_center("writer"):
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+ # Generate a search history with more than 10 entries (A to Z)
+ for searchTerm in map(chr, range(65, 91)):
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+f"}))
+ xFind = xWriterDoc.getChild("find")
+ xFindBar = xWriterDoc.getChild("FindBar")
+ xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ xFind.executeAction("TYPE", mkPropertyValues({"TEXT":searchTerm}))
+ xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
+ xFindBar.executeAction("CLICK", mkPropertyValues({"POS":"0"}))
+
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+f"}))
+ xFind = xWriterDoc.getChild("find")
+ # The default value of FindReplaceRememberedSearches has been respected
+ self.assertEqual("10", get_state_as_dict(xFind)["EntryCount"])
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findBar/tdf154818.py b/sw/qa/uitest/findBar/tdf154818.py
new file mode 100644
index 0000000000..e0470206fa
--- /dev/null
+++ b/sw/qa/uitest/findBar/tdf154818.py
@@ -0,0 +1,65 @@
+# -*- 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_pos
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf154818(UITestCase):
+
+ def test_tdf154818_remember_search_item(self):
+ with self.ui_test.create_doc_in_start_center("writer"):
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+ # Search for an entry and check again if it is preselected (A -> B -> A)
+ searchTerms = ["A", "B", "A"]
+ for searchTerm in searchTerms:
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+f"}))
+ xFind = xWriterDoc.getChild("find")
+ xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ xFind.executeAction("TYPE", mkPropertyValues({"TEXT":searchTerm}))
+ xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
+ xFindBar = xWriterDoc.getChild("FindBar")
+ xFindBar.executeAction("CLICK", mkPropertyValues({"POS":"0"}))
+
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+f"}))
+ xFind = xWriterDoc.getChild("find")
+ # Without the fix in place, this test would have failed with
+ # AssertionError: 'A' != 'B'
+ # i.e., the last search item was not remembered
+ self.assertEqual("A", get_state_as_dict(xFind)["Text"])
+
+ def test_tdf154818_search_history(self):
+ with self.ui_test.create_doc_in_start_center("writer"):
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+ # Search for an entry and check for the search history (A -> B -> C -> B)
+ searchTerms = ["A", "B", "C", "B"]
+ for searchTerm in searchTerms:
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+f"}))
+ xFind = xWriterDoc.getChild("find")
+ xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ xFind.executeAction("TYPE", mkPropertyValues({"TEXT":searchTerm}))
+ xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
+ xFindBar = xWriterDoc.getChild("FindBar")
+ xFindBar.executeAction("CLICK", mkPropertyValues({"POS":"0"}))
+
+ # Check if the search history was respected
+ searchTerms = ["B", "C", "A"]
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+f"}))
+ xFind = xWriterDoc.getChild("find")
+ for searchTerm in searchTerms:
+ select_pos(xFind, 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(xFind)["Text"])
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findBar/tdf88608.py b/sw/qa/uitest/findBar/tdf88608.py
new file mode 100644
index 0000000000..83e99d8e1c
--- /dev/null
+++ b/sw/qa/uitest/findBar/tdf88608.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
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf88608(UITestCase):
+
+ def test_tdf88608(self):
+
+ with self.ui_test.create_doc_in_start_center("writer"):
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello World"}))
+
+ self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
+
+ # Search a word that doesn't exist
+ xfind = xWriterDoc.getChild("find")
+ xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "X"}))
+ self.assertEqual("X", get_state_as_dict(xfind)['Text'])
+
+ xfind_bar = xWriterDoc.getChild("FindBar")
+ self.assertEqual('', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
+
+ # Search Next
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
+
+ self.assertEqual('Search key not found', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
+
+ self.assertEqual("", get_state_as_dict(xWriterEdit)['SelectedText'])
+
+ xfind.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
+ xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "World"}))
+ self.assertEqual("World", get_state_as_dict(xfind)['Text'])
+
+ # Without the fix in place, this test would have failed with
+ # AssertionError: '' != 'Search key not found'
+ self.assertEqual('', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
+
+ # Search Next
+ xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
+
+ self.assertEqual('Reached the end of the document', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
+
+ self.assertEqual("World", get_state_as_dict(xWriterEdit)['SelectedText'])
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: