summaryrefslogtreecommitdiffstats
path: root/uitest/demo_ui
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /uitest/demo_ui
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'uitest/demo_ui')
-rw-r--r--uitest/demo_ui/char_dialog.py26
-rw-r--r--uitest/demo_ui/checkbox.py24
-rw-r--r--uitest/demo_ui/combobox.py26
-rw-r--r--uitest/demo_ui/command_with_parameters.py25
-rw-r--r--uitest/demo_ui/data/test.odsbin0 -> 7598 bytes
-rw-r--r--uitest/demo_ui/data/test2.odsbin0 -> 7339 bytes
-rw-r--r--uitest/demo_ui/edit.py47
-rw-r--r--uitest/demo_ui/gridwin.py50
-rw-r--r--uitest/demo_ui/handle_multiple_files.py47
-rw-r--r--uitest/demo_ui/hierarchy.py31
-rw-r--r--uitest/demo_ui/listbox.py30
-rw-r--r--uitest/demo_ui/radiobutton.py24
-rw-r--r--uitest/demo_ui/spinfield.py63
-rw-r--r--uitest/demo_ui/tabcontrol.py36
-rw-r--r--uitest/demo_ui/tabdialog.py30
-rw-r--r--uitest/demo_ui/treelist.py44
16 files changed, 503 insertions, 0 deletions
diff --git a/uitest/demo_ui/char_dialog.py b/uitest/demo_ui/char_dialog.py
new file mode 100644
index 0000000000..9475f3b16e
--- /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 0000000000..7c83d71f0a
--- /dev/null
+++ b/uitest/demo_ui/checkbox.py
@@ -0,0 +1,24 @@
+# -*- 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 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 0000000000..1ec4b30d6f
--- /dev/null
+++ b/uitest/demo_ui/combobox.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 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 0000000000..91d3acec9c
--- /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
new file mode 100644
index 0000000000..571291d265
--- /dev/null
+++ b/uitest/demo_ui/data/test.ods
Binary files differ
diff --git a/uitest/demo_ui/data/test2.ods b/uitest/demo_ui/data/test2.ods
new file mode 100644
index 0000000000..550115cb9a
--- /dev/null
+++ b/uitest/demo_ui/data/test2.ods
Binary files differ
diff --git a/uitest/demo_ui/edit.py b/uitest/demo_ui/edit.py
new file mode 100644
index 0000000000..7a0fbb2b8a
--- /dev/null
+++ b/uitest/demo_ui/edit.py
@@ -0,0 +1,47 @@
+# -*- 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
+
+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 0000000000..272cdffc10
--- /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 0000000000..a15b92deec
--- /dev/null
+++ b/uitest/demo_ui/handle_multiple_files.py
@@ -0,0 +1,47 @@
+# -*- 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
+import time
+
+class HandleFiles(UITestCase):
+
+ def test_load_file(self):
+
+ with self.ui_test.load_file(get_url_for_data_file("test.ods")):
+
+ 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")):
+
+ 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 0000000000..a447de563e
--- /dev/null
+++ b/uitest/demo_ui/hierarchy.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
+
+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 0000000000..b59a7b0a0a
--- /dev/null
+++ b/uitest/demo_ui/listbox.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
+
+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 0000000000..268696e56e
--- /dev/null
+++ b/uitest/demo_ui/radiobutton.py
@@ -0,0 +1,24 @@
+# -*- 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 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 0000000000..6b6a3bce0f
--- /dev/null
+++ b/uitest/demo_ui/spinfield.py
@@ -0,0 +1,63 @@
+# -*- 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
+
+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 0000000000..5a1809c98a
--- /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 0000000000..6ed5bcc069
--- /dev/null
+++ b/uitest/demo_ui/tabdialog.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
+
+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 0000000000..214fc4b08e
--- /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 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: