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 libreoffice
.uno
.propertyvalue
import mkPropertyValues
11 from uitest
.uihelper
.common
import get_state_as_dict
, get_url_for_data_file
13 #Bug 126627 - CRASH: undoing redlinehide deletion
15 class tdf126627(UITestCase
):
16 def test_tdf126627_crash_undo_deletion(self
):
17 with self
.ui_test
.load_file(get_url_for_data_file("tdf126627.odt")) as writer_doc
:
18 xWriterDoc
= self
.xUITest
.getTopFocusWindow()
19 xWriterEdit
= xWriterDoc
.getChild("writer_edit")
20 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button
="close") as xDialog
:
22 searchterm
= xDialog
.getChild("searchterm")
23 searchterm
.executeAction("TYPE", mkPropertyValues({"TEXT":"bar"}))
24 xsearch
= xDialog
.getChild("search")
25 xsearch
.executeAction("CLICK", tuple())
27 #2. Place the cursor before 'bar'
28 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
29 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
30 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
31 #3. Hit backspace 4 times -> Foo and bar are together
32 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
33 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
34 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
35 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
36 self
.assertEqual(writer_doc
.Text
.String
[0:6], "foobar")
38 self
.xUITest
.executeCommand(".uno:Undo")
39 #verify that we have now two words
40 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button
="close") as xDialog
:
41 xselectwords
= xDialog
.getChild("selectwords")
42 self
.assertEqual(get_state_as_dict(xselectwords
)["Text"], "2")
44 # vim: set shiftwidth=4 softtabstop=4 expandtab: