From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- .../writer_tests5/DateFormFieldPropertiesDialog.py | 164 ++++++++++++ .../DropDownFormFieldPropertiesDialog.py | 275 +++++++++++++++++++++ sw/qa/uitest/writer_tests5/about_test.py | 25 ++ sw/qa/uitest/writer_tests5/autocorrectOptions.py | 94 +++++++ sw/qa/uitest/writer_tests5/columns.py | 71 ++++++ sw/qa/uitest/writer_tests5/tdf107494.py | 93 +++++++ sw/qa/uitest/writer_tests5/tdf117039.py | 34 +++ sw/qa/uitest/writer_tests5/tdf118540.py | 41 +++ sw/qa/uitest/writer_tests5/tdf121591.py | 41 +++ sw/qa/uitest/writer_tests5/tdf122722.py | 76 ++++++ sw/qa/uitest/writer_tests5/tdf123378.py | 27 ++ sw/qa/uitest/writer_tests5/tdf123446.py | 46 ++++ sw/qa/uitest/writer_tests5/titlePage.py | 43 ++++ sw/qa/uitest/writer_tests5/xwindow.py | 179 ++++++++++++++ sw/qa/uitest/writer_tests5/zoom.py | 107 ++++++++ 15 files changed, 1316 insertions(+) create mode 100644 sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py create mode 100644 sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py create mode 100644 sw/qa/uitest/writer_tests5/about_test.py create mode 100644 sw/qa/uitest/writer_tests5/autocorrectOptions.py create mode 100644 sw/qa/uitest/writer_tests5/columns.py create mode 100644 sw/qa/uitest/writer_tests5/tdf107494.py create mode 100644 sw/qa/uitest/writer_tests5/tdf117039.py create mode 100644 sw/qa/uitest/writer_tests5/tdf118540.py create mode 100644 sw/qa/uitest/writer_tests5/tdf121591.py create mode 100644 sw/qa/uitest/writer_tests5/tdf122722.py create mode 100644 sw/qa/uitest/writer_tests5/tdf123378.py create mode 100644 sw/qa/uitest/writer_tests5/tdf123446.py create mode 100644 sw/qa/uitest/writer_tests5/titlePage.py create mode 100644 sw/qa/uitest/writer_tests5/xwindow.py create mode 100644 sw/qa/uitest/writer_tests5/zoom.py (limited to 'sw/qa/uitest/writer_tests5') diff --git a/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py b/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py new file mode 100644 index 000000000..0a32863d6 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py @@ -0,0 +1,164 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +import time + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class dateFormFieldDialog(UITestCase): + + def test_setting_date_format(self): + # open a file with a date form field + writer_doc = self.ui_test.load_file(get_url_for_data_file("date_form_field.odt")) + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("date_formats_treeview") + + # check whether we have the right format selected + self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/31/99") + + # select a new format + itemsList.getChild("11").executeAction("SELECT", tuple()); + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # open the dialog again + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + itemsList = xDialog.getChild("date_formats_treeview") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + + def test_date_field_with_custom_format(self): + # open a file with a date form field + writer_doc = self.ui_test.load_file(get_url_for_data_file("date_form_field_custom_format.odt")) + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("date_formats_treeview") + + # check whether we have the right format selected + self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "1999. december 31., péntek") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + + def test_date_reformat(self): + # open a file with a date form field + writer_doc = self.ui_test.load_file(get_url_for_data_file("date_form_field.odt")) + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + self.assertEqual(writer_doc.getText().getString(), "07/17/19") + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("date_formats_treeview") + + # check whether we have the right format selected + self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/31/99") + + # select a new format + itemsList.getChild("11").executeAction("SELECT", tuple()); + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # after applying the new format, the field content should be updated + self.assertEqual(writer_doc.getText().getString(), "07-17") + + self.ui_test.close_doc() + + def test_date_field_with_placeholder(self): + # open a file with a date form field + writer_doc = self.ui_test.load_file(get_url_for_data_file("date_form_field_with_placeholder.odt")) + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + self.assertEqual(writer_doc.getText().getString(), "[select date]") + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("date_formats_treeview") + + # check whether we have the right format selected + self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "Fri 31/Dec 99") + + # select a new format + itemsList.getChild("11").executeAction("SELECT", tuple()); + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # a placeholder text is not changed by format change + self.assertEqual(writer_doc.getText().getString(), "[select date]") + + self.ui_test.close_doc() + + def test_date_field_without_current_date(self): + # current date means the current date fieldmark parameter which contains the current date in YYYY-MM-DD format + # when this parameter is missing LO tries to parse the content string to find out the set date + + # open a file with a date form field + writer_doc = self.ui_test.load_file(get_url_for_data_file("date_form_field_without_current_date.odt")) + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + self.assertEqual(writer_doc.getText().getString(), "07/17/19") + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("date_formats_treeview") + + # check whether we have the right format selected + self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/31/99") + + # select a new format + itemsList.getChild("3").executeAction("SELECT", tuple()); + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "Dec 31, 1999") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # a placeholder text is not changed by format change + self.assertEqual(writer_doc.getText().getString(), "Jul 17, 2019") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py b/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py new file mode 100644 index 000000000..08797d9bb --- /dev/null +++ b/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py @@ -0,0 +1,275 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +import time + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class dropDownFormFieldDialog(UITestCase): + + def test_add_new_items(self): + + # open a file with an empty form field + writer_doc = self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemEntry = xDialog.getChild("item_entry") + addButton = xDialog.getChild("add_button") + itemsList = xDialog.getChild("items_treeview") + + # initial state + self.assertEqual(get_state_as_dict(itemEntry)["Text"], "") + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") + + # add some new items + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"1000"})) + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "true") + addButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"2000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"3000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"4000"})) + addButton.executeAction("CLICK", tuple()) + + # check whether the items are there in the list + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # check whether items are the same after reopening + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("items_treeview") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + + def test_remove_items(self): + + # open a file with an empty form field + writer_doc = self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemEntry = xDialog.getChild("item_entry") + addButton = xDialog.getChild("add_button") + itemsList = xDialog.getChild("items_treeview") + removeButton = xDialog.getChild("remove_button") + + # initial state + self.assertEqual(get_state_as_dict(itemEntry)["Text"], "") + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") + self.assertEqual(get_state_as_dict(removeButton)["Enabled"], "false") + + # add some new items + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"1000"})) + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "true") + addButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(removeButton)["Enabled"], "true") + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"2000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"3000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"4000"})) + addButton.executeAction("CLICK", tuple()) + + # check whether the items are there in the list + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") + + # select an item from the list and remove it + itemsList.getChild("1").executeAction("SELECT", tuple()); + removeButton.executeAction("CLICK", tuple()) + + # check whether the right item was removed + self.assertEqual(get_state_as_dict(itemsList)["Children"], "3") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # check whether items are the same after reopening + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("items_treeview") + removeButton = xDialog.getChild("remove_button") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "3") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") + + # remove all items + itemsList.getChild("1").executeAction("SELECT", tuple()); + removeButton.executeAction("CLICK", tuple()) + removeButton.executeAction("CLICK", tuple()) + removeButton.executeAction("CLICK", tuple()) + + self.assertEqual(get_state_as_dict(removeButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + + def test_move_items(self): + + # open a file with an empty form field + writer_doc = self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemEntry = xDialog.getChild("item_entry") + addButton = xDialog.getChild("add_button") + itemsList = xDialog.getChild("items_treeview") + upButton = xDialog.getChild("up_button") + downButton = xDialog.getChild("down_button") + + # initial state + self.assertEqual(get_state_as_dict(itemEntry)["Text"], "") + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") + self.assertEqual(get_state_as_dict(upButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(downButton)["Enabled"], "false") + + # add some new items + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"1000"})) + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "true") + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"2000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"3000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"4000"})) + addButton.executeAction("CLICK", tuple()) + + # check whether the items are there in the list + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") + + # select an item from the list and move it up + itemsList.getChild("1").executeAction("SELECT", tuple()) + self.assertEqual(get_state_as_dict(upButton)["Enabled"], "true") + self.assertEqual(get_state_as_dict(downButton)["Enabled"], "true") + upButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(upButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(downButton)["Enabled"], "true") + + # check whether the item was correctly moved + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") + + # move down the selected item + downButton.executeAction("CLICK", tuple()) + downButton.executeAction("CLICK", tuple()) + downButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(upButton)["Enabled"], "true") + self.assertEqual(get_state_as_dict(downButton)["Enabled"], "false") + + # check whether the item was correctly moved + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "2000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # check whether items are the same after reopening + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("items_treeview") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "2000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + + def test_drop_down_after_import(self): + + files = ["drop_down_form_field.odt", "drop_down_form_field.doc", "drop_down_form_field.docx"] + for file in files: + # open a file with a drop-down for field with items and selection + writer_doc = self.ui_test.load_file(get_url_for_data_file(file)) + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("items_treeview") + + # check whether the items are there in the list + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") + + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "3000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/about_test.py b/sw/qa/uitest/writer_tests5/about_test.py new file mode 100644 index 000000000..7005dbb65 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/about_test.py @@ -0,0 +1,25 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase + +class AboutDlgTest(UITestCase): + + def test_about_dlg(self): + + self.ui_test.create_doc_in_start_center("writer") + + self.ui_test.execute_dialog_through_command(".uno:About") + + xAboutDlg = self.xUITest.getTopFocusWindow() + + xCloseBtn = xAboutDlg.getChild("btnClose") + self.ui_test.close_dialog_through_button(xCloseBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/autocorrectOptions.py b/sw/qa/uitest/writer_tests5/autocorrectOptions.py new file mode 100644 index 000000000..55d4b382c --- /dev/null +++ b/sw/qa/uitest/writer_tests5/autocorrectOptions.py @@ -0,0 +1,94 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict +import time +from uitest.debug import sleep +from uitest.uihelper.common import select_pos + +class autocorrectOptions(UITestCase): + + def test_autocorrect_options_writer(self): + self.ui_test.create_doc_in_start_center("writer") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab replace + origtext = xDialog.getChild("origtext") + newtext = xDialog.getChild("newtext") + xnew = xDialog.getChild("new") + xdelete = xDialog.getChild("delete") + xtabview = xDialog.getChild("tabview") + xreset = xDialog.getChild("reset") + nrRows = get_state_as_dict(xtabview)["VisibleCount"] + + #add new rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xnew.executeAction("CLICK", tuple()) + nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"] + nrRowsDiff = int(nrRowsNew) - int(nrRows) + self.assertEqual(nrRowsDiff, 1) #we have +1 rule + #delete rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xdelete.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules + + select_pos(xTabs, "1") #tab Exceptions + #abbreviations + abbrev = xDialog.getChild("abbrev") + newabbrev = xDialog.getChild("newabbrev") + delabbrev = xDialog.getChild("delabbrev") + abbrevlist = xDialog.getChild("abbrevlist") + + nrRowsAbb = get_state_as_dict(abbrevlist)["Children"] + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"})) + newabbrev.executeAction("CLICK", tuple()) + nrRowsAbbNew = get_state_as_dict(abbrevlist)["Children"] + nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) + self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule + delabbrev.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(abbrevlist)["Children"], nrRowsAbb) #we have default nr of rules + + #words with two initial capitals + double = xDialog.getChild("double") + newdouble = xDialog.getChild("newdouble") + deldouble = xDialog.getChild("deldouble") + doublelist = xDialog.getChild("doublelist") + + nrRowsDouble = get_state_as_dict(doublelist)["Children"] + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"})) + newdouble.executeAction("CLICK", tuple()) + nrRowsDoubleNew = get_state_as_dict(doublelist)["Children"] + nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and + self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule + deldouble.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(doublelist)["Children"], nrRowsDouble) #we have default nr of rules + + xCancelButton = xDialog.getChild("cancel") + xCancelButton.executeAction("CLICK", tuple()) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/columns.py b/sw/qa/uitest/writer_tests5/columns.py new file mode 100644 index 000000000..f2a9fe6bc --- /dev/null +++ b/sw/qa/uitest/writer_tests5/columns.py @@ -0,0 +1,71 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from uitest.debug import sleep +from libreoffice.uno.propertyvalue import mkPropertyValues +#uitest sw / Columns dialog + +class columns(UITestCase): + def test_columns(self): + writer_doc = self.ui_test.create_doc_in_start_center("writer") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + #set cm + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialog = self.xUITest.getTopFocusWindow() + + xPages = xDialog.getChild("pages") + xWriterEntry = xPages.getChild('3') # Writer + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General + xMetric = xDialog.getChild("metric") + props = {"TEXT": "Centimeter"} + actionProps = mkPropertyValues(props) + xMetric.executeAction("SELECT", actionProps) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #dialog Columns + self.ui_test.execute_dialog_through_command(".uno:FormatColumns") + xDialog = self.xUITest.getTopFocusWindow() + + colsnf = xDialog.getChild("colsnf") + colsnf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + colsnf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + colsnf.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + colsnf.executeAction("UP", tuple()) + colsnf.executeAction("DOWN", tuple()) + spacing1mf = xDialog.getChild("spacing1mf") + spacing1mf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + spacing1mf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + spacing1mf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + autowidth = xDialog.getChild("autowidth") + autowidth.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.ui_test.execute_dialog_through_command(".uno:FormatColumns") + xDialog = self.xUITest.getTopFocusWindow() + colsnf = xDialog.getChild("colsnf") + spacing1mf = xDialog.getChild("spacing1mf") + autowidth = xDialog.getChild("autowidth") + + self.assertEqual(get_state_as_dict(colsnf)["Text"], "2") + self.assertEqual(get_state_as_dict(spacing1mf)["Text"], "1.00 cm") + self.assertEqual(get_state_as_dict(autowidth)["Selected"], "false") + xOKBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf107494.py b/sw/qa/uitest/writer_tests5/tdf107494.py new file mode 100644 index 000000000..0828e26bf --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf107494.py @@ -0,0 +1,93 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.debug import sleep +from uitest.path import get_srcdir_url + +def get_url_for_data_file(file_name): + return get_srcdir_url() + "/sw/qa/uitest/writer_tests/data/" + file_name + +#Bug 107494 - CRASH: LibreOffice crashes while deleting the header containing an image + +class tdf107494(UITestCase): + def test_tdf107494_delete_header_with_image(self): + writer_doc = self.ui_test.create_doc_in_start_center("writer") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert header + self.assertEqual(document.StyleFamilies.PageStyles.Standard.HeaderIsOn, False) + self.xUITest.executeCommand(".uno:InsertPageHeader?PageStyle:string=Default%20Page%20Style&On:bool=true") + self.assertEqual(document.StyleFamilies.PageStyles.Standard.HeaderIsOn, True) + #insert image + text = document.getText() + cursor = text.createTextCursor() + oStyleFamilies = document.getStyleFamilies() + #https://forum.openoffice.org/en/forum/viewtopic.php?f=7&t=71227 + obj2 = oStyleFamilies.getByName("PageStyles") + obj3 = obj2.getByName("Standard") + oHeaderText = obj3.HeaderText + oHeaderText.setString("New text for header") #write text to header + obj4 = oHeaderText.createTextCursor() + text = obj4.getText() + cursor = text.createTextCursor() + + textGraphic = document.createInstance('com.sun.star.text.TextGraphicObject') + provider = self.xContext.ServiceManager.createInstance('com.sun.star.graphic.GraphicProvider') + graphic = provider.queryGraphic( mkPropertyValues({"URL": get_url_for_data_file("LibreOffice_external_logo_100px.png")})) + textGraphic.Graphic = graphic + text.insertTextContent(cursor, textGraphic, False) + # Delete the header + self.ui_test.execute_dialog_through_command(".uno:InsertPageHeader?PageStyle:string=Default%20Page%20Style&On:bool=false") + xDialog = self.xUITest.getTopFocusWindow() #question dialog + xOption = xDialog.getChild("yes") + xOption.executeAction("CLICK", tuple()) + + self.assertEqual(document.StyleFamilies.PageStyles.Standard.HeaderIsOn, False) + + self.ui_test.close_doc() + + def test_tdf107494_delete_footer_with_image(self): + writer_doc = self.ui_test.create_doc_in_start_center("writer") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert footer + self.assertEqual(document.StyleFamilies.PageStyles.Standard.FooterIsOn, False) + self.xUITest.executeCommand(".uno:InsertPageFooter?PageStyle:string=Default%20Page%20Style&On:bool=true") + self.assertEqual(document.StyleFamilies.PageStyles.Standard.FooterIsOn, True) + #insert image + text = document.getText() + cursor = text.createTextCursor() + oStyleFamilies = document.getStyleFamilies() + #https://forum.openoffice.org/en/forum/viewtopic.php?f=7&t=71227 + obj2 = oStyleFamilies.getByName("PageStyles") + obj3 = obj2.getByName("Standard") + oFooterText = obj3.FooterText + oFooterText.setString("New text for footer") #write text to footer + obj4 = oFooterText.createTextCursor() + text = obj4.getText() + cursor = text.createTextCursor() + + textGraphic = document.createInstance('com.sun.star.text.TextGraphicObject') + provider = self.xContext.ServiceManager.createInstance('com.sun.star.graphic.GraphicProvider') + graphic = provider.queryGraphic( mkPropertyValues({"URL": get_url_for_data_file("LibreOffice_external_logo_100px.png")})) + textGraphic.Graphic = graphic + text.insertTextContent(cursor, textGraphic, False) + # Delete the footer + self.ui_test.execute_dialog_through_command(".uno:InsertPageFooter?PageStyle:string=Default%20Page%20Style&On:bool=false") + xDialog = self.xUITest.getTopFocusWindow() #question dialog + xOption = xDialog.getChild("yes") + xOption.executeAction("CLICK", tuple()) + + self.assertEqual(document.StyleFamilies.PageStyles.Standard.FooterIsOn, False) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf117039.py b/sw/qa/uitest/writer_tests5/tdf117039.py new file mode 100644 index 000000000..9045f71c9 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf117039.py @@ -0,0 +1,34 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 117039 - Print Preview crashes on signed document + +class tdf117039(UITestCase): + def test_tdf117039_preview_signed_document(self): + writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf117039.odt")) + document = self.ui_test.get_component() + self.xUITest.executeCommand(".uno:PrintPreview") #open print preview + self.xUITest.executeCommand(".uno:ClosePreview") # close print preview + + self.xUITest.getTopFocusWindow() #Get focus after closing preview + + #verify + self.assertEqual(document.Text.String[0:22], "Test digital signature") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf118540.py b/sw/qa/uitest/writer_tests5/tdf118540.py new file mode 100644 index 000000000..9b8b34fa3 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf118540.py @@ -0,0 +1,41 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict +from uitest.debug import sleep +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 118540 - LO6.1b2: DOCX crashes when properties are opened in print preview mode + +class tdf118540(UITestCase): + def test_tdf118540_preview_document_properties(self): + # FIXME flaky test, usually passes, but breaks regularly. + return + writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf118540.docx")) + document = self.ui_test.get_component() + self.xUITest.executeCommand(".uno:PrintPreview") #open print preview + self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") #open properties dialog + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + self.xUITest.executeCommand(".uno:ClosePreview") # close print preview + + self.xUITest.getTopFocusWindow() #Get focus after closing preview + + #verify + self.assertEqual(document.Text.String[0:4], "Test") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf121591.py b/sw/qa/uitest/writer_tests5/tdf121591.py new file mode 100644 index 000000000..df6deac65 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf121591.py @@ -0,0 +1,41 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +import time +from uitest.uihelper.common import get_state_as_dict, type_text +from uitest.debug import sleep +from uitest.uihelper.common import select_pos +#Bug 121591 - CRASH: Print Preview fails if cursor inside Floating frame +class tdf121591(UITestCase): + + def test_tdf121591_frame_print_preview(self): + # FIXME unstable test + return + self.ui_test.create_doc_in_start_center("writer") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + self.ui_test.execute_dialog_through_command(".uno:InsertFrame") # insert frame + xDialogFr = self.xUITest.getTopFocusWindow() + + xOkBtn=xDialogFr.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + type_text(xWriterEdit, "Text in the frame") + #open and close print preview + self.xUITest.executeCommand(".uno:PrintPreview") #open print preview + self.xUITest.executeCommand(".uno:ClosePreview") # close print preview + + self.xUITest.getTopFocusWindow() #Get focus after closing preview + + #verify nr. of frames + self.assertEqual(document.TextFrames.getCount(), 1) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf122722.py b/sw/qa/uitest/writer_tests5/tdf122722.py new file mode 100644 index 000000000..cbc46e09c --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf122722.py @@ -0,0 +1,76 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, type_text +import time +from uitest.debug import sleep +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +#Bug 122722 - Hiding characters will crash. Crash in: SwAttrIter::CtorInitAttrIter(SwTextNode &,SwScriptInfo &,SwTextFrame const *) + +class tdf122722(UITestCase): + def test_tdf122722_format_character_hidden(self): + self.ui_test.create_doc_in_start_center("writer") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #1. Start LibreOffice + #2. Create New Writer Document + #3. Type "LibreOffice" in Writer + type_text(xWriterEdit, "LibreOffice") + #4. Select "LibreOffice" with mouse, and right click + self.xUITest.executeCommand(".uno:SelectAll") + self.assertEqual(document.Text.String[0:11], "LibreOffice") + #5. Appear Context Menu, Character -> Character + #6. Opened Character, Select "Font Effect" tab + #7. Check Hidden, and click [OK] + #8. Crash a LibreOffice + self.ui_test.execute_dialog_through_command(".uno:FontDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + + xEffects = xDialog.getChild("effectslb") + xRelief = xDialog.getChild("relieflb") + xHidden = xDialog.getChild("hiddencb") + xOverline = xDialog.getChild("overlinelb") + xStrikeout = xDialog.getChild("strikeoutlb") + xUnderline = xDialog.getChild("underlinelb") + xEmphasis = xDialog.getChild("emphasislb") + xPosition = xDialog.getChild("positionlb") + + xHidden.executeAction("CLICK", tuple()) + + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #un-hidden + self.ui_test.execute_dialog_through_command(".uno:FontDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + + xEffects = xDialog.getChild("effectslb") + xRelief = xDialog.getChild("relieflb") + xHidden = xDialog.getChild("hiddencb") + xOverline = xDialog.getChild("overlinelb") + xStrikeout = xDialog.getChild("strikeoutlb") + xUnderline = xDialog.getChild("underlinelb") + xEmphasis = xDialog.getChild("emphasislb") + xPosition = xDialog.getChild("positionlb") + + self.assertEqual(get_state_as_dict(xHidden)["Selected"], "true") + xHidden.executeAction("CLICK", tuple()) + + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + self.assertEqual(document.Text.String[0:11], "LibreOffice") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf123378.py b/sw/qa/uitest/writer_tests5/tdf123378.py new file mode 100644 index 000000000..d7b832e25 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf123378.py @@ -0,0 +1,27 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from uitest.framework import UITestCase + +#Bug 123378 - Printing always sets "document modified" status + +class tdf123378(UITestCase): + def test_tdf123378_print_sets_modified(self): + # FIXME unstable test + return + self.ui_test.create_doc_in_start_center("writer") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + self.xUITest.executeCommand(".uno:Print") + xDialog = self.xUITest.getTopFocusWindow() + xOK = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xOK) + + self.assertEqual(document.isModified(), False) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf123446.py b/sw/qa/uitest/writer_tests5/tdf123446.py new file mode 100644 index 000000000..dd39dd9f5 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf123446.py @@ -0,0 +1,46 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, type_text +import time +from uitest.debug import sleep +#Bug 123446 - Writer crashes after undoing + redoing ToC insertion in middle of word + +class tdf123446(UITestCase): + + def test_tsd123446_undo_redo_ToC_crash(self): + self.ui_test.create_doc_in_start_center("writer") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #- Add a word to an empty document. + type_text(xWriterEdit, "LibreOffice") + #- Change its style to Heading 2. + self.xUITest.executeCommand(".uno:StyleApply?Style:string=Heading%202&FamilyName:string=ParagraphStyles") + #- Position cursor somewhere in the middle of the word, and add Table of Contents + #(no need to change anything in the dialog). + self.xUITest.executeCommand(".uno:GoLeft") + self.xUITest.executeCommand(".uno:GoLeft") + self.xUITest.executeCommand(".uno:GoLeft") + self.xUITest.executeCommand(".uno:GoLeft") + + self.ui_test.execute_dialog_through_command(".uno:InsertMultiIndex") + xDialog = self.xUITest.getTopFocusWindow() + xokbtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xokbtn) + #- Undo the ToC insertion. + self.xUITest.executeCommand(".uno:Undo") + #- Redo the ToC insertion. + self.xUITest.executeCommand(".uno:Redo") + #=> Crash. Now we verify the text + # This second undo crash in Clang build https://bugs.documentfoundation.org/show_bug.cgi?id=123313#c9 + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Text.String[0:7], "LibreOf") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/titlePage.py b/sw/qa/uitest/writer_tests5/titlePage.py new file mode 100644 index 000000000..644406932 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/titlePage.py @@ -0,0 +1,43 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#uitest sw / Title Page dialog + +class titlePage(UITestCase): + def test_title_page(self): + writer_doc = self.ui_test.create_doc_in_start_center("writer") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #dialog Title Page + self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") + xDialog = self.xUITest.getTopFocusWindow() + #print(xDialog.getChildren()) + + #select new Pages; nr of pages =2 (click UP), save; verify pageCount = 3 + newPages = xDialog.getChild("RB_INSERT_NEW_PAGES") + newPages.executeAction("CLICK", tuple()) + xpageCount = xDialog.getChild("NF_PAGE_COUNT") + xpageCount.executeAction("UP", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.assertEqual(document.CurrentController.PageCount, 3) + + # check cancel button + self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + self.assertEqual(document.CurrentController.PageCount, 3) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/xwindow.py b/sw/qa/uitest/writer_tests5/xwindow.py new file mode 100644 index 000000000..49628776b --- /dev/null +++ b/sw/qa/uitest/writer_tests5/xwindow.py @@ -0,0 +1,179 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import unittest +import unohelper +from org.libreoffice.unotest import UnoInProcess +from com.sun.star.awt import XMouseListener +from com.sun.star.awt import XToolkitRobot +from com.sun.star.awt import MouseButton +from com.sun.star.awt import MouseEvent +from com.sun.star.awt import KeyEvent +from com.sun.star.awt import XKeyListener + + +mouseListenerCount = 0 +mouseEventsIntercepted = 0 +mousePressedEventsIntercepted = 0 +mouseReleasedEventsIntercepted = 0 +mouseEnteredEventsIntercepted = 0 +mouseExitedEventsIntercepted = 0 +keymousePressedEventsIntercepted = 0 +keymouseReleasedEventsIntercepted = 0 + + +class XMouseListenerExtended(unohelper.Base, XMouseListener): + def __init__(self): + global mouseListenerCount + mouseListenerCount += 1 + super().__init__() + + # is invoked when a mouse button has been pressed on a window. + @classmethod + def mousePressed(self, xMouseEvent): + global mousePressedEventsIntercepted + mousePressedEventsIntercepted += 1 + + # is invoked when a mouse button has been released on a window. + @classmethod + def mouseReleased(self, xMouseEvent): + global mouseReleasedEventsIntercepted + mouseReleasedEventsIntercepted += 1 + + # is invoked when the mouse enters a window. + @classmethod + def mouseEntered(self, xMouseEvent): + global mouseEventsIntercepted + mouseEventsIntercepted += 1 + return super(XMouseListenerExtended, self).mouseEntered(xMouseEvent) + + # is invoked when the mouse exits a window. + @classmethod + def mouseExited(self, xMouseEvent): + global mouseEventsIntercepted + mouseEventsIntercepted += 1 + return super(XMouseListenerExtended, self).mouseExited(xMouseEvent) + + +class XKeyListenerExtended(unohelper.Base, XKeyListener): + # is invoked when a key has been pressed + @classmethod + def keyPressed(self, xKeyEvent): + global keymousePressedEventsIntercepted + keymousePressedEventsIntercepted += 1 + return super(XKeyListenerExtended, self).keyPressed(xKeyEvent) + + # is invoked when a key has been released + @classmethod + def keyReleased(self, xKeyEvent): + global keymouseReleasedEventsIntercepted + keymouseReleasedEventsIntercepted += 1 + return super(XKeyListenerExtended, self).keyReleased(xKeyEvent) + +# Test that registered mouse/key listeners for top window receive mouse/key events +class XWindow(UITestCase): + def test_listeners(self): + global mouseListenerCount + + self.ui_test.create_doc_in_start_center("writer") + xDoc = self.ui_test.get_component() + + # create new mouse listener + xFrame = xDoc.getCurrentController().getFrame() + self.assertIsNotNone(xFrame) + xWindow = xFrame.getContainerWindow() + self.assertIsNotNone(xWindow) + + # add new mouse listener + xMouseListener = XMouseListenerExtended() + self.assertIsNotNone(xMouseListener) + xWindow.addMouseListener(xMouseListener) + self.assertEqual(1, mouseListenerCount) + + # add new key listener + xKeyListener = XKeyListenerExtended() + self.assertIsNotNone(xKeyListener) + xWindow.addKeyListener(xKeyListener) + + # create dummy mouse event + xMouseEvent = MouseEvent() + xMouseEvent.Modifiers = 0 + xMouseEvent.Buttons = MouseButton.LEFT + xMouseEvent.X = 10 + xMouseEvent.Y = 10 + xMouseEvent.ClickCount = 1 + xMouseEvent.PopupTrigger = False + xMouseEvent.Source = xWindow + + xMouseEvent2 = MouseEvent() + xMouseEvent2.Modifiers = 0 + xMouseEvent2.Buttons = MouseButton.LEFT + xMouseEvent2.X = 300 + xMouseEvent2.Y = 300 + xMouseEvent2.ClickCount = 1 + xMouseEvent2.PopupTrigger = False + xMouseEvent2.Source = xWindow + + # send mouse event + xToolkitRobot = xWindow.getToolkit() + self.assertIsNotNone(xToolkitRobot) + + # Click in the menubar/toolbar area + xToolkitRobot.mouseMove(xMouseEvent) + xToolkitRobot.mousePress(xMouseEvent) + xToolkitRobot.mouseRelease(xMouseEvent) + + # Click into the document content + xToolkitRobot.mousePress(xMouseEvent2) + xToolkitRobot.mouseRelease(xMouseEvent2) + + # send key press event + xKeyEvent = KeyEvent() + xKeyEvent.Modifiers = 0 + xKeyEvent.KeyCode = 70 + xKeyEvent.KeyChar = 70 + xKeyEvent.Source = xWindow + + xToolkitRobot.keyPress(xKeyEvent) + xToolkitRobot.keyRelease(xKeyEvent) + + # Wait for async events to be processed + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + + # remove mouse listener + xWindow.removeMouseListener(xMouseListener) + self.assertEqual(1, mouseListenerCount) + del xMouseListener + + # remove key listener + xWindow.removeKeyListener(xKeyListener) + del xKeyListener + + global keymousePressedEventsIntercepted + # Not expected any interceptions + self.assertEqual(0, keymousePressedEventsIntercepted) + + global keymouseReleasedEventsIntercepted + # Not expected any interceptions + self.assertEqual(0, keymouseReleasedEventsIntercepted) + + global mousePressedEventsIntercepted + self.assertEqual(0, mousePressedEventsIntercepted) + + global mouseReleasedEventsIntercepted + self.assertEqual(0, mouseReleasedEventsIntercepted) + + global mouseEventsIntercepted + # Not expected 3 interceptions + self.assertEqual(0, mouseEventsIntercepted) + + # close document + self.ui_test.close_doc() + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/zoom.py b/sw/qa/uitest/writer_tests5/zoom.py new file mode 100644 index 000000000..3d9e224c1 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/zoom.py @@ -0,0 +1,107 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#uitest sw / View-Zoom + +class writerZoom(UITestCase): + def test_zoom_writer(self): + writer_doc = self.ui_test.create_doc_in_start_center("writer") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #dialog View-Zoom-Zoom + self.ui_test.execute_dialog_through_command(".uno:Zoom") + xDialog = self.xUITest.getTopFocusWindow() + + #select Optimal & Automatic - OK - open and verify + optimal = xDialog.getChild("optimal") + optimal.executeAction("CLICK", tuple()) + automatic = xDialog.getChild("automatic") + automatic.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.execute_dialog_through_command(".uno:Zoom") + xDialog = self.xUITest.getTopFocusWindow() + optimal = xDialog.getChild("optimal") + automatic = xDialog.getChild("automatic") + self.assertEqual(get_state_as_dict(optimal)["Checked"], "true") + self.assertEqual(get_state_as_dict(automatic)["Checked"], "true") + #select fit weight & Single page - OK - open and verify + fitwandh = xDialog.getChild("fitwandh") + singlepage = xDialog.getChild("singlepage") + fitwandh.executeAction("CLICK", tuple()) + singlepage.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.execute_dialog_through_command(".uno:Zoom") + xDialog = self.xUITest.getTopFocusWindow() + singlepage = xDialog.getChild("singlepage") + fitwandh = xDialog.getChild("fitwandh") + self.assertEqual(get_state_as_dict(singlepage)["Checked"], "true") + self.assertEqual(get_state_as_dict(fitwandh)["Checked"], "true") + #select fit width & columns - OK - open and verify + fitw = xDialog.getChild("fitw") + columnssb = xDialog.getChild("columnssb") + columns = xDialog.getChild("columns") + fitw.executeAction("CLICK", tuple()) + columns.executeAction("CLICK", tuple()) + columnssb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + columnssb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + columnssb.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.execute_dialog_through_command(".uno:Zoom") + xDialog = self.xUITest.getTopFocusWindow() + fitw = xDialog.getChild("fitw") + columnssb = xDialog.getChild("columnssb") + columns = xDialog.getChild("columns") + self.assertEqual(get_state_as_dict(fitw)["Checked"], "true") + self.assertEqual(get_state_as_dict(columns)["Checked"], "true") + self.assertEqual(get_state_as_dict(columnssb)["Text"], "3") + #select 100% & Automatic - OK - open and verify + automatic = xDialog.getChild("automatic") + x100pc = xDialog.getChild("100pc") + x100pc.executeAction("CLICK", tuple()) + automatic.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.execute_dialog_through_command(".uno:Zoom") + xDialog = self.xUITest.getTopFocusWindow() + automatic = xDialog.getChild("automatic") + x100pc = xDialog.getChild("100pc") + self.assertEqual(get_state_as_dict(automatic)["Checked"], "true") + self.assertEqual(get_state_as_dict(x100pc)["Checked"], "true") + #select variable 103% & Automatic - OK - open and verify + variable = xDialog.getChild("variable") + zoomsb = xDialog.getChild("zoomsb") + variable.executeAction("CLICK", tuple()) + zoomsb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + zoomsb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + zoomsb.executeAction("TYPE", mkPropertyValues({"TEXT":"101"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.execute_dialog_through_command(".uno:Zoom") + xDialog = self.xUITest.getTopFocusWindow() + variable = xDialog.getChild("variable") + zoomsb = xDialog.getChild("zoomsb") + self.assertEqual(get_state_as_dict(variable)["Checked"], "true") + self.assertEqual(get_state_as_dict(zoomsb)["Text"], "101%") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: -- cgit v1.2.3