diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sc/qa/uitest/calc_tests9 | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream.tar.xz libreoffice-upstream.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/qa/uitest/calc_tests9')
22 files changed, 1224 insertions, 0 deletions
diff --git a/sc/qa/uitest/calc_tests9/forms.py b/sc/qa/uitest/calc_tests9/forms.py new file mode 100644 index 000000000..35f9feb41 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/forms.py @@ -0,0 +1,30 @@ +# -*- 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 Forms(UITestCase): + + def test_tdf131000(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf131000.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "form"})) + + # Without the fix in place, this test would have hung here + with self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button=""): + + xCellRange = self.ui_test.wait_until_child_is_available('textfield-Source cell range') + + self.assertEqual("A1:A7000", get_state_as_dict(xCellRange)['Text']) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/hashIncompatible.py b/sc/qa/uitest/calc_tests9/hashIncompatible.py new file mode 100644 index 000000000..07ab21db8 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/hashIncompatible.py @@ -0,0 +1,71 @@ +# -*- 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 +from uitest.uihelper.common import select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues +from tempfile import TemporaryDirectory +import os.path + +class hashIncompatible(UITestCase): + + def test_hashIncompatible(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "hashIncompatible-temp.ods") + + with self.ui_test.load_file(get_url_for_data_file("hashIncompatible.xlsx")): + + # Save the XLSX document as ODS with a sheet protected with an unsupported hash format + with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileTypeCombo = xSaveDialog.getChild("file_type") + select_by_text(xFileTypeCombo, "ODF Spreadsheet (.ods)") + + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="") as xRetypePasswordDialog: + # hash error dialog is still displayed (only disabled for the recovery file) + xCancel = xRetypePasswordDialog.getChild("cancel") + + with self.ui_test.execute_dialog_through_action(xCancel, "CLICK"): + # Write error dialog is displayed + pass + + # Check the document is not created + self.assertFalse(os.path.isfile(xFilePath)) + + # Now check it can be saved to ODS using the correct password + with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileTypeCombo = xSaveDialog.getChild("file_type") + select_by_text(xFileTypeCombo, "ODF Spreadsheet (.ods)") + + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK") as xRetypePasswordDialog: + xRetypeBtn = xRetypePasswordDialog.getChild("button") + + with self.ui_test.execute_blocking_action( + xRetypeBtn.executeAction, args=('CLICK', ())) as xPasswordDialog: + xNewPassEntry = xPasswordDialog.getChild("newpassEntry") + xConfirmPassEntry = xPasswordDialog.getChild("confirmpassEntry") + xNewPassEntry.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"})) + xConfirmPassEntry.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"})) + + self.assertTrue(os.path.isfile(xFilePath)) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/pivotTable.py b/sc/qa/uitest/calc_tests9/pivotTable.py new file mode 100644 index 000000000..bb985429f --- /dev/null +++ b/sc/qa/uitest/calc_tests9/pivotTable.py @@ -0,0 +1,99 @@ +# -*- 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, get_url_for_data_file +from libreoffice.calc.document import get_cell_by_position + +class pivotTable(UITestCase): + + def test_cancelButton(self): + + # This is basically a test for cf93998eb5abc193d95ae5433bf4dfd11a9d62d8 + # Without the fix in place, this test would have crashed + + with self.ui_test.load_file(get_url_for_data_file("basicPivotTable.ods")): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "1"})) + + self.xUITest.executeCommand(".uno:GoUp") + + + with self.ui_test.execute_dialog_through_command(".uno:DataDataPilotRun") as xDialog: + xFields = xDialog.getChild("listbox-fields") + self.assertEqual(2, len(xFields.getChildren())) + self.assertEqual("qtX", get_state_as_dict(xFields.getChild('0'))['Text']) + self.assertEqual("qtY", get_state_as_dict(xFields.getChild('1'))['Text']) + + xColumns = xDialog.getChild("listbox-column") + self.assertEqual(1, len(xColumns.getChildren())) + self.assertEqual("Data", get_state_as_dict(xColumns.getChild('0'))['Text']) + + xPage = xDialog.getChild("listbox-page") + self.assertEqual(1, len(xPage.getChildren())) + xPageChild = xPage.getChild('0') + self.assertEqual("qtX", get_state_as_dict(xPageChild)['Text']) + + with self.ui_test.execute_blocking_action(xPageChild.executeAction, args=('DOUBLECLICK', ())) as dialog: + optionBtn = dialog.getChild("options") + + with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ())) as dialog2: + xEmptyLine = dialog2.getChild("emptyline") + + xEmptyLine.executeAction("CLICK", tuple()) + self.assertEqual('true', get_state_as_dict(xEmptyLine)['Selected']) + + with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog2: + xEmptyLine = dialog2.getChild("emptyline") + + xEmptyLine.executeAction("CLICK", tuple()) + self.assertEqual('false', get_state_as_dict(xEmptyLine)['Selected']) + + with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ())) as dialog2: + xEmptyLine = dialog2.getChild("emptyline") + + self.assertEqual('true', get_state_as_dict(xEmptyLine)['Selected']) + + def test_popup(self): + with self.ui_test.load_file(get_url_for_data_file("pivotTable.ods")) as calc_doc: + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + self.assertEqual("a", get_cell_by_position(calc_doc, 0, 3, 1).getString()) + self.assertEqual("b", get_cell_by_position(calc_doc, 0, 3, 2).getString()) + self.assertEqual("m", get_cell_by_position(calc_doc, 0, 4, 1).getString()) + self.assertEqual("n", get_cell_by_position(calc_doc, 0, 4, 2).getString()) + self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 1).getString()) + self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 2).getString()) + + gridwin.executeAction("LAUNCH", mkPropertyValues({"PIVOTTABLE": "", "COL": "3", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("FilterDropDown") + + xTreeList = xCheckListMenu.getChild("check_list_box") + xFirstEntry = xTreeList.getChild("0") + + xFirstEntry.executeAction("CLICK", tuple()) + + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + self.assertEqual("b", get_cell_by_position(calc_doc, 0, 3, 1).getString()) + self.assertEqual("Total Result", get_cell_by_position(calc_doc, 0, 3, 2).getString()) + self.assertEqual("n", get_cell_by_position(calc_doc, 0, 4, 1).getString()) + self.assertEqual("", get_cell_by_position(calc_doc, 0, 4, 2).getString()) + self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 1).getString()) + self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 2).getString()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf113571.py b/sc/qa/uitest/calc_tests9/tdf113571.py new file mode 100644 index 000000000..0dc337ca6 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf113571.py @@ -0,0 +1,38 @@ +# -*- 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 +from libreoffice.uno.propertyvalue import mkPropertyValues + +class Tdf113571(UITestCase): + + def test_tdf113571(self): + with self.ui_test.load_file(get_url_for_data_file("tdf113571.ods")): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_empty_file("writer") as writer_document: + + self.xUITest.getTopFocusWindow() + + self.xUITest.executeCommand(".uno:PasteUnformatted") + + # Without the fix in place, this test would have failed with + # AssertionError: '<?xml version="1.0" encoding="UTF-8"?>\n<[34 chars]est>' != + # '"<?xml version=""1.0"" encoding=""UTF-8""[40 chars]st>"' + self.assertEqual('<?xml version="1.0" encoding="UTF-8"?>\n<test>\n <hello>world</hello>\n</test>', + writer_document.Text.String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests9/tdf115933.py b/sc/qa/uitest/calc_tests9/tdf115933.py new file mode 100644 index 000000000..0fe7fec06 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf115933.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 uitest.uihelper.common import get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 115933 - XLSX <fileSharing> password protected with algorithmName, hashValue, saltValue and spinCount + +class tdf115933(UITestCase): + + def test_tdf115933(self): + with self.ui_test.load_file(get_url_for_data_file("tdf115933.xlsx")): + #The document was created in Excel. + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + document = self.ui_test.get_component() + + self.assertTrue(document.isReadonly()) + + #Without the fix in place, this dialog wouldn't have been displayed + with self.ui_test.execute_dialog_through_action(gridwin, "TYPE", mkPropertyValues({"KEYCODE": "CTRL+SHIFT+M"})) as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "a"})) + + self.assertFalse(document.isReadonly()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf117879.py b/sc/qa/uitest/calc_tests9/tdf117879.py new file mode 100644 index 000000000..6e3049e6c --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf117879.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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import type_text +from libreoffice.calc.document import get_cell_by_position + +class tdf117879(UITestCase): + + def test_tdf117879(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + type_text(gridwin, "=SUM({A1},2,3,4,5}") + + # Without the fix in place, this dialog wouldn't have been displayed + with self.ui_test.execute_blocking_action(gridwin.executeAction, + args=("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})), close_button="yes"): + pass + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getFormula(), "=SUM({A1};2;3;4;5)") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + type_text(gridwin, "=SUM({A1},2,3,4,5}") + + with self.ui_test.execute_blocking_action(gridwin.executeAction, + args=("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})), close_button="no"): + pass + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getFormula(), "=SUM({A1};2;3;4;5})") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf118938.py b/sc/qa/uitest/calc_tests9/tdf118938.py new file mode 100644 index 000000000..eede90451 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf118938.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_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 118938 - FILESAVE to Microsoft Excel 2007-2013 XML (.xlsx) files as read-only +# with additional password protection for editing not working (Calc) + +class tdf118938(UITestCase): + + def test_tdf118938(self): + with self.ui_test.load_file(get_url_for_data_file("tdf118938.xlsx")): + #The document was created in Calc after this fix. + document = self.ui_test.get_component() + + # Without the fix in place, this test would have failed with + # AssertionError: False is not true + self.assertTrue(document.isReadonly()) + + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "a"})) + + self.assertFalse(document.isReadonly()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf121949.py b/sc/qa/uitest/calc_tests9/tdf121949.py new file mode 100644 index 000000000..03e501234 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf121949.py @@ -0,0 +1,27 @@ +# -*- 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 + +class tdf121949 (UITestCase): + + def test_tdf121949_copy_block_with_single_cell_not_included(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + # mark a range with a single cell left our and copy to clipboard + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B1", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B3:B3", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C3", "EXTEND":"1"})) + with self.ui_test.execute_dialog_through_command(".uno:Copy"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf124318.py b/sc/qa/uitest/calc_tests9/tdf124318.py new file mode 100644 index 000000000..9fae2d5b4 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf124318.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, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf124318(UITestCase): + + def test_tdf124318(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf124318.xls")): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B4"})) + + with self.ui_test.execute_dialog_through_action(gridwin, "TYPE", mkPropertyValues({"KEYCODE": "CTRL+k"})) as xDialog: + # Without the fix in place, this test would have failed with + # AssertionError: 'mobile/identification/authentification' != + # 'mobile/identification/authentification%00塹\uf481ᴻ䡿ⲯ嶂藄挧%00%00ꮥ%00' + self.assertEqual("mobile/identification/authentification", + get_state_as_dict(xDialog.getChild("target"))['Text'].split(".fr/")[1]) + self.assertEqual("mobile/identification/authentification", + get_state_as_dict(xDialog.getChild("indication"))['Text'].split(".fr/")[1]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf125440.py b/sc/qa/uitest/calc_tests9/tdf125440.py new file mode 100644 index 000000000..a5319d582 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf125440.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 libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.common import get_url_for_data_file + +class Tdf1254400(UITestCase): + + def test_tdf125440(self): + # In order to simulate copy&paste from external source, + # import the text in Writer, copy it and paste it in Calc + with self.ui_test.load_file(get_url_for_data_file("tdf125440.odt")): + + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_empty_file("calc") as calc_document: + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + self.xUITest.executeCommand(".uno:PasteUnformatted") + + # Without the fix in place, this test would have failed with + # AssertionError: 'Row' != '"Row"' + self.assertEqual("Row", get_cell_by_position(calc_document, 0, 0, 0).getString()) + self.assertEqual("", get_cell_by_position(calc_document, 0, 1, 0).getString()) + self.assertEqual("", get_cell_by_position(calc_document, 0, 2, 0).getString()) + self.assertEqual("50", get_cell_by_position(calc_document, 0, 3, 0).getString()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf126541_GridVisibilityImportXlsx.py b/sc/qa/uitest/calc_tests9/tdf126541_GridVisibilityImportXlsx.py new file mode 100644 index 000000000..91c71f154 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf126541_GridVisibilityImportXlsx.py @@ -0,0 +1,29 @@ +# -*- 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 + +class tdf126541(UITestCase): + + def test_tdf126541_GridVisibilityImportXlsx(self): + # Import an ods file with 'Hide' global grid visibility setting. + with self.ui_test.load_file(get_url_for_data_file("tdf126541_GridOffGlobally.ods")) as document: + controller = document.getCurrentController() + grid = controller.ShowGrid + self.assertEqual(grid, False) + + # Importing xlsx file should set the global grid visibility setting to 'Show' + # Sheet based grid line visibility setting should not overwrite the global setting. + with self.ui_test.load_file(get_url_for_data_file("tdf126541_GridOff.xlsx")) as document: + controller = document.getCurrentController() + grid = controller.ShowGrid + self.assertEqual(grid, True) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf126673.py b/sc/qa/uitest/calc_tests9/tdf126673.py new file mode 100644 index 000000000..7d60d5195 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf126673.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 change_measurement_unit +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 126673 - Calc: Auto-fit column and auto-fit row don't work with line break +class tdf126673(UITestCase): + def test_tdf126673_auto_fit_row_height(self): + with self.ui_test.load_file(get_url_for_data_file("tdf126673.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A2 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + #optimal row height + with self.ui_test.execute_dialog_through_command(".uno:SetOptimalRowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual("0.00 cm", get_state_as_dict(xvalue)["Text"]) + + #select A2 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + #row height + with self.ui_test.execute_dialog_through_command(".uno:RowHeight", close_button="cancel") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual("1.24 cm", get_state_as_dict(xvalue)["Text"]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf130371.py b/sc/qa/uitest/calc_tests9/tdf130371.py new file mode 100644 index 000000000..8e7c09159 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf130371.py @@ -0,0 +1,57 @@ +# -*- 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, get_url_for_data_file + +class namedRanges(UITestCase): + + def test_tdf130371(self): + with self.ui_test.load_file(get_url_for_data_file("tdf130371.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + text1 = "value\t$Sheet2.$B$2\tSheet2" + text2 = "value\t$Sheet3.$B$2\tSheet3" + text3 = "value\t$Sheet4.$B$2\tSheet4" + + with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog: + namesList = xDialog.getChild('names') + self.assertEqual(2, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + self.xUITest.executeCommand(".uno:Copy") + + self.xUITest.executeCommand(".uno:JumpToNextTable") + self.xUITest.executeCommand(".uno:JumpToNextTable") + + self.xUITest.executeCommand(".uno:Paste") + + with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog: + namesList = xDialog.getChild('names') + self.assertEqual(3, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + self.assertEqual(get_state_as_dict(namesList.getChild('2'))["Text"], text3) + + + self.xUITest.executeCommand(".uno:Undo") + + with self.ui_test.execute_dialog_through_command(".uno:DefineName", close_button="cancel") as xDialog: + namesList = xDialog.getChild('names') + self.assertEqual(2, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf133629.py b/sc/qa/uitest/calc_tests9/tdf133629.py new file mode 100644 index 000000000..8b28fcb99 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf133629.py @@ -0,0 +1,57 @@ +# -*- 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, select_pos +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf133629(UITestCase): + + def test_tdf133629(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + + self.xUITest.executeCommand(".uno:TableSelectAll") + + self.xUITest.executeCommand(".uno:SelectAll") + + # Check both sheets are selected + self.assertIsNotNone(getattr(document.CurrentSelection, 'Sheet1.A1:AMJ1048576')) + self.assertIsNotNone(getattr(document.CurrentSelection, 'Sheet2.A1:AMJ1048576')) + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") + + xPresets = xDialog.getChild("presets") + xPresets.executeAction("CHOOSE", mkPropertyValues({"POS": "4"})) + + # Change width + xLineWidth = xDialog.getChild("linewidthmf") + xLineWidth.executeAction("UP", tuple()) + xLineWidth.executeAction("UP", tuple()) + self.assertEqual("1.25 pt", get_state_as_dict(xLineWidth)['Text']) + + + # Without the fix in place, this test would have crash here + + xA1Sheet1 = document.Sheets[0].getCellRangeByName("A1") + self.assertEqual(44, xA1Sheet1.BottomBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet1.TopBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet1.LeftBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet1.RightBorder.OuterLineWidth) + + xA1Sheet2 = document.Sheets[1].getCellRangeByName("A1") + self.assertEqual(44, xA1Sheet2.BottomBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet2.TopBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet2.LeftBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet2.RightBorder.OuterLineWidth) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf135761.py b/sc/qa/uitest/calc_tests9/tdf135761.py new file mode 100755 index 000000000..fd9e5ebda --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf135761.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 libreoffice.calc.document import get_cell_by_position + +class tdf135761(UITestCase): + def test_tdf135761_ctrl_backspace(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Enter text including two whitespaces in the text, and delete the left part of the text + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "a b"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"F2"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+BACKSPACE"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + # Without the fix in place, this test would have failed with + # AssertionError: ' b' != 'a b' + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), " b") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf137446.py b/sc/qa/uitest/calc_tests9/tdf137446.py new file mode 100644 index 000000000..e6aa04667 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf137446.py @@ -0,0 +1,51 @@ +# -*- 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 change_measurement_unit +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf137446(UITestCase): + + def test_tdf137446(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf137446.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "lineObject"})) + + with self.ui_test.execute_dialog_through_command(".uno:TransformDialog") as xDialog: + + + self.assertEqual('10', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value']) + self.assertEqual('0', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value']) + self.assertEqual('5.51', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value']) + self.assertEqual('2.55', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_Y'))['Value']) + self.assertEqual('0', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value']) + + + xDialog.getChild('MTR_FLD_WIDTH').executeAction("UP", tuple()) + + + with self.ui_test.execute_dialog_through_command(".uno:TransformDialog") as xDialog: + + + self.assertEqual('10.1', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value']) + self.assertEqual('0', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value']) + self.assertEqual('5.51', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value']) + self.assertEqual('2.55', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_Y'))['Value']) + + # Without the fix in place, this test would have failed with AssertionError: '0' != '180' + self.assertEqual('0', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value']) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf141244.py b/sc/qa/uitest/calc_tests9/tdf141244.py new file mode 100644 index 000000000..b292bfefe --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf141244.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 uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict + + +class tdf141244(UITestCase): + + def test_tdf141244(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", '=DDE("soffice";"data1.ods";"sheet1.A1")') + + with self.ui_test.execute_dialog_through_command(".uno:EditLinks", close_button="close") as xDialog: + + xLinks = xDialog.getChild("TB_LINKS") + self.assertEqual(1, len(xLinks.getChildren())) + + xChangeBtn = xDialog.getChild("CHANGE_SOURCE") + + with self.ui_test.execute_blocking_action(xChangeBtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog: + self.assertEqual("soffice", get_state_as_dict(dialog.getChild("app"))['Text']) + self.assertEqual("data1.ods", get_state_as_dict(dialog.getChild("file"))['Text']) + self.assertEqual("sheet1.A1", get_state_as_dict(dialog.getChild("category"))['Text']) + + # tdf#141770: Without the fix in place, the cancel button wouldn't have worked here + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf142763.py b/sc/qa/uitest/calc_tests9/tdf142763.py new file mode 100644 index 000000000..548be27b4 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf142763.py @@ -0,0 +1,71 @@ +# -*- 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, select_pos + +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class Tdf142763(UITestCase): + + def test_tdf142763_header(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + with self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog") as xPageFormatDialog: + xTabControl = xPageFormatDialog.getChild("tabcontrol") + select_pos(xTabControl, "4") + + xHeaderOnBtn = xPageFormatDialog.getChild("checkHeaderOn") + xHeaderOnBtn.executeAction("CLICK", tuple()) + xFirstHeaderSameBtn = xPageFormatDialog.getChild("checkSameFP") + xFirstHeaderSameBtn.executeAction("CLICK", tuple()) + + with self.ui_test.execute_dialog_through_command(".uno:EditHeaderAndFooter") as xHeaderDialog: + xLeftTextWindow = xHeaderDialog.getChild("textviewWND_LEFT") + xLeftTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "first"})) + xCenterTextWindow = xHeaderDialog.getChild("textviewWND_CENTER") + xCenterTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "page | "})) + xRightTextWindow = xHeaderDialog.getChild("textviewWND_RIGHT") + xRightTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "header"})) + + self.assertEqual("first", get_state_as_dict(xLeftTextWindow)["Text"]) + self.assertEqual("page | Sheet1", get_state_as_dict(xCenterTextWindow)["Text"]) + self.assertEqual("header", get_state_as_dict(xRightTextWindow)["Text"]) + + def test_tdf142763_footer(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + with self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog") as xPageFormatDialog: + xTabControl = xPageFormatDialog.getChild("tabcontrol") + select_pos(xTabControl, "5") + + xFooterOnBtn = xPageFormatDialog.getChild("checkFooterOn") + xFooterOnBtn.executeAction("CLICK", tuple()) + xFirstFooterSameBtn = xPageFormatDialog.getChild("checkSameFP") + xFirstFooterSameBtn.executeAction("CLICK", tuple()) + + with self.ui_test.execute_dialog_through_command(".uno:EditHeaderAndFooter") as xFooterDialog: + xLeftTextWindow = xFooterDialog.getChild("textviewWND_LEFT") + xLeftTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "first"})) + xCenterTextWindow = xFooterDialog.getChild("textviewWND_CENTER") + xCenterTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "page | "})) + xRightTextWindow = xFooterDialog.getChild("textviewWND_RIGHT") + xRightTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "footer"})) + + self.assertEqual("first", get_state_as_dict(xLeftTextWindow)["Text"]) + self.assertEqual("page | Sheet1", get_state_as_dict(xCenterTextWindow)["Text"]) + self.assertEqual("footer", get_state_as_dict(xRightTextWindow)["Text"]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf144996.py b/sc/qa/uitest/calc_tests9/tdf144996.py new file mode 100644 index 000000000..eabd61ddb --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf144996.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 +from uitest.uihelper.common import get_url_for_data_file + +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class tdf144996(UITestCase): + + def test_tdf144996(self): + + # get_url_for_data_file calls makeCopyFromTDOC + # so using save doesn't affect the original file + xFilePath = get_url_for_data_file("tdf144996.xlsx") + + with self.ui_test.load_file(xFilePath) as document: + + self.assertTrue(document.isReadonly()) + + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + self.assertFalse(document.isReadonly()) + + with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="save"): + # Confirm file format popup + pass + + with self.ui_test.load_file(xFilePath) as document: + + self.assertTrue(document.isReadonly()) + + # Without the fix in place, this test would have failed here because the saved document + # doesn't need a password to edit it + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + self.assertFalse(document.isReadonly()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf148437.py b/sc/qa/uitest/calc_tests9/tdf148437.py new file mode 100644 index 000000000..d457b2324 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf148437.py @@ -0,0 +1,53 @@ +# -*- 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 libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict, select_pos + +class tdf148437(UITestCase): + def test_tdf148437_formula_cell(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Select a cell including a formula and insert a hyperlink + enter_text_to_cell(xGridWindow, "A1", "=HYPERLINK(\"www.libreoffice.org\";\"LibreOffice\")") + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "https://www.documentfoundation.org/"})) + xIndication.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xIndication.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice Document Foundation"})) + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Check contents of the cell + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice Document Foundation") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "https://www.documentfoundation.org/") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf80043.py b/sc/qa/uitest/calc_tests9/tdf80043.py new file mode 100644 index 000000000..eb99f0038 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf80043.py @@ -0,0 +1,243 @@ +# -*- 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 libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict, select_pos + +class tdf80043(UITestCase): + def test_tdf80043_empty_cell(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Select an empty cell and insert a hyperlink + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Both fields in the hyperlink dialog should be empty + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "http://www.libreoffice.org/"})) + xIndication.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice"})) + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Check contents of the cell + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "http://www.libreoffice.org/") + + # Reopen hyperlink dialog and check the target and the indication of the hyperlink + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog", close_button="cancel") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "http://www.libreoffice.org/") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice") + + def test_tdf80043_text_cell(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Select a cell including a text and insert a hyperlink + enter_text_to_cell(xGridWindow, "A1", "LibreOffice") + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "http://www.libreoffice.org/"})) + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Check contents of the cell + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "http://www.libreoffice.org/") + + # Reopen hyperlink dialog and check the target and the indication of the hyperlink + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog", close_button="cancel") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "http://www.libreoffice.org/") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice") + + def test_tdf80043_link_text_cell(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Select a cell including a text and insert a hyperlink + enter_text_to_cell(xGridWindow, "A1", "LibreOffice") + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "http://www.libreoffice.org/"})) + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Insert an additional text without a hyperlink in the cell including a hyperlink + self.xUITest.executeCommand(".uno:SetInputMode") + enter_text_to_cell(xGridWindow, "A1", " Document Foundation") + + # Check contents of the cell + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice Document Foundation") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "http://www.libreoffice.org/") + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Reopen hyperlink dialog and check the target and the indication of the hyperlink + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "https://www.documentfoundation.org/"})) + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice Document Foundation") + + # Check contents of the cell - move focus, otherwise text fields won't be updated + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice Document Foundation") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "https://www.documentfoundation.org/") + + def test_tdf80043_link_link_cell(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Select a cell including a text and insert a hyperlink + enter_text_to_cell(xGridWindow, "A1", "Libre") + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "Libre") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "http://www.libreoffice.org/"})) + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Insert an additional hyperlink in the cell + self.xUITest.executeCommand(".uno:SetInputMode") + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE": "Office Document Foundation"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE": "SHIFT+CTRL+LEFT"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "Foundation") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "https://www.documentfoundation.org/"})) + + # Check contents of the cell + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice Document Foundation") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 2) + self.assertEqual(xTextFields.getByIndex(0).URL, "http://www.libreoffice.org/") + self.assertEqual(xTextFields.getByIndex(1).URL, "https://www.documentfoundation.org/") + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Reopen hyperlink dialog and check the target and the indication of the hyperlink + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "https://wiki.documentfoundation.org/Main_Page"})) + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice Document Foundation") + + # Check contents of the cell - move focus, otherwise text fields won't be updated + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice Document Foundation") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "https://wiki.documentfoundation.org/Main_Page") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf95554.py b/sc/qa/uitest/calc_tests9/tdf95554.py new file mode 100644 index 000000000..734711e41 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf95554.py @@ -0,0 +1,51 @@ +# -*- 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.calc import enter_text_to_cell + +import platform + +class Tdf95554(UITestCase): + + def test_tdf95554(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "A2", "B") + enter_text_to_cell(gridwin, "A3", "C") + enter_text_to_cell(gridwin, "A4", "D") + enter_text_to_cell(gridwin, "A5", "E") + enter_text_to_cell(gridwin, "A6", "F") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A3:A3", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A5:A5", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A6:A6", "EXTEND":"1"})) + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_empty_file("writer") as writer_document: + + self.xUITest.getTopFocusWindow() + self.xUITest.executeCommand(".uno:PasteUnformatted") + + # Without the fix, the test breaks here with: + #AssertionError: 'A\n\nC\n\nE\nF' != 'A' + + if platform.system() == "Windows": + self.assertEqual('A\r\n\r\nC\r\n\r\nE\r\nF', + writer_document.Text.String) + else: + self.assertEqual('A\n\nC\n\nE\nF', + writer_document.Text.String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file |