Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / uitest / findBar / tdf154818.py
blobe0470206faf8cc266edafd9b2b3a5e696fcf5d0e
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 from uitest.framework import UITestCase
10 from uitest.uihelper.common import get_state_as_dict, select_pos
11 from libreoffice.uno.propertyvalue import mkPropertyValues
13 class tdf154818(UITestCase):
15 def test_tdf154818_remember_search_item(self):
16 with self.ui_test.create_doc_in_start_center("writer"):
17 xWriterDoc = self.xUITest.getTopFocusWindow()
18 xWriterEdit = xWriterDoc.getChild("writer_edit")
20 # Search for an entry and check again if it is preselected (A -> B -> A)
21 searchTerms = ["A", "B", "A"]
22 for searchTerm in searchTerms:
23 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+f"}))
24 xFind = xWriterDoc.getChild("find")
25 xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
26 xFind.executeAction("TYPE", mkPropertyValues({"TEXT":searchTerm}))
27 xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
28 xFindBar = xWriterDoc.getChild("FindBar")
29 xFindBar.executeAction("CLICK", mkPropertyValues({"POS":"0"}))
31 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+f"}))
32 xFind = xWriterDoc.getChild("find")
33 # Without the fix in place, this test would have failed with
34 # AssertionError: 'A' != 'B'
35 # i.e., the last search item was not remembered
36 self.assertEqual("A", get_state_as_dict(xFind)["Text"])
38 def test_tdf154818_search_history(self):
39 with self.ui_test.create_doc_in_start_center("writer"):
40 xWriterDoc = self.xUITest.getTopFocusWindow()
41 xWriterEdit = xWriterDoc.getChild("writer_edit")
43 # Search for an entry and check for the search history (A -> B -> C -> B)
44 searchTerms = ["A", "B", "C", "B"]
45 for searchTerm in searchTerms:
46 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+f"}))
47 xFind = xWriterDoc.getChild("find")
48 xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
49 xFind.executeAction("TYPE", mkPropertyValues({"TEXT":searchTerm}))
50 xFind.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
51 xFindBar = xWriterDoc.getChild("FindBar")
52 xFindBar.executeAction("CLICK", mkPropertyValues({"POS":"0"}))
54 # Check if the search history was respected
55 searchTerms = ["B", "C", "A"]
56 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+f"}))
57 xFind = xWriterDoc.getChild("find")
58 for searchTerm in searchTerms:
59 select_pos(xFind, str(searchTerms.index(searchTerm)))
60 # Without the fix in place, this test would have failed with
61 # AssertionError: 'B' != 'C'
62 # i.e., the search history was not respected
63 self.assertEqual(searchTerm, get_state_as_dict(xFind)["Text"])
65 # vim: set shiftwidth=4 softtabstop=4 expandtab: