diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-02-13 11:42:56 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-02-13 11:39:50 +0000 |
commit | 835f87280ab228f59801c28c288472f2941ea222 (patch) | |
tree | 95398371c7955f630fe047c650214517dc997071 | |
parent | 00f6c36b603416b73e1327ac4c862b1eaca2d277 (diff) |
sc: use try/finally to reset the changes in OptionsTreeDialog
Otherwise it might affect other tests if it hits an assert
Change-Id: Iee86221cc7b4bd66fc19dc63b162d72aacec5016
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146874
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sc/qa/uitest/calc_tests7/tdf150288.py | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/sc/qa/uitest/calc_tests7/tdf150288.py b/sc/qa/uitest/calc_tests7/tdf150288.py index e6ec3ed69329..951cb7349a6e 100644 --- a/sc/qa/uitest/calc_tests7/tdf150288.py +++ b/sc/qa/uitest/calc_tests7/tdf150288.py @@ -16,38 +16,43 @@ from uitest.uihelper.common import select_by_text class tdf150288(UITestCase): - def test_tdf150288(self): + def change_date_pattern(self, pattern): + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog: + xPages = xDialog.getChild("pages") + xLanguageEntry = xPages.getChild('2') + xLanguageEntry.executeAction("EXPAND", tuple()) + xxLanguageEntryGeneralEntry = xLanguageEntry.getChild('0') + xxLanguageEntryGeneralEntry.executeAction("SELECT", tuple()) - with self.ui_test.create_doc_in_start_center("calc") as document: + xDatePatterns = xDialog.getChild("datepatterns") + xLocaleSetting = xDialog.getChild("localesetting") - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog: - xPages = xDialog.getChild("pages") - xLanguageEntry = xPages.getChild('2') - xLanguageEntry.executeAction("EXPAND", tuple()) - xxLanguageEntryGeneralEntry = xLanguageEntry.getChild('0') - xxLanguageEntryGeneralEntry.executeAction("SELECT", tuple()) + select_by_text(xLocaleSetting, "English (USA)") - xDatePatterns = xDialog.getChild("datepatterns") - xLocaleSetting = xDialog.getChild("localesetting") + xDatePatterns.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xDatePatterns.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xDatePatterns.executeAction("TYPE", mkPropertyValues({"TEXT": pattern})) - select_by_text(xLocaleSetting, "English (USA)") + def test_tdf150288(self): + with self.ui_test.create_doc_in_start_center("calc") as document: - self.assertEqual("M/D/Y;M/D", get_state_as_dict(xDatePatterns)['Text']) + try: + self.change_date_pattern("D/M/Y;D/M") - xDatePatterns.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xDatePatterns.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xDatePatterns.executeAction("TYPE", mkPropertyValues({"TEXT":"D/M/Y;D/M"})) + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(xGridWin, "A1", "31/8/22") + enter_text_to_cell(xGridWin, "A2", "1/8/22") - enter_text_to_cell(xGridWin, "A1", "31/8/22") - enter_text_to_cell(xGridWin, "A2", "1/8/22") + self.assertEqual("08/31/22", get_cell_by_position(document, 0, 0, 0).getString()) - self.assertEqual("08/31/22", get_cell_by_position(document, 0, 0, 0).getString()) + # Without the fix in place, this test would have failed with + # AssertionError: '08/01/22' != '01/08/22' + self.assertEqual("08/01/22", get_cell_by_position(document, 0, 0, 1).getString()) - # Without the fix in place, this test would have failed with - # AssertionError: '08/01/22' != '01/08/22' - self.assertEqual("08/01/22", get_cell_by_position(document, 0, 0, 1).getString()) + finally: + # reset date pattern to default + self.change_date_pattern("M/D/Y;M/D") # vim: set shiftwidth=4 softtabstop=4 expandtab: |