summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-02-13 11:49:29 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2023-02-13 12:48:31 +0000
commit4beaa92bc2c91e7ff84b044469d376216efec2fe (patch)
tree0a20786b4bf8677b0870b8197edc685e9df134a0
parent22850e8d281d17575c01321cfff9e1ad2201ffb5 (diff)
sw: use try/finally to reset the changes in OptionsTreeDialog
Otherwise it might affect other tests if it hits an assert Change-Id: Iee4ee4964640114126c2ec404df567598668ed99 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146894 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sw/qa/uitest/writer_tests7/tdf133348.py77
1 files changed, 42 insertions, 35 deletions
diff --git a/sw/qa/uitest/writer_tests7/tdf133348.py b/sw/qa/uitest/writer_tests7/tdf133348.py
index 417dedeb6aa9..100f26cbd741 100644
--- a/sw/qa/uitest/writer_tests7/tdf133348.py
+++ b/sw/qa/uitest/writer_tests7/tdf133348.py
@@ -10,44 +10,51 @@ from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
class tdf133348(UITestCase):
+
+ def change_author_name(self, name):
+ with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt:
+ xPages = xDialogOpt.getChild("pages")
+ xEntry = xPages.getChild('0')
+ xEntry.executeAction("EXPAND", tuple())
+ xGeneralEntry = xEntry.getChild('0')
+ xGeneralEntry.executeAction("SELECT", tuple())
+ xFirstName = xDialogOpt.getChild("firstname")
+ props = {"TEXT": name}
+ actionProps = mkPropertyValues(props)
+ xFirstName.executeAction("TYPE", actionProps)
+
def test_tdf133348(self):
with self.ui_test.create_doc_in_start_center("writer") as document:
- self.xUITest.executeCommand(".uno:SelectAll")
- xArgs = mkPropertyValues({"Text": "C1"})
- self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs)
-
- with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt:
- xPages = xDialogOpt.getChild("pages")
- xEntry = xPages.getChild('0')
- xEntry.executeAction("EXPAND", tuple())
- xGeneralEntry = xEntry.getChild('0')
- xGeneralEntry.executeAction("SELECT", tuple())
- xFirstName = xDialogOpt.getChild("firstname")
- props = {"TEXT": "Known Author"}
- actionProps = mkPropertyValues(props)
- xFirstName.executeAction("TYPE", actionProps)
-
- xArgs = mkPropertyValues({"Text": "C2"})
- self.xUITest.executeCommandWithParameters(".uno:ReplyComment", xArgs)
-
- # Wait for async events to be processed
- xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
- xToolkit.processEventsToIdle()
-
- xEnum = document.TextFields.createEnumeration()
- self.assertEqual(xEnum.nextElement().Author.strip(), 'Unknown Author')
- self.assertEqual(xEnum.nextElement().Author.strip(), 'Known Author')
-
- self.xUITest.executeCommand(".uno:Undo")
- self.xUITest.executeCommand(".uno:Undo")
-
- # Without the fix in place, it would have crashed here
- self.xUITest.executeCommand(".uno:Undo")
- self.xUITest.executeCommand(".uno:Undo")
-
- # all comments have been deleted
- self.assertFalse(document.TextFields.createEnumeration().hasMoreElements())
+ try:
+ self.xUITest.executeCommand(".uno:SelectAll")
+ xArgs = mkPropertyValues({"Text": "C1"})
+ self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs)
+
+ self.change_author_name("Known Author")
+
+ xArgs = mkPropertyValues({"Text": "C2"})
+ self.xUITest.executeCommandWithParameters(".uno:ReplyComment", xArgs)
+
+ # Wait for async events to be processed
+ xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+ xToolkit.processEventsToIdle()
+
+ xEnum = document.TextFields.createEnumeration()
+ self.assertEqual(xEnum.nextElement().Author.strip(), 'Unknown Author')
+ self.assertEqual(xEnum.nextElement().Author.strip(), 'Known Author')
+
+ self.xUITest.executeCommand(".uno:Undo")
+ self.xUITest.executeCommand(".uno:Undo")
+
+ # Without the fix in place, it would have crashed here
+ self.xUITest.executeCommand(".uno:Undo")
+ self.xUITest.executeCommand(".uno:Undo")
+
+ # all comments have been deleted
+ self.assertFalse(document.TextFields.createEnumeration().hasMoreElements())
+ finally:
+ self.change_author_name("")
# vim: set shiftwidth=4 softtabstop=4 expandtab: