diff options
Diffstat (limited to '')
-rw-r--r-- | uitest/demo_ui/char_dialog.py | 26 | ||||
-rw-r--r-- | uitest/demo_ui/checkbox.py | 26 | ||||
-rw-r--r-- | uitest/demo_ui/combobox.py | 28 | ||||
-rw-r--r-- | uitest/demo_ui/command_with_parameters.py | 25 | ||||
-rw-r--r-- | uitest/demo_ui/data/test.ods | bin | 0 -> 7598 bytes | |||
-rw-r--r-- | uitest/demo_ui/data/test2.ods | bin | 0 -> 7339 bytes | |||
-rw-r--r-- | uitest/demo_ui/edit.py | 49 | ||||
-rw-r--r-- | uitest/demo_ui/gridwin.py | 50 | ||||
-rw-r--r-- | uitest/demo_ui/handle_multiple_files.py | 49 | ||||
-rw-r--r-- | uitest/demo_ui/hierarchy.py | 33 | ||||
-rw-r--r-- | uitest/demo_ui/listbox.py | 33 | ||||
-rw-r--r-- | uitest/demo_ui/radiobutton.py | 38 | ||||
-rw-r--r-- | uitest/demo_ui/spinfield.py | 65 | ||||
-rw-r--r-- | uitest/demo_ui/tabcontrol.py | 36 | ||||
-rw-r--r-- | uitest/demo_ui/tabdialog.py | 33 | ||||
-rw-r--r-- | uitest/demo_ui/treelist.py | 44 |
16 files changed, 535 insertions, 0 deletions
diff --git a/uitest/demo_ui/char_dialog.py b/uitest/demo_ui/char_dialog.py new file mode 100644 index 000000000..9475f3b16 --- /dev/null +++ b/uitest/demo_ui/char_dialog.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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase + +class CharDialogText(UITestCase): + + def test_select_char(self): + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:InsertSymbol", close_button="cancel") as xCharDialog: + + xCharSet = xCharDialog.getChild("showcharset") + + xCharSet.executeAction("SELECT", mkPropertyValues({"COLUMN": "2", "ROW": "2"})) + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/checkbox.py b/uitest/demo_ui/checkbox.py new file mode 100644 index 000000000..bb0f1f60a --- /dev/null +++ b/uitest/demo_ui/checkbox.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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase + +class CheckBoxTest(UITestCase): + + def test_toggle_checkbox(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xCellsDlg: + xNegativeNumRedCB = xCellsDlg.getChild("negnumred") + xNegativeNumRedCB.executeAction("CLICK",tuple()) + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/combobox.py b/uitest/demo_ui/combobox.py new file mode 100644 index 000000000..56d4a4e79 --- /dev/null +++ b/uitest/demo_ui/combobox.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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase +from uitest.uihelper.common import select_pos + +class ComboBoxTest(UITestCase): + + def test_select_entry_pos(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AddName", close_button="cancel") as xAddNameDlg: + + scopeCB = xAddNameDlg.getChild("scope") + select_pos(scopeCB, "1") + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/command_with_parameters.py b/uitest/demo_ui/command_with_parameters.py new file mode 100644 index 000000000..91d3acec9 --- /dev/null +++ b/uitest/demo_ui/command_with_parameters.py @@ -0,0 +1,25 @@ +# -*- 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 +from libreoffice.uno.propertyvalue import mkPropertyValues + +class CommandWithParametersTest(UITestCase): + + def test_text_color_change(self): + + with self.ui_test.create_doc_in_start_center("writer"): + + self.xUITest.executeCommandWithParameters(".uno:Color", + mkPropertyValues({"Color": 16776960})) + xWriterEdit = self.xUITest.getTopFocusWindow().getChild("writer_edit") + type_text(xWriterEdit, "LibreOffice") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/data/test.ods b/uitest/demo_ui/data/test.ods Binary files differnew file mode 100644 index 000000000..571291d26 --- /dev/null +++ b/uitest/demo_ui/data/test.ods diff --git a/uitest/demo_ui/data/test2.ods b/uitest/demo_ui/data/test2.ods Binary files differnew file mode 100644 index 000000000..550115cb9 --- /dev/null +++ b/uitest/demo_ui/data/test2.ods diff --git a/uitest/demo_ui/edit.py b/uitest/demo_ui/edit.py new file mode 100644 index 000000000..59516b13a --- /dev/null +++ b/uitest/demo_ui/edit.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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase +from uitest.uihelper.common import type_text, get_state_as_dict, select_text + +import time + +class EditTest(UITestCase): + + def test_type_text(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AddName", close_button="cancel") as xAddNameDlg: + + xEdit = xAddNameDlg.getChild("edit") + + type_text(xEdit, "simpleRangeName") + + + + def test_select_text(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AddName", close_button="cancel") as xAddNameDlg: + + xEdit = xAddNameDlg.getChild("edit") + + type_text(xEdit, "simpleRangeName") + xEdit.executeAction("SELECT", mkPropertyValues({"FROM": "2", "TO": "9"})) + type_text(xEdit, "otherChars") + self.assertEqual("siotherCharsgeName", get_state_as_dict(xEdit)["Text"]) + + select_text(xEdit, from_pos="2", to="12") + self.assertEqual("otherChars", get_state_as_dict(xEdit)["SelectedText"]) + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/gridwin.py b/uitest/demo_ui/gridwin.py new file mode 100644 index 000000000..272cdffc1 --- /dev/null +++ b/uitest/demo_ui/gridwin.py @@ -0,0 +1,50 @@ +# -*- 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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase + +class GridWinTest(UITestCase): + + def test_select_cell(self): + + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + selectProps = mkPropertyValues({"CELL": "B10"}) + xGridWindow.executeAction("SELECT", selectProps) + + + def test_select_range(self): + + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + selectProps = mkPropertyValues({"RANGE": "B10:C20"}) + xGridWindow.executeAction("SELECT", selectProps) + + + def test_extend_range(self): + + with self.ui_test.create_doc_in_start_center("calc"): + xTopWindow = self.xUITest.getTopFocusWindow() + + xGridWindow = xTopWindow.getChild("grid_window") + + selectProps = mkPropertyValues({"RANGE": "B10:C20"}) + xGridWindow.executeAction("SELECT", selectProps) + + select2Props = mkPropertyValues({"RANGE": "D3:F5", "EXTEND": "true"}) + xGridWindow.executeAction("SELECT", select2Props) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/handle_multiple_files.py b/uitest/demo_ui/handle_multiple_files.py new file mode 100644 index 000000000..406bb2b51 --- /dev/null +++ b/uitest/demo_ui/handle_multiple_files.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 libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.uno.eventlistener import EventListener +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +import time + +class HandleFiles(UITestCase): + + def test_load_file(self): + + with self.ui_test.load_file(get_url_for_data_file("test.ods")) as calc_file: + + with self.ui_test.load_file(get_url_for_data_file("test2.ods")): + + frames = self.ui_test.get_frames() + self.assertEqual(len(frames), 2) + + frames = self.ui_test.get_frames() + self.assertEqual(len(frames), 1) + + # this is currently still necessary as otherwise + # the command is not forwarded to the correct frame + # TODO: provide an additional event that we can use + # and get rid of the sleep + time.sleep(1) + + def test_select_frame(self): + with self.ui_test.load_file(get_url_for_data_file("test.ods")) as calc_file: + + with self.ui_test.load_file(get_url_for_data_file("test2.ods")): + frames = self.ui_test.get_frames() + self.assertEqual(len(frames), 2) + frames[0].activate() + + frames = self.ui_test.get_frames() + self.assertEqual(len(frames), 1) + + self.assertTrue(frames[0].getTitle().startswith("test2.ods")) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/hierarchy.py b/uitest/demo_ui/hierarchy.py new file mode 100644 index 000000000..19cb4c34b --- /dev/null +++ b/uitest/demo_ui/hierarchy.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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase + +import json + +class CheckBoxTest(UITestCase): + + def test_get_json(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:About", close_button="btnClose") as xAboutDlg: + + + json_string = xAboutDlg.getHierarchy() + print(json_string) + json_content = json.loads(json_string) + print(json_content) + print(json.dumps(json_content, indent=4)) + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/listbox.py b/uitest/demo_ui/listbox.py new file mode 100644 index 000000000..9e762c521 --- /dev/null +++ b/uitest/demo_ui/listbox.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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase +from uitest.uihelper.common import select_pos + +class ListBoxTest(UITestCase): + + def test_select_entry_pos(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog"): + pass + + + def test_select_entry_text(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog"): + pass + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/radiobutton.py b/uitest/demo_ui/radiobutton.py new file mode 100644 index 000000000..cc5a3b67b --- /dev/null +++ b/uitest/demo_ui/radiobutton.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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase + +import time + +try: + import pyuno + import uno + import unohelper +except ImportError: + print("pyuno not found: try to set PYTHONPATH and URE_BOOTSTRAP variables") + print("PYTHONPATH=/installation/opt/program") + print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc") + raise + +class RadioButtonTest(UITestCase): + + def test_toggle_radiobutton(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xCellsDlg: + xNegativeNumRedCB = xCellsDlg.getChild("negnumred") + xNegativeNumRedCB.executeAction("CLICK",tuple()) + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/spinfield.py b/uitest/demo_ui/spinfield.py new file mode 100644 index 000000000..5511fec08 --- /dev/null +++ b/uitest/demo_ui/spinfield.py @@ -0,0 +1,65 @@ +# -*- 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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, type_text, select_pos + +class SpinFieldTest(UITestCase): + + def test_up(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xCellsDlg: + + xDecimalPlaces = xCellsDlg.getChild("leadzerosed") + xDecimalPlaces.executeAction("UP", tuple()) + + decimal_places_state = get_state_as_dict(xDecimalPlaces) + assert(decimal_places_state["Text"] == "2") + + + + def test_down(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xCellsDlg: + + xDecimalPlaces = xCellsDlg.getChild("leadzerosed") + xDecimalPlaces.executeAction("UP", tuple()) + xDecimalPlaces.executeAction("UP", tuple()) + + decimal_places_state = get_state_as_dict(xDecimalPlaces) + assert(decimal_places_state["Text"] == "3") + + xDecimalPlaces.executeAction("DOWN", tuple()) + + decimal_places_state = get_state_as_dict(xDecimalPlaces) + assert(decimal_places_state["Text"] == "2") + + + + def test_text(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xCellsDlg: + + xDecimalPlaces = xCellsDlg.getChild("leadzerosed") + type_text(xDecimalPlaces, "4") + + decimal_places_state = get_state_as_dict(xDecimalPlaces) + assert(decimal_places_state["Text"] == "41") + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/tabcontrol.py b/uitest/demo_ui/tabcontrol.py new file mode 100644 index 000000000..5a1809c98 --- /dev/null +++ b/uitest/demo_ui/tabcontrol.py @@ -0,0 +1,36 @@ +# -*- 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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import select_pos + +from uitest.framework import UITestCase + +class TabControlTest(UITestCase): + + def test_select_pos(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + enter_text_to_cell(xGridWindow, "B2", "=2+3+4") + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog", close_button="cancel") as xFunctionDlg: + + + xTabs = xFunctionDlg.getChild("tabcontrol") + select_pos(xTabs, "1") + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/tabdialog.py b/uitest/demo_ui/tabdialog.py new file mode 100644 index 000000000..73167ea65 --- /dev/null +++ b/uitest/demo_ui/tabdialog.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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase +from uitest.uihelper.common import select_pos + +class TabDialogTest(UITestCase): + + def test_select_tab_page_pos(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog"): + pass + + + def test_select_tab_page_name(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog"): + pass + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/uitest/demo_ui/treelist.py b/uitest/demo_ui/treelist.py new file mode 100644 index 000000000..e80176c52 --- /dev/null +++ b/uitest/demo_ui/treelist.py @@ -0,0 +1,44 @@ +# -*- 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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell + +from uitest.uihelper.common import get_state_as_dict, select_pos + +from uitest.framework import UITestCase + +class TreeListTest(UITestCase): + + def test_expand(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + enter_text_to_cell(xGridWindow, "B2", "=2+3+4") + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog", close_button="cancel") as xFunctionDlg: + + + xTabs = xFunctionDlg.getChild("tabcontrol") + select_pos(xTabs, "1") + + xTreelist = xTabs.getChild("struct") + + xTreeEntry = xTreelist.getChild('0') + + xTreeEntry.executeAction("COLLAPSE", tuple()) + + xTreeEntry.executeAction("EXPAND", tuple()) + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |