sc/qa/uitest/calc_tests6/tdf116996.py |   46 ++++++++++++++--------------------
 1 file changed, 20 insertions(+), 26 deletions(-)

New commits:
commit d0bb675cbf7582cd153ead7806b15d4c22117bb0
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Feb 14 14:27:31 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Feb 14 20:16:09 2023 +0000

    sc: use try/finally to reset the changes in OptionsTreeDialog
    
    Otherwise it might affect other tests if it hits an assert
    
    Change-Id: I460e5cd984d410e4b937cb42be55864fc6b97db7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147012
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/uitest/calc_tests6/tdf116996.py 
b/sc/qa/uitest/calc_tests6/tdf116996.py
index 7e3f4e61c43b..d6b21115c5ac 100644
--- a/sc/qa/uitest/calc_tests6/tdf116996.py
+++ b/sc/qa/uitest/calc_tests6/tdf116996.py
@@ -12,36 +12,30 @@ from uitest.uihelper.common import get_state_as_dict
 #Bug 116996 - Crash recover on selecting Tools -> Options -> Advanced: Enable 
experimental features
 
 class tdf116996(UITestCase):
-    def test_tdf116996_enable_experimental_feature(self):
-        with self.ui_test.create_doc_in_start_center("calc"):
-            with 
self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", 
close_button="") as xDialogOpt:
-                xPages = xDialogOpt.getChild("pages")
-                xLOEntry = xPages.getChild('0')                 # Libreoffice
-                xLOEntry.executeAction("EXPAND", tuple())
-                xAdvancedEntry = xLOEntry.getChild('10')
-                xAdvancedEntry.executeAction("SELECT", tuple())          
#Libreoffice / Advanced
-                xexperimental = xDialogOpt.getChild("experimental")
-                xexperimental.executeAction("CLICK", tuple())          #enable 
experimental features
 
-                xOKBtn = xDialogOpt.getChild("ok")
+    def change_experimental_features(self, enabled):
+        with 
self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", 
close_button="") as xDialogOpt:
+            xPages = xDialogOpt.getChild("pages")
+            xLOEntry = xPages.getChild('0')                 # Libreoffice
+            xLOEntry.executeAction("EXPAND", tuple())
+            xAdvancedEntry = xLOEntry.getChild('10')
+            xAdvancedEntry.executeAction("SELECT", tuple())          
#Libreoffice / Advanced
+            xexperimental = xDialogOpt.getChild("experimental")
+            if get_state_as_dict(xexperimental)['Selected'] != enabled:
+                xexperimental.executeAction("CLICK", tuple())          #enable 
experimental features
 
-                with 
self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), 
close_button="no"):
-                    pass
+            self.assertEqual(get_state_as_dict(xexperimental)["Selected"], 
enabled)
 
-            #reopen options dialog and verify
-            with 
self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", 
close_button="") as xDialogOpt:
-                xPages = xDialogOpt.getChild("pages")
-                xLOEntry = xPages.getChild('0')                 # Libreoffice
-                xLOEntry.executeAction("EXPAND", tuple())
-                xAdvancedEntry = xLOEntry.getChild('10')
-                xAdvancedEntry.executeAction("SELECT", tuple())          
#Libreoffice / Advanced
-                xexperimental = xDialogOpt.getChild("experimental")
+            xOKBtn = xDialogOpt.getChild("ok")
 
-                self.assertEqual(get_state_as_dict(xexperimental)["Selected"], 
"true")
-                xexperimental.executeAction("CLICK", tuple())       #disable 
experimental features
-                xOKBtn = xDialogOpt.getChild("ok")
+            with self.ui_test.execute_blocking_action(xOKBtn.executeAction, 
args=('CLICK', ()), close_button="no"):
+                pass
 
-                with 
self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), 
close_button="no"):
-                    pass
+    def test_tdf116996_enable_experimental_feature(self):
+        with self.ui_test.create_doc_in_start_center("calc"):
+            try:
+                self.change_experimental_features("true")
+            finally:
+                self.change_experimental_features("false")
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:

Reply via email to