Debian Codegraph @

sw/qa/uitest/findReplace/tdf144089.py

raw symbols SCIP
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
2 #
3 # This file is part of the LibreOffice project.
4 #
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/.
8 #
9
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
13
14 class tdf144089(UITestCase):
15
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")
20
21 type_text(xWriterEdit, "This is a test")
22 xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "10", "END_POS": "14"}))
23
24 self.assertEqual("test", document.CurrentSelection[0].String)
25
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":"^."}))
31
32 xReplaceterm = xDialog.getChild("replaceterm")
33 xReplaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"A"}))
34
35 xSelectionOnly = xDialog.getChild("selection")
36 xSelectionOnly.executeAction("CLICK", tuple())
37
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())
42
43 xRegexp = xDialog.getChild("regexp")
44 xRegexp.executeAction("CLICK", tuple())
45 self.assertEqual("true", get_state_as_dict(xRegexp)['Selected'])
46
47 replaceall = xDialog.getChild("replaceall")
48 replaceall.executeAction("CLICK", tuple())
49
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'])
53
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)
57
58 self.assertEqual("test", document.CurrentSelection[0].String)
59
60 # vim: set shiftwidth=4 softtabstop=4 expandtab: