Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / uitest / findReplace / tdf144089.py
blobae26ffd24a3491ff084347269c25d22a1012e2b1
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/.
10 from uitest.framework import UITestCase
11 from uitest.uihelper.common import type_text, get_state_as_dict
12 from libreoffice.uno.propertyvalue import mkPropertyValues
14 class tdf144089(UITestCase):
16 def test_tdf144089(self):
17 with self.ui_test.create_doc_in_start_center("writer") as document:
18 xWriterDoc = self.xUITest.getTopFocusWindow()
19 xWriterEdit = xWriterDoc.getChild("writer_edit")
21 type_text(xWriterEdit, "This is a test")
22 xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "10", "END_POS": "14"}))
24 self.assertEqual("test", document.CurrentSelection[0].String)
26 with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog:
27 xSearchterm = xDialog.getChild("searchterm")
28 xSearchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
29 xSearchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
30 xSearchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"^."}))
32 xReplaceterm = xDialog.getChild("replaceterm")
33 xReplaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"A"}))
35 xSelectionOnly = xDialog.getChild("selection")
36 xSelectionOnly.executeAction("CLICK", tuple())
38 # Deselect similarity before selecting regex
39 xSimilarity = xDialog.getChild("similarity")
40 if get_state_as_dict(xSimilarity)['Selected'] == 'true':
41 xSimilarity.executeAction("CLICK", tuple())
43 xRegexp = xDialog.getChild("regexp")
44 xRegexp.executeAction("CLICK", tuple())
45 self.assertEqual("true", get_state_as_dict(xRegexp)['Selected'])
47 replaceall = xDialog.getChild("replaceall")
48 replaceall.executeAction("CLICK", tuple())
50 # Deselect regex button, otherwise it might affect other tests
51 xRegexp.executeAction("CLICK", tuple())
52 self.assertEqual("false", get_state_as_dict(xRegexp)['Selected'])
54 # Without the fix in place, this test would have failed with
55 # AssertionError: 'This is a test' != 'This is a AAAA'
56 self.assertEqual("This is a test", document.Text.String)
58 self.assertEqual("test", document.CurrentSelection[0].String)
60 # vim: set shiftwidth=4 softtabstop=4 expandtab: