diff options
Diffstat (limited to '')
22 files changed, 1702 insertions, 0 deletions
diff --git a/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py b/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py new file mode 100644 index 000000000..9eb36eefb --- /dev/null +++ b/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py @@ -0,0 +1,133 @@ +# -*- 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 uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class dateFormFieldDialog(UITestCase): + + def test_setting_date_format(self): + # open a file with a date form field + with self.ui_test.load_file(get_url_for_data_file("date_form_field.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + + # open the dialog again + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + itemsList = xDialog.getChild("date_formats_treeview") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") + + + def test_date_field_with_custom_format(self): + # open a file with a date form field + with self.ui_test.load_file(get_url_for_data_file("date_form_field_custom_format.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + itemsList = xDialog.getChild("date_formats_treeview") + + # check whether we have the right format selected + # This is awkward though because checking for a fixed number of + # entries if the selected default format happens to equal a + # standard system format the entry gets duplicated with + # "[System]" appended. So this may be either 20 or 21 ... and + # in that case it is the selected format and the + # SelectEntryText doesn't match the sample string, so all this + # is rather fragile depending on actual locale data. + self.assertEqual(get_state_as_dict(itemsList)["Children"], "21") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "1999. december 31., péntek[System]") + + + def test_date_reformat(self): + # open a file with a date form field + with self.ui_test.load_file(get_url_for_data_file("date_form_field.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + self.assertEqual(writer_doc.getText().getString(), "07/17/19") + + # open the dialog (cursor is at the field) + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + + # after applying the new format, the field content should be updated + self.assertEqual(writer_doc.getText().getString(), "07-17") + + def test_date_field_with_placeholder(self): + # open a file with a date form field + with self.ui_test.load_file(get_url_for_data_file("date_form_field_with_placeholder.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + self.assertEqual(writer_doc.getText().getString(), "[select date]") + + # open the dialog (cursor is at the field) + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + + # a placeholder text is not changed by format change + self.assertEqual(writer_doc.getText().getString(), "[select date]") + + 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 + with self.ui_test.load_file(get_url_for_data_file("date_form_field_without_current_date.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + self.assertEqual(writer_doc.getText().getString(), "07/17/19") + + # open the dialog (cursor is at the field) + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + + # a placeholder text is not changed by format change + self.assertEqual(writer_doc.getText().getString(), "Jul 17, 2019") + +# 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..e64e32b02 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py @@ -0,0 +1,238 @@ +# -*- 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 uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class dropDownFormFieldDialog(UITestCase): + + def test_add_new_items(self): + + # open a file with an empty form field + with self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + + # check whether items are the same after reopening + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + + def test_remove_items(self): + + # open a file with an empty form field + with self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + + # check whether items are the same after reopening + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + + def test_move_items(self): + + # open a file with an empty form field + with self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + + # check whether items are the same after reopening + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + + 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 + with self.ui_test.load_file(get_url_for_data_file(file)) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + with self.ui_test.execute_dialog_through_command(".uno:ControlProperties") as xDialog: + + 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") + + +# 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..980eca989 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/about_test.py @@ -0,0 +1,22 @@ +# -*- 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 + +class AboutDlgTest(UITestCase): + + def test_about_dlg(self): + + with self.ui_test.create_doc_in_start_center("writer"): + + with self.ui_test.execute_dialog_through_command(".uno:About", close_button="btnClose"): + pass + + +# 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..a1305018e --- /dev/null +++ b/sw/qa/uitest/writer_tests5/autocorrectOptions.py @@ -0,0 +1,98 @@ +# -*- 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.uihelper.common import select_pos + +class autocorrectOptions(UITestCase): + + def test_autocorrect_options_writer(self): + with self.ui_test.create_doc_in_start_center("writer"): + xWriterDoc = self.xUITest.getTopFocusWindow() + + with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg", close_button="cancel") as xDialog: + 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"] + + self.assertTrue(int(nrRows) > 0) + + #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)["VisibleCount"] + + self.assertTrue(int(nrRowsAbb) > 0) + + 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)["VisibleCount"] + nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) + self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule + delabbrev.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], 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)["VisibleCount"] + + self.assertTrue(int(nrRowsDouble) > 0) + + 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)["VisibleCount"] + 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)["VisibleCount"], nrRowsDouble) #we have default nr of rules + + + +# 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..a70f31143 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/columns.py @@ -0,0 +1,48 @@ +# -*- 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 uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import change_measurement_unit +from libreoffice.uno.propertyvalue import mkPropertyValues +#uitest sw / Columns dialog + +class columns(UITestCase): + def test_columns(self): + with self.ui_test.create_doc_in_start_center("writer"): + xWriterDoc = self.xUITest.getTopFocusWindow() + + change_measurement_unit(self, "Centimeter") + + #dialog Columns + with self.ui_test.execute_dialog_through_command(".uno:FormatColumns") as xDialog: + + 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()) + #verify + with self.ui_test.execute_dialog_through_command(".uno:FormatColumns", close_button="cancel") as xDialog: + 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") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf106899.py b/sw/qa/uitest/writer_tests5/tdf106899.py new file mode 100644 index 000000000..bd77c2945 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf106899.py @@ -0,0 +1,43 @@ +# -*- 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/. +# + +import org.libreoffice.unotest +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +class tdf106899(UITestCase): + + def test_tdf106899_alphabetical_index_utf8(self): + # Copy concordance file containing an utf8 index entry + org.libreoffice.unotest.makeCopyFromTDOC("tdf106899.sdi") + with self.ui_test.load_file(get_url_for_data_file("tdf106899.odt")) as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + + # Update the alphabetical index and check if it contains the utf8 index entry + xDocumentIndexes = document.DocumentIndexes + self.assertEqual(xDocumentIndexes.getCount(), 1) + self.assertEqual(xDocumentIndexes.hasByName("Alphabetical Index1"), True) + xDocumentIndex = xDocumentIndexes.getByName("Alphabetical Index1") + xIndexAnchor = xDocumentIndex.getAnchor() + self.assertEqual("Nguyễn Khánh" in xIndexAnchor.getString(), False) + + # TODO Bug Report - Refresh of the index does only work using .uno:UpdateAllIndexes + # It does not work with xDocumentIndex.refresh() nor with xDocumentIndex.update() + self.xUITest.executeCommand(".uno:UpdateAllIndexes") + + # TODO Bug Report - Retrieving the text of the updated index only works using the cursor + # It does not work with xIndexAnchor.getString() + xCursor = document.getText().createTextCursor() + xCursor.gotoRange(xDocumentIndex.getAnchor().getEnd(), False) + xCursor.gotoStartOfParagraph(True) + + # Without the fix in place the index does not contain the utf8 index entry + self.assertEqual("Nguyễn Khánh" in xCursor.getString(), True) + +# 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..a08885308 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf117039.py @@ -0,0 +1,26 @@ +# -*- 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 uitest.uihelper.common import get_url_for_data_file + +#Bug 117039 - Print Preview crashes on signed document + +class tdf117039(UITestCase): + def test_tdf117039_preview_signed_document(self): + with self.ui_test.load_file(get_url_for_data_file("tdf117039.odt")) as writer_doc: + 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(writer_doc.Text.String[0:22], "Test digital signature") + +# 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..e33cad63b --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf118540.py @@ -0,0 +1,28 @@ +# -*- 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 uitest.uihelper.common import get_url_for_data_file + +#Bug 118540 - LO6.1b2: DOCX crashes when properties are opened in print preview mode + +class tdf118540(UITestCase): + def test_tdf118540_preview_document_properties(self): + with self.ui_test.load_file(get_url_for_data_file("tdf118540.docx")) as writer_doc: + self.xUITest.executeCommand(".uno:PrintPreview") #open print preview + with self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties"): + pass + self.xUITest.executeCommand(".uno:ClosePreview") # close print preview + + self.xUITest.getTopFocusWindow() #Get focus after closing preview + + #verify + self.assertEqual(writer_doc.Text.String[0:4], "Test") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf122045.py b/sw/qa/uitest/writer_tests5/tdf122045.py new file mode 100644 index 000000000..6e938e093 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf122045.py @@ -0,0 +1,39 @@ +# -*- 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 uitest.uihelper.common import select_pos + +class tdf122045(UITestCase): + + def test_tdf122045(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + + with self.ui_test.execute_dialog_through_command(".uno:PageDialog", close_button="cancel") as xDialog: + + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + + btncolor = xDialog.getChild("btncolor") + btncolor.executeAction("CLICK", tuple()) + + xApplyBtn = xDialog.getChild("apply") + xApplyBtn.executeAction("CLICK", tuple()) + + self.assertTrue(document.isModified()) + self.assertEqual("0x729fcf", hex(document.StyleFamilies.PageStyles.Standard.BackColor)) + + + self.assertTrue(document.isModified()) + self.assertEqual("0x729fcf", hex(document.StyleFamilies.PageStyles.Standard.BackColor)) + + +# 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..ebbbd18db --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf122722.py @@ -0,0 +1,67 @@ +# -*- 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 uitest.uihelper.common import get_state_as_dict, type_text +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): + with self.ui_test.create_doc_in_start_center("writer") as document: + 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 + with self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xDialog: + 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()) + + #un-hidden + with self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xDialog: + 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()) + + + self.assertEqual(document.Text.String[0:11], "LibreOffice") + +# 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..b0b35d266 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf123378.py @@ -0,0 +1,28 @@ +# -*- 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 + +#Bug 123378 - Printing always sets "document modified" status + +class tdf123378(UITestCase): + def test_tdf123378_print_sets_modified(self): + # FIXME unstable test + return + with self.ui_test.create_doc_in_start_center("writer") as document: + 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) + +# 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..53f8208f8 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf123446.py @@ -0,0 +1,42 @@ +# -*- 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 uitest.uihelper.common import type_text +#Bug 123446 - Writer crashes after undoing + redoing ToC insertion in middle of word + +class tdf123446(UITestCase): + + def test_tdf123446_undo_redo_ToC_crash(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + 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") + + with self.ui_test.execute_dialog_through_command(".uno:InsertMultiIndex"): + pass + #- 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") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf138531.py b/sw/qa/uitest/writer_tests5/tdf138531.py new file mode 100644 index 000000000..328a8250b --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf138531.py @@ -0,0 +1,67 @@ +# -*- 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 uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell + +class Tdf138531(UITestCase): + + def test_tdf138531(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "First") + enter_text_to_cell(gridwin, "A2", "Second") + + #select A1:A2 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + + self.xUITest.executeCommand(".uno:Copy") + + # Work with both documents at the same time + with self.ui_test.load_empty_file("writer") as writer_doc: + + # Paste as DDE + formatProperty = mkPropertyValues({"SelectedFormat": 59}) + self.xUITest.executeCommandWithParameters(".uno:ClipboardFormatItems", formatProperty) + + self.assertEqual(1, writer_doc.TextTables.getCount()) + table = writer_doc.getTextTables()[0] + self.assertEqual("First", table.getCellByName("A1").getString()) + self.assertEqual("Second", table.getCellByName("A2").getString()) + + frames = self.ui_test.get_frames() + # switch view to the calc document + frames[0].activate() + enter_text_to_cell(gridwin, "A1", "Second") + enter_text_to_cell(gridwin, "A2", "First") + + # switch view back to the writer document + frames[1].activate() + + with self.ui_test.execute_dialog_through_command(".uno:LinkDialog", close_button="close") as xDialog: + xLinks = xDialog.getChild("TB_LINKS") + self.assertEqual(1, len(xLinks.getChildren())) + + xFileName = xDialog.getChild("FULL_FILE_NAME") + self.assertEqual("Untitled 1", get_state_as_dict(xFileName)["Text"]) + + xUpdate = xDialog.getChild("UPDATE_NOW") + xUpdate.executeAction("CLICK", tuple()) + + # Without the fix in place, this test would have failed with + # AssertionError: 'Second' != 'First' + self.assertEqual("Second", table.getCellByName("A1").getString()) + self.assertEqual("First", table.getCellByName("A2").getString()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf142847.py b/sw/qa/uitest/writer_tests5/tdf142847.py new file mode 100644 index 000000000..845b7eb7a --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf142847.py @@ -0,0 +1,49 @@ +# -*- 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 +import org.libreoffice.unotest +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf142847(UITestCase): + def test_tdf142847(self): + # load the sample file + with self.ui_test.load_file(get_url_for_data_file("tdf142847.fodt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() + + # get the shape + shape = document.DrawPage.getByIndex(0) + + # get the textbox + frame = shape.getText() + + oldFramePos = frame.getPropertyValue("HoriOrientPosition") + oldShapePos = shape.getPropertyValue("LeftMargin") + oldDiff = oldFramePos - oldShapePos + + # select the shape. + self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.ui_test.wait_until_child_is_available('metricfield') + + # set the wrap spacing of the shape + with self.ui_test.execute_dialog_through_command(".uno:TextWrap") as wrap_dialog: + wrap_dialog.getChild('left').executeAction("UP", tuple()) + + newDiff = frame.getPropertyValue("HoriOrientPosition") - shape.getPropertyValue("LeftMargin") + + # without the fix, this will fail. + # the textbox has fallen apart. + self.assertEqual(oldDiff, newDiff) + + self.assertGreater(frame.getPropertyValue("HoriOrientPosition"), oldFramePos) + self.assertGreater(shape.getPropertyValue("LeftMargin"), oldShapePos) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf145326.py b/sw/qa/uitest/writer_tests5/tdf145326.py new file mode 100644 index 000000000..d063e6388 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf145326.py @@ -0,0 +1,86 @@ +# -*- 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 uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from org.libreoffice.unotest import systemPathToFileUrl +from tempfile import TemporaryDirectory +import os.path + +class Tdf145326(UITestCase): + + def test_tdf145326(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "tdf145326-temp.odt") + + with self.ui_test.execute_dialog_through_command(".uno:Open", close_button="") as xOpenDialog: + + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf145326.odt")})) + + xOpenBtn = xOpenDialog.getChild("open") + # Update all links dialog + with self.ui_test.wait_until_component_loaded(): + with self.ui_test.execute_blocking_action(xOpenBtn.executeAction, args=('CLICK', ()), close_button="yes"): + pass + + with self.ui_test.execute_dialog_through_command(".uno:LinkDialog", close_button="close") as xDialog: + + sLinks = "TB_LINKS" + xLinks = xDialog.getChild(sLinks) + self.assertEqual(1, len(xLinks.getChildren())) + + sFileName = "FULL_FILE_NAME" + xFileName = xDialog.getChild(sFileName) + self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("SAmple odp.ods")) + + sBreakLink = "BREAK_LINK" + xBreakLink = xDialog.getChild(sBreakLink) + + with self.ui_test.execute_blocking_action(xBreakLink.executeAction, + args=("CLICK", tuple()), close_button="yes"): + pass + + # Save Copy as + with self.ui_test.execute_dialog_through_command('.uno:SaveAs', close_button="open") 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})) + + self.ui_test.close_doc() + + self.ui_test.wait_until_file_is_available(xFilePath) + + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as doc2: + + self.xUITest.executeCommand(".uno:LinkDialog") + + # Since the image is no longer linked, the link dialog is not open. + # Without the fix in place, this dialog would have been opened + xMainWin = self.xUITest.getTopFocusWindow() + self.assertTrue(sLinks not in xMainWin.getChildren()) + self.assertTrue(sFileName not in xMainWin.getChildren()) + self.assertTrue(sBreakLink not in xMainWin.getChildren()) + self.assertTrue("writer_edit" in xMainWin.getChildren()) + + self.assertEqual(doc2.TextTables.getCount(), 1) + table = doc2.getTextTables()[0] + + self.assertEqual(len(table.getRows()), 7) + self.assertEqual("10,000", table.getCellByName("D2").getString()) + self.assertEqual("20,000", table.getCellByName("D3").getString()) + self.assertEqual("5,000", table.getCellByName("D4").getString()) + self.assertEqual("7,000", table.getCellByName("D5").getString()) + self.assertEqual("5,000", table.getCellByName("D6").getString()) + self.assertEqual("7,000", table.getCellByName("D7").getString()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf147935.py b/sw/qa/uitest/writer_tests5/tdf147935.py new file mode 100644 index 000000000..fa0e773a9 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf147935.py @@ -0,0 +1,43 @@ +# -*- 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 uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell + +class Tdf147935(UITestCase): + + def test_tdf147935(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "DDE") + + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"Cell": "A1"})) + + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_empty_file("writer") as writer_doc: + + # Paste as DDE + formatProperty = mkPropertyValues({"SelectedFormat": 59}) + self.xUITest.executeCommandWithParameters(".uno:ClipboardFormatItems", formatProperty) + + # Without the fix in place, this test would have failed because the warning message + # "A table with no rows or no cells cannot be inserted" would have been displayed + + self.assertEqual(1, writer_doc.TextTables.getCount()) + table = writer_doc.getTextTables()[0] + self.assertEqual("DDE", table.getCellByName("A1").getString()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf148920.py b/sw/qa/uitest/writer_tests5/tdf148920.py new file mode 100644 index 000000000..c8bde7769 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf148920.py @@ -0,0 +1,33 @@ +# -*- 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 uitest.uihelper.common import get_state_as_dict + +class tdf148920(UITestCase): + + def test_tdf148920(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + + self.xUITest.executeCommand(".uno:StyleApply?Style:string=Text%20body&FamilyName:string=ParagraphStyles") + + with self.ui_test.execute_dialog_through_command(".uno:EditStyle", close_button="cancel") as xDialog: + xFilter = xDialog.getChild("filter") + + # Without the fix in place, this test would have failed with + # AssertionError: 'true' != 'false' + self.assertEqual("true", get_state_as_dict(xFilter)["Enabled"]) + + # tdf#91035: Without the fix in place, this test would have failed with + # AssertionError: 'All Styles' != 'Hidden Styles' + self.assertEqual("All Styles", get_state_as_dict(xFilter)["SelectEntryText"]) + + +# 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..e2b774492 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/titlePage.py @@ -0,0 +1,31 @@ +# -*- 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 +#uitest sw / Title Page dialog + +class titlePage(UITestCase): + def test_title_page(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + #dialog Title Page + with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog: + #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()) + self.assertEqual(document.CurrentController.PageCount, 3) + + # check cancel button + with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog", close_button="cancel"): + pass + self.assertEqual(document.CurrentController.PageCount, 3) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/titlePageWizard.py b/sw/qa/uitest/writer_tests5/titlePageWizard.py new file mode 100644 index 000000000..4146dab22 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/titlePageWizard.py @@ -0,0 +1,195 @@ +# -*- 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 uitest.uihelper.common import get_url_for_data_file + +# This tests the Format->Title Page wizard, specifically the reset page number portion, +# replacing some pages with title pages, +# inserting pages in the middle of the document, +# and inserting at the very end of the document. +class tdf138907(UITestCase): + def test_tdf138907(self): + with self.ui_test.load_file(get_url_for_data_file("tdf138907_titlePageDialog.odt")) as document: + + # Confirm the starting state. Just a page break, without a valid restart page number on page 2 + self.assertEqual(document.CurrentController.PageCount, 5) + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "7") + self.assertEqual(Para2.PageDescName, None) + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "8") + self.assertEqual(Para3.PageDescName, None) + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "9") + self.assertEqual(Para4.PageDescName, None) + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "10") + self.assertEqual(Para5.PageDescName, None) + + + #dialog Title Page + with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog: + #set restart page number to 2. With this doc, it defaults to resetting to 1. + xRestartNumbering = xDialog.getChild("NF_RESTART_NUMBERING") + xRestartNumbering.executeAction("UP", tuple()) # restart numbering at 2 + + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + self.assertEqual(Para2.String, "2") + Para2 = Paragraphs.nextElement() + # Without this fix, there was no PageDescName specified, just Landscape as default. + self.assertEqual(Para2.PageDescName, "Landscape") + + #re-run dialog Title Page + with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog"): + pass + + # Without this fix, re-running the wizard was failing with the title page restarting at page 2. + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "2") + self.assertEqual(Para2.PageDescName, "Landscape") + + #Note: 6 virtual pages, including blank, even page seen in book view + self.assertEqual(document.CurrentController.PageCount, 6) + + #Now test replacing several pages with title and index styles + + #dialog Title Page + with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog: + #Convert three pages to title/index pages starting at page two. + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,2): + xPageCount.executeAction("UP", tuple()) + xUseStartingPage = xDialog.getChild("RB_PAGE_START") + xUseStartingPage.executeAction("CLICK", tuple()) + xStartingPage = xDialog.getChild("NF_PAGE_START") + xStartingPage.executeAction("UP", tuple()) #Start at page 2. + + + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + # Without the fix, the following results are all off by one. + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "6") + self.assertEqual(Para2.PageDescName, "First Page") + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "7") + self.assertEqual(Para3.PageDescName, "Index") + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "8") + self.assertEqual(Para4.PageDescName, "Index") + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "2") + self.assertEqual(Para5.PageDescName, "Landscape") + + #Now test inserting at the end of the document + + #dialog Title Page + with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog: + #Insert three title/index pages at the end of the document (plus a content page). + newPages = xDialog.getChild("RB_INSERT_NEW_PAGES") + newPages.executeAction("CLICK", tuple()) + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,2): + xPageCount.executeAction("UP", tuple()) + xUseStartingPage = xDialog.getChild("RB_PAGE_START") + xUseStartingPage.executeAction("CLICK", tuple()) + xStartingPage = xDialog.getChild("NF_PAGE_START") + for _ in range(0,18): + xStartingPage.executeAction("UP", tuple()) #Start at mythical page 20. + + + # Without the fix, the pages were being inserted before the last page. + text = document.Text.String.replace('\r\n', '\n') + self.assertEqual(text[0:1], "6") + self.assertEqual(text[2:3], "6") + self.assertEqual(text[4:5], "7") + self.assertEqual(text[6:7], "8") + # Without the fix, the new pages were inserted before the last page. + self.assertFalse("\n" in text[8:9]) + #Note: 13 total virtual pages, including four blanks, as seen in book view + self.assertEqual(document.CurrentController.PageCount, 13) + + #Now test inserting in the middle of the document + + #dialog Title Page + with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog: + #Insert three title/index pages starting at page 2. + newPages = xDialog.getChild("RB_INSERT_NEW_PAGES") + newPages.executeAction("CLICK", tuple()) + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,2): + xPageCount.executeAction("UP", tuple()) + xUseStartingPage = xDialog.getChild("RB_PAGE_START") + xUseStartingPage.executeAction("CLICK", tuple()) + xStartingPage = xDialog.getChild("NF_PAGE_START") + for _ in range(0,10): + xStartingPage.executeAction("DOWN", tuple()) #Reset to page 1 + xStartingPage.executeAction("UP", tuple()) #Start at page 2. + + + # Without first re-calculating the layout, the styles were applied to the wrong pages. + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + # The next three pages are the ones that were just inserted. + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "") + self.assertEqual(Para2.PageDescName, "First Page") + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "") + self.assertEqual(Para3.PageDescName, "Index") + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "") + self.assertEqual(Para4.PageDescName, "Index") + # A bit of a quirk is that the style of the first page after the + # title page is still First Page - so that is used as the Normal page style. + # OK - this is a bit of a strange workflow, so just accept that. + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "6") + self.assertEqual(Para5.PageDescName, "First Page") + Para6 = Paragraphs.nextElement() + self.assertEqual(Para6.String, "7") + self.assertEqual(Para6.PageDescName, "Index") + Para7 = Paragraphs.nextElement() + self.assertEqual(Para7.String, "8") + self.assertEqual(Para7.PageDescName, "Index") + Para8 = Paragraphs.nextElement() + self.assertEqual(Para8.String, "2") + self.assertEqual(Para8.PageDescName, "Landscape") + Para9 = Paragraphs.nextElement() + self.assertEqual(Para9.String, "") + self.assertEqual(Para9.PageDescName, "First Page") + Para10 = Paragraphs.nextElement() + self.assertEqual(Para10.String, "") + self.assertEqual(Para10.PageDescName, "Index") + Para11 = Paragraphs.nextElement() + self.assertEqual(Para11.String, "") + self.assertEqual(Para11.PageDescName, "Index") + # The quirk resets this extra content page to the "style after First page == First Page" + Para12 = Paragraphs.nextElement() + self.assertEqual(Para12.String, "") + self.assertEqual(Para12.PageDescName, "First Page") + #Note: 17 total virtual pages, including five blanks, as seen in book view + self.assertEqual(document.CurrentController.PageCount, 17) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/titlePageWizard2.py b/sw/qa/uitest/writer_tests5/titlePageWizard2.py new file mode 100644 index 000000000..4f3473530 --- /dev/null +++ b/sw/qa/uitest/writer_tests5/titlePageWizard2.py @@ -0,0 +1,124 @@ +# -*- 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 uitest.uihelper.common import get_url_for_data_file + +# This tests both an edge cases, and some more realistic situations. +class tdf138907(UITestCase): + def test_tdf138907(self): + with self.ui_test.load_file(get_url_for_data_file("tdf138907_titlePageDialog.odt")) as document: + + # Test an undefined situation - try to modify pages beyond the end of the document. + + #dialog Title Page + with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog: + #set restart page number to 2. With this doc, it defaults to resetting to 1. + xRestartNumbering = xDialog.getChild("NF_RESTART_NUMBERING") + xRestartNumbering.executeAction("UP", tuple()) # restart numbering at 2 + + #Convert three pages to title/index pages starting at non-existing page twenty. + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,2): + xPageCount.executeAction("UP", tuple()) + xUseStartingPage = xDialog.getChild("RB_PAGE_START") + xUseStartingPage.executeAction("CLICK", tuple()) + xStartingPage = xDialog.getChild("NF_PAGE_START") + for _ in range(0,19): + xStartingPage.executeAction("UP", tuple()) #Start at mythical page 20. + + + # Nothing should happen when modifying pages that don't exist. + # Just a page break, without a valid restart page number on page 2 + self.assertEqual(document.CurrentController.PageCount, 5) + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "7") + self.assertEqual(Para2.PageDescName, None) + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "8") + self.assertEqual(Para3.PageDescName, None) + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "9") + self.assertEqual(Para4.PageDescName, None) + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "10") + self.assertEqual(Para5.PageDescName, None) + + + #dialog Title Page + with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog: + #set restart page number to 1 - which is the default. + #set restart title page to 1 - the current value for this document is 6. + xRestartNumbering = xDialog.getChild("NF_SET_PAGE_NUMBER") + for _ in range(0,5): + xRestartNumbering.executeAction("DOWN", tuple()) # restart title numbering at 1 + #Insert two title/index pages at beginning of the document. + newPages = xDialog.getChild("RB_INSERT_NEW_PAGES") + newPages.executeAction("CLICK", tuple()) + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,1): + xPageCount.executeAction("UP", tuple()) + + + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "") + self.assertEqual(Para1.PageDescName, "First Page") + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "") + self.assertEqual(Para2.PageDescName, "Index") + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "1") + self.assertEqual(Para3.PageDescName, "Landscape") + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "2") + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "3") + Para6 = Paragraphs.nextElement() + self.assertEqual(Para6.String, "4") + Para7 = Paragraphs.nextElement() + self.assertEqual(Para7.String, "5") + + #Now test replacing several pages with title and index styles + + #dialog Title Page + with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog: + #Convert four pages to title/index pages starting at page one. + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,3): + xPageCount.executeAction("DOWN", tuple()) #reset to 1 first + for _ in range(0,3): + xPageCount.executeAction("UP", tuple()) + + + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "") + self.assertEqual(Para1.PageDescName, "First Page") + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "") + self.assertEqual(Para2.PageDescName, "Index") + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "3") + self.assertEqual(Para3.PageDescName, "Index") + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "4") + self.assertEqual(Para4.PageDescName, "Index") + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "1") + self.assertEqual(Para5.PageDescName, "Landscape") + Para6 = Paragraphs.nextElement() + self.assertEqual(Para6.String, "2") + Para7 = Paragraphs.nextElement() + self.assertEqual(Para7.String, "3") + +# 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..d7a0f885f --- /dev/null +++ b/sw/qa/uitest/writer_tests5/xwindow.py @@ -0,0 +1,176 @@ +# -*- 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 +import unohelper +from com.sun.star.awt import XMouseListener +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 + + with self.ui_test.create_doc_in_start_center("writer") as xDoc: + + # 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 + + +# 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..cb6d0ebad --- /dev/null +++ b/sw/qa/uitest/writer_tests5/zoom.py @@ -0,0 +1,86 @@ +# -*- 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 uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +#uitest sw / View-Zoom + +class writerZoom(UITestCase): + def test_zoom_writer(self): + with self.ui_test.create_doc_in_start_center("writer"): + xWriterDoc = self.xUITest.getTopFocusWindow() + #dialog View-Zoom-Zoom + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + + #select Optimal & Automatic - OK - open and verify + optimal = xDialog.getChild("optimal") + optimal.executeAction("CLICK", tuple()) + automatic = xDialog.getChild("automatic") + automatic.executeAction("CLICK", tuple()) + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + 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()) + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + 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"})) + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + 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()) + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + 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"})) + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + 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%") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |