diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-11-03 15:39:35 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-11-04 13:17:44 +0100 |
commit | 01cbdcc6dd0cf575997e9899496115ac41ab4be1 (patch) | |
tree | 6e785918a2e75d0920bed318634e6d8540325f1b | |
parent | c218614ffa95ec62c0a0ad31583282d287042890 (diff) |
tdf#119206: sw: Add UItest
Change-Id: Iaf0e3be8a43eaaa4abb1efff9bc844ff38602d77
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124654
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sw/qa/uitest/writer_tests6/edit_file_properties_before_saving.py (renamed from sw/qa/uitest/writer_tests6/tdf117895.py) | 44 | ||||
-rw-r--r-- | uitest/uitest/test.py | 3 |
2 files changed, 43 insertions, 4 deletions
diff --git a/sw/qa/uitest/writer_tests6/tdf117895.py b/sw/qa/uitest/writer_tests6/edit_file_properties_before_saving.py index 5aa6600a835b..ad30bae45026 100644 --- a/sw/qa/uitest/writer_tests6/tdf117895.py +++ b/sw/qa/uitest/writer_tests6/edit_file_properties_before_saving.py @@ -6,13 +6,14 @@ # from uitest.framework import UITestCase -from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import type_text from libreoffice.uno.propertyvalue import mkPropertyValues from org.libreoffice.unotest import systemPathToFileUrl from tempfile import TemporaryDirectory import os.path -class Tdf117895(UITestCase): +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: @@ -24,7 +25,8 @@ class Tdf117895(UITestCase): xGeneralEntry.executeAction("SELECT", tuple()) xDocInfo = xDialog.getChild("docinfo") - xDocInfo.executeAction("CLICK", tuple()) + if get_state_as_dict(xDocInfo)['Selected'] != enabled: + xDocInfo.executeAction("CLICK", tuple()) self.assertEqual(enabled, get_state_as_dict(xDocInfo)['Selected']) def test_tdf117895(self): @@ -56,4 +58,40 @@ class Tdf117895(UITestCase): # Without the fix in place, this test would have failed here self.assertTrue(doc2.isReadonly()) + def test_tdf119206(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "tdf119206-temp.odt") + + 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']) + + 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: diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py index 9a15671223b9..3beee0d274f2 100644 --- a/uitest/uitest/test.py +++ b/uitest/uitest/test.py @@ -159,7 +159,8 @@ class UITest(object): try: yield xDialog finally: - self.close_dialog_through_button(xDialog.getChild(close_button)) + if close_button: + self.close_dialog_through_button(xDialog.getChild(close_button)) return time_ += DEFAULT_SLEEP time.sleep(DEFAULT_SLEEP) |