sc/qa/uitest/calc_tests8/tdf125051.py | 38 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-)
New commits: commit 0967050fa77c265ec215d43d5a118a709481787f Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Jul 15 13:27:33 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Jul 15 15:56:23 2024 +0200 tdf#125051: rework and improve uitest The test still fails if f7936b8ccd0ce9bea3a5e780443e4ae8f35b9da1 "tdf#125051: fix spellchecking on Calc" is reverted. Change the test to avoid having the second dialog prompted when launching the spell dialog. The options dialog part is removed because it's not needed for testing the crash Change-Id: I337376dd9ad0f5454534821d259589a9bd68af35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170495 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/uitest/calc_tests8/tdf125051.py b/sc/qa/uitest/calc_tests8/tdf125051.py index 89314b2690e9..c099e2e3d368 100644 --- a/sc/qa/uitest/calc_tests8/tdf125051.py +++ b/sc/qa/uitest/calc_tests8/tdf125051.py @@ -8,6 +8,7 @@ # from uitest.framework import UITestCase from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict from libreoffice.calc.document import get_cell_by_position from libreoffice.uno.propertyvalue import mkPropertyValues @@ -19,21 +20,38 @@ class tdf125051(UITestCase): with self.ui_test.create_doc_in_start_center("calc") as document: xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "text") + enter_text_to_cell(gridwin, "A1", "teext") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - with self.ui_test.execute_dialog_through_command(".uno:SpellDialog"): - pass + with self.ui_test.execute_dialog_through_command(".uno:SpellDialog", close_button="close") as xDialog: + xSentence = xDialog.getChild("sentence") + self.assertEqual("teext", get_state_as_dict(xSentence)['Text']) - xDialog = self.xUITest.getTopFocusWindow() #Spelling dialog - #open options - optionsBtn = xDialog.getChild("options") + xLanguagelb = xDialog.getChild("languagelb") + self.assertEqual("English (USA)", get_state_as_dict(xLanguagelb)["DisplayText"]) - self.ui_test.execute_dialog_through_action(optionsBtn, "CLICK", None, "DialogExecute", "cancel") + xSuggestionslb = xDialog.getChild("suggestionslb") + nSuggestions = len(xSuggestionslb.getChildren()) + self.assertGreaterEqual(nSuggestions, 1) + self.assertEqual("text", get_state_as_dict(xSuggestionslb.getChild("0"))["Text"]) + for i in range(1, nSuggestions): + # Check the first suggestion is not duplicated + self.assertNotEqual("text", get_state_as_dict(xSuggestionslb.getChild(str(i)))["Text"]) - closeBtn = xDialog.getChild("close") #close Spelling dialog - self.ui_test.close_dialog_through_button(closeBtn) + self.assertEqual("true", get_state_as_dict(xSuggestionslb.getChild("0"))["IsSelected"]) - #verify, we didn't crash + for i in range(1, nSuggestions): + self.assertEqual("false", get_state_as_dict(xSuggestionslb.getChild(str(i)))["IsSemiTransparent"]) + + xChangeBtn = xDialog.getChild("change") + + # Without the fix in place, this would have crashed here + with self.ui_test.execute_blocking_action(xChangeBtn.executeAction, args=('CLICK', ())): + pass + + for i in range(nSuggestions): + self.assertEqual("false", get_state_as_dict(xSuggestionslb.getChild(str(i)))["IsSemiTransparent"]) + + #verify it didn't crash and autocorrect worked self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "text")