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
12 class tdf133348(UITestCase
):
14 def change_author_name(self
, name
):
15 with self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt
:
16 xPages
= xDialogOpt
.getChild("pages")
17 xEntry
= xPages
.getChild('0')
18 xEntry
.executeAction("EXPAND", tuple())
19 xGeneralEntry
= xEntry
.getChild('0')
20 xGeneralEntry
.executeAction("SELECT", tuple())
21 xFirstName
= xDialogOpt
.getChild("firstname")
22 props
= {"TEXT": name
}
23 actionProps
= mkPropertyValues(props
)
24 xFirstName
.executeAction("TYPE", actionProps
)
26 def test_tdf133348(self
):
28 with self
.ui_test
.create_doc_in_start_center("writer") as document
:
31 self
.xUITest
.executeCommand(".uno:SelectAll")
32 xArgs
= mkPropertyValues({"Text": "C1"})
33 self
.xUITest
.executeCommandWithParameters(".uno:InsertAnnotation", xArgs
)
35 self
.change_author_name("Known Author")
37 xArgs
= mkPropertyValues({"Text": "C2"})
38 self
.xUITest
.executeCommandWithParameters(".uno:ReplyComment", xArgs
)
40 # Wait for async events to be processed
41 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
42 xToolkit
.processEventsToIdle()
44 xEnum
= document
.TextFields
.createEnumeration()
45 self
.assertEqual(xEnum
.nextElement().Author
.strip(), 'Unknown Author')
46 self
.assertEqual(xEnum
.nextElement().Author
.strip(), 'Known Author')
48 self
.xUITest
.executeCommand(".uno:Undo")
49 self
.xUITest
.executeCommand(".uno:Undo")
51 # Without the fix in place, it would have crashed here
52 self
.xUITest
.executeCommand(".uno:Undo")
53 self
.xUITest
.executeCommand(".uno:Undo")
55 # all comments have been deleted
56 self
.assertFalse(document
.TextFields
.createEnumeration().hasMoreElements())
58 self
.change_author_name("")
60 # vim: set shiftwidth=4 softtabstop=4 expandtab: