sw/qa/uitest/writer_tests6/edit_file_properties_before_saving.py |   83 
+++++-----
 1 file changed, 42 insertions(+), 41 deletions(-)

New commits:
commit 3ac5bfec2f73c55e99c4410f7559db86b875a269
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Jan 31 11:39:42 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jan 31 14:23:18 2023 +0000

    uitest: Always change doc info setting back to false
    
    otherwise it won't be changed if an exception is raised
    affering other tests as seen in
    
https://gerrit.libreoffice.org/c/core/+/130530/2/sw/qa/uitest/writer_tests6/save_readonly_with_password.py#50
    
    Change-Id: Ife443cc6627025a05a0a33ba1c86140f087dd70c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146385
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/uitest/writer_tests6/edit_file_properties_before_saving.py 
b/sw/qa/uitest/writer_tests6/edit_file_properties_before_saving.py
index 746d9a75075c..0df0dc504dde 100644
--- a/sw/qa/uitest/writer_tests6/edit_file_properties_before_saving.py
+++ b/sw/qa/uitest/writer_tests6/edit_file_properties_before_saving.py
@@ -19,7 +19,6 @@ class edit_file_properties_before_saving(UITestCase):
 
     def change_doc_info_setting(self, enabled):
         with 
self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as 
xDialog:
-
             xPages = xDialog.getChild("pages")
             xLoadSaveEntry = xPages.getChild('1')
             xLoadSaveEntry.executeAction("EXPAND", tuple())
@@ -38,27 +37,28 @@ class edit_file_properties_before_saving(UITestCase):
 
             with self.ui_test.create_doc_in_start_center("writer"):
 
-                self.change_doc_info_setting("true")
+                try:
+                    self.change_doc_info_setting("true")
 
-                # Save Copy as
-                with 
self.ui_test.execute_dialog_through_command('.uno:SaveAs', close_button="") as 
xDialog:
-                    xFileName = xDialog.getChild('file_name')
-                    xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'CTRL+A'}))
-                    xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'BACKSPACE'}))
-                    xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': 
xFilePath}))
+                    # Save Copy as
+                    with 
self.ui_test.execute_dialog_through_command('.uno:SaveAs', close_button="") as 
xDialog:
+                        xFileName = xDialog.getChild('file_name')
+                        xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'CTRL+A'}))
+                        xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'BACKSPACE'}))
+                        xFileName.executeAction('TYPE', 
mkPropertyValues({'TEXT': xFilePath}))
 
-                    xOpen = xDialog.getChild("open")
-                    with self.ui_test.execute_dialog_through_action(xOpen, 
"CLICK") as xPropertiesDialog:
-                        xReadOnly = xPropertiesDialog.getChild("readonly")
-                        xReadOnly.executeAction("CLICK", tuple())
-                        self.assertEqual("true", 
get_state_as_dict(xReadOnly)['Selected'])
+                        xOpen = xDialog.getChild("open")
+                        with self.ui_test.execute_dialog_through_action(xOpen, 
"CLICK") as xPropertiesDialog:
+                            xReadOnly = xPropertiesDialog.getChild("readonly")
+                            xReadOnly.executeAction("CLICK", tuple())
+                            self.assertEqual("true", 
get_state_as_dict(xReadOnly)['Selected'])
+                finally:
+                    # Put this setting back to false, otherwise it might 
affect other tests
+                    self.change_doc_info_setting("false")
 
             self.ui_test.wait_until_file_is_available(xFilePath)
 
             with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
doc2:
-
-                self.change_doc_info_setting("false")
-
                 # Without the fix in place, this test would have failed here
                 self.assertTrue(doc2.isReadonly())
 
@@ -69,35 +69,36 @@ class edit_file_properties_before_saving(UITestCase):
 
             with self.ui_test.create_doc_in_start_center("writer"):
 
-                self.change_doc_info_setting("true")
-
-                xWriterDoc = self.xUITest.getTopFocusWindow()
-                xWriterEdit = xWriterDoc.getChild("writer_edit")
-                type_text(xWriterEdit, "XXXX")
-
-                # Close document and save
-                with 
self.ui_test.execute_dialog_through_command('.uno:CloseDoc', close_button="") 
as xConfirmationDialog:
-                    xSave = xConfirmationDialog.getChild("save")
-
-                    with self.ui_test.execute_dialog_through_action(xSave, 
"CLICK", close_button="") as xDialog:
-                        xFileName = xDialog.getChild('file_name')
-                        xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'CTRL+A'}))
-                        xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'BACKSPACE'}))
-                        xFileName.executeAction('TYPE', 
mkPropertyValues({'TEXT': xFilePath}))
-
-                        xOpen = xDialog.getChild("open")
-                        with self.ui_test.execute_dialog_through_action(xOpen, 
"CLICK") as xPropertiesDialog:
-                            # Without the fix in place, this test would have 
crashed here
-                            xReadOnly = xPropertiesDialog.getChild("readonly")
-                            xReadOnly.executeAction("CLICK", tuple())
-                            self.assertEqual("true", 
get_state_as_dict(xReadOnly)['Selected'])
+                try:
+                    self.change_doc_info_setting("true")
+
+                    xWriterDoc = self.xUITest.getTopFocusWindow()
+                    xWriterEdit = xWriterDoc.getChild("writer_edit")
+                    type_text(xWriterEdit, "XXXX")
+
+                    # Close document and save
+                    with 
self.ui_test.execute_dialog_through_command('.uno:CloseDoc', close_button="") 
as xConfirmationDialog:
+                        xSave = xConfirmationDialog.getChild("save")
+
+                        with self.ui_test.execute_dialog_through_action(xSave, 
"CLICK", close_button="") as xDialog:
+                            xFileName = xDialog.getChild('file_name')
+                            xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'CTRL+A'}))
+                            xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'BACKSPACE'}))
+                            xFileName.executeAction('TYPE', 
mkPropertyValues({'TEXT': xFilePath}))
+
+                            xOpen = xDialog.getChild("open")
+                            with 
self.ui_test.execute_dialog_through_action(xOpen, "CLICK") as xPropertiesDialog:
+                                # Without the fix in place, this test would 
have crashed here
+                                xReadOnly = 
xPropertiesDialog.getChild("readonly")
+                                xReadOnly.executeAction("CLICK", tuple())
+                                self.assertEqual("true", 
get_state_as_dict(xReadOnly)['Selected'])
+                finally:
+                    # Put this setting back to false, otherwise it might 
affect other tests
+                    self.change_doc_info_setting("false")
 
             self.ui_test.wait_until_file_is_available(xFilePath)
 
             with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
doc2:
-
-                self.change_doc_info_setting("false")
-
                 self.assertTrue(doc2.isReadonly())
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:

Reply via email to