uitest/UITestCase.py | 36 -------- uitest/calc_tests/about_test.py | 2 uitest/calc_tests/create_chart.py | 2 uitest/calc_tests/create_range_name.py | 2 uitest/calc_tests/function_wizard.py | 2 uitest/calc_tests/gridwin.py | 2 uitest/calc_tests/gridwindow.py | 4 uitest/connection.py | 139 -------------------------------- uitest/demo_ui/char_dialog.py | 8 - uitest/demo_ui/checkbox.py | 2 uitest/demo_ui/combobox.py | 2 uitest/demo_ui/edit.py | 2 uitest/demo_ui/gridwin.py | 2 uitest/demo_ui/listbox.py | 2 uitest/demo_ui/radiobutton.py | 2 uitest/demo_ui/spinfield.py | 2 uitest/demo_ui/tabcontrol.py | 4 uitest/demo_ui/tabdialog.py | 2 uitest/demo_ui/treelist.py | 4 uitest/helper.py | 38 -------- uitest/impress_tests/start.py | 2 uitest/libreoffice/connection.py | 139 ++++++++++++++++++++++++++++++++ uitest/libreoffice/uno/eventlistener.py | 50 +++++++++++ uitest/main.py | 75 ----------------- uitest/test_main.py | 13 ++ uitest/uihelper/calc.py | 15 --- uitest/uitest/config.py | 10 ++ uitest/uitest/debug.py | 16 +++ uitest/uitest/framework.py | 36 ++++++++ uitest/uitest/uihelper/calc.py | 15 +++ uitest/uitest_helper.py | 2 uitest/writer_tests/start.py | 2 32 files changed, 301 insertions(+), 333 deletions(-)
New commits: commit 6402c19c9b4d51dd7feaa3129b6f15b20704d356 Author: Markus Mohrhard <[email protected]> Date: Sun Jun 26 03:26:22 2016 +0200 uitest: move the EventListener to an own file in the new dir structure Change-Id: I8d6c2d9f2a9386d8eec64780b7d197c9675764aa diff --git a/uitest/helper.py b/uitest/helper.py index b993041..9b24bee 100644 --- a/uitest/helper.py +++ b/uitest/helper.py @@ -18,44 +18,6 @@ except ImportError: print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc") raise -try: - from com.sun.star.document import XDocumentEventListener -except ImportError: - print("UNO API class not found: try to set URE_BOOTSTRAP variable") - print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc") - raise - -class EventListener(XDocumentEventListener,unohelper.Base): - - def __init__(self, xContext, eventNames): - self.xGEB = xContext.ServiceManager.createInstanceWithContext( - "com.sun.star.frame.GlobalEventBroadcaster", xContext) - self.xContext = xContext - self.executed = False - self.eventExecuted = [] - if isinstance(eventNames, str): - self.eventNames = [eventNames] - elif isinstance(eventNames, list): - self.eventNames = eventNames - - def __enter__(self): - self.xGEB.addDocumentEventListener(self) - return self - - def __exit__(self, type, value, traceback): - self.xGEB.removeDocumentEventListener(self) - - def documentEventOccured(self, event): - if event.EventName in self.eventNames: - self.executed = True - self.eventExecuted.append(event.EventName) - - def hasExecuted(self, eventName): - return eventName in self.eventExecuted - - def disposing(event): - pass - def mkPropertyValue(name, value): """ Create a UNO ProertyValue from two input values. """ diff --git a/uitest/libreoffice/uno/eventlistener.py b/uitest/libreoffice/uno/eventlistener.py new file mode 100644 index 0000000..63eb0e6 --- /dev/null +++ b/uitest/libreoffice/uno/eventlistener.py @@ -0,0 +1,50 @@ +# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +try: + import pyuno + import uno + import unohelper + from com.sun.star.document import XDocumentEventListener +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 EventListener(XDocumentEventListener,unohelper.Base): + + def __init__(self, xContext, eventNames): + self.xGEB = xContext.ServiceManager.createInstanceWithContext( + "com.sun.star.frame.GlobalEventBroadcaster", xContext) + self.xContext = xContext + self.executed = False + self.eventExecuted = [] + if isinstance(eventNames, str): + self.eventNames = [eventNames] + elif isinstance(eventNames, list): + self.eventNames = eventNames + + def __enter__(self): + self.xGEB.addDocumentEventListener(self) + return self + + def __exit__(self, type, value, traceback): + self.xGEB.removeDocumentEventListener(self) + + def documentEventOccured(self, event): + if event.EventName in self.eventNames: + self.executed = True + self.eventExecuted.append(event.EventName) + + def hasExecuted(self, eventName): + return eventName in self.eventExecuted + + def disposing(event): + pass + +# vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/uitest/uitest_helper.py b/uitest/uitest_helper.py index 925010e..049929c 100644 --- a/uitest/uitest_helper.py +++ b/uitest/uitest_helper.py @@ -7,7 +7,7 @@ import time -from helper import EventListener +from libreoffice.uno.eventlistener import EventListener from helper import convert_property_values_to_dict commit 65979ca6ebf341a4733b2755d099e365e6dd0fa0 Author: Markus Mohrhard <[email protected]> Date: Sun Jun 26 03:03:52 2016 +0200 uitest: add a way to have sleeps in some test runs Now adding a -d or --debug to the command line options will enable the sleeps in the uitest.debug part. This makes it much easier to debug a test in the visual mode. Only remaining part is now to add a test runner into the build system that makes use of that mode. Change-Id: I03d55b10f06dd12a63a8d87c135967901bef0fba diff --git a/uitest/demo_ui/char_dialog.py b/uitest/demo_ui/char_dialog.py index 903b2b1..06c17bb 100644 --- a/uitest/demo_ui/char_dialog.py +++ b/uitest/demo_ui/char_dialog.py @@ -10,7 +10,7 @@ from uitest_helper import UITest from helper import mkPropertyValues from uitest.framework import UITestCase -import time +from uitest.debug import sleep class CharDialogText(UITestCase): @@ -21,13 +21,13 @@ class CharDialogText(UITestCase): xCharDialog = self.xUITest.getTopFocusWindow() print(xCharDialog.getChildren()) - time.sleep(5) + sleep(5) xCharSet = xCharDialog.getChild("showcharset") xCharSet.executeAction("SELECT", mkPropertyValues({"COLUMN": "2", "ROW": "2"})) - time.sleep(5) + sleep(5) xCancelBtn = xCharDialog.getChild("cancel") xCancelBtn.executeAction("CLICK", tuple()) diff --git a/uitest/test_main.py b/uitest/test_main.py index c755336..97afeb4 100644 --- a/uitest/test_main.py +++ b/uitest/test_main.py @@ -13,13 +13,15 @@ import calc_tests import importlib import importlib.machinery +import uitest.config + from uitest.framework import UITestCase from libreoffice.connection import OfficeConnection def parseArgs(argv): - (optlist,args) = getopt.getopt(argv[1:], "hr", - ["help", "soffice=", "userdir=", "dir=", "file="]) + (optlist,args) = getopt.getopt(argv[1:], "hdr", + ["help", "debug", "soffice=", "userdir=", "dir=", "file="]) return (dict(optlist), args) def usage(): @@ -101,6 +103,9 @@ if __name__ == '__main__': usage() sys.exit() + if "-d" in opts or "--debug" in opts: + uitest.config.use_sleep = True + result = unittest.TextTestRunner(verbosity=2).run(test_suite) print("Tests run: %d" % result.testsRun) print("Tests failed: %d" % len(result.failures)) diff --git a/uitest/uitest/config.py b/uitest/uitest/config.py new file mode 100644 index 0000000..fa13274 --- /dev/null +++ b/uitest/uitest/config.py @@ -0,0 +1,10 @@ +# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +use_sleep = False + +# vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/uitest/uitest/debug.py b/uitest/uitest/debug.py new file mode 100644 index 0000000..8af6d8a --- /dev/null +++ b/uitest/uitest/debug.py @@ -0,0 +1,16 @@ +# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +import uitest.config + +import time + +def sleep(seconds): + if uitest.config.use_sleep: + time.sleep(seconds) + +# vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 901aa845b7b7fe0e0f2ed483d3b8e7b7ffd8b894 Author: Markus Mohrhard <[email protected]> Date: Sun Jun 26 02:29:37 2016 +0200 uitest: move for files into the new directory layout Change-Id: Ic8289da6bd32ed9645253b996269be6e82bd1d7c diff --git a/uitest/calc_tests/gridwindow.py b/uitest/calc_tests/gridwindow.py index 4dfa83a..7620df1 100644 --- a/uitest/calc_tests/gridwindow.py +++ b/uitest/calc_tests/gridwindow.py @@ -9,7 +9,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from uihelper.calc import enter_text_to_cell +from uitest.uihelper.calc import enter_text_to_cell from uitest.framework import UITestCase diff --git a/uitest/demo_ui/tabcontrol.py b/uitest/demo_ui/tabcontrol.py index 222a423..cc04221 100644 --- a/uitest/demo_ui/tabcontrol.py +++ b/uitest/demo_ui/tabcontrol.py @@ -11,7 +11,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from uihelper.calc import enter_text_to_cell +from uitest.uihelper.calc import enter_text_to_cell from uitest.framework import UITestCase diff --git a/uitest/demo_ui/treelist.py b/uitest/demo_ui/treelist.py index 3814344..ef5512a 100644 --- a/uitest/demo_ui/treelist.py +++ b/uitest/demo_ui/treelist.py @@ -10,7 +10,7 @@ import time from uitest_helper import UITest from helper import mkPropertyValues -from uihelper.calc import enter_text_to_cell +from uitest.uihelper.calc import enter_text_to_cell from uitest_helper import get_state_as_dict diff --git a/uitest/uihelper/__init__.py b/uitest/uitest/uihelper/__init__.py similarity index 100% rename from uitest/uihelper/__init__.py rename to uitest/uitest/uihelper/__init__.py diff --git a/uitest/uihelper/calc.py b/uitest/uitest/uihelper/calc.py similarity index 100% rename from uitest/uihelper/calc.py rename to uitest/uitest/uihelper/calc.py commit 0b6acf6fe6256e2b4fc2673b7b226ea2cbb011c5 Author: Markus Mohrhard <[email protected]> Date: Sun Jun 26 01:53:48 2016 +0200 uitest: remove old test runner Change-Id: I5d29fb4c275223d00ca01f57f7fac0aa7b518740 diff --git a/uitest/main.py b/uitest/main.py deleted file mode 100644 index 9039320..0000000 --- a/uitest/main.py +++ /dev/null @@ -1,75 +0,0 @@ -# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -import sys -import getopt -import os -import importlib - -from connection import PersistentConnection, OfficeConnection - -def load_test(name): - if name.startswith("#"): - return None - - module_name, obj_name = name.rsplit(".", 1) - module = importlib.import_module(module_name) - obj = getattr(module, obj_name) - return obj - -def generic_test(opts, test_name): - print("executing: " + test_name) - func = load_test(test_name) - if func is None: - return - - connection = PersistentConnection(opts) - connection.setUp() - xContext = connection.getContext() - func(xContext) - connection.tearDown() - -def parseArgs(argv): - (optlist,args) = getopt.getopt(argv[1:], "hr", - ["help", "soffice=", "userdir=", "calc-demo", "file="]) - return (dict(optlist), args) - -def usage(): - message = """usage: {program} [option]... [task_file]..." - -h | --help: print usage information - {connection_params} - the 'task_file' parameters should be - full absolute pathnames, not URLs.""" - print(message.format(program = os.path.basename(sys.argv[0]), \ - connection_params = OfficeConnection.getHelpText())) - -if __name__ == "__main__": - (opts,args) = parseArgs(sys.argv) - if "-h" in opts or "--help" in opts: - usage() - sys.exit() - elif not "--soffice" in opts: - usage() - sys.exit(1) - elif "--file" in opts: - file_name = opts["--file"] - with open(file_name) as f: - lines = f.readlines() - for line in lines: - line = line.strip() - if len(line) == 0: - continue - generic_test(opts, line) - - elif "--calc-demo" in opts: - generic_test(opts, "calc_tests.about_test.test_about_dlg") - generic_test(opts, "calc_tests.create_range_name.create_range_name") - else: - usage() - sys.exit(1) - -# vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 97ad8133644d8eb7678aa3c180f3d8f9247a0d90 Author: Markus Mohrhard <[email protected]> Date: Sun Jun 26 01:41:17 2016 +0200 uitest: bring some order into the file mess The uitest/uitest directory will be used for the actual uitest framework. The libreoffice directory should contain any common LibreOffice related code. Change-Id: I3f6394ff4be83b89a8764eab10a154e755237d35 diff --git a/uitest/calc_tests/about_test.py b/uitest/calc_tests/about_test.py index df90e7d..1495837 100644 --- a/uitest/calc_tests/about_test.py +++ b/uitest/calc_tests/about_test.py @@ -7,7 +7,7 @@ from uitest_helper import UITest -from UITestCase import UITestCase +from uitest.framework import UITestCase class AboutDlgTest(UITestCase): diff --git a/uitest/calc_tests/create_chart.py b/uitest/calc_tests/create_chart.py index 1bd8276..322618b 100644 --- a/uitest/calc_tests/create_chart.py +++ b/uitest/calc_tests/create_chart.py @@ -9,7 +9,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase import time diff --git a/uitest/calc_tests/create_range_name.py b/uitest/calc_tests/create_range_name.py index 01d01fd..a265970 100644 --- a/uitest/calc_tests/create_range_name.py +++ b/uitest/calc_tests/create_range_name.py @@ -9,7 +9,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase try: import pyuno diff --git a/uitest/calc_tests/function_wizard.py b/uitest/calc_tests/function_wizard.py index bbdb0c1..b7ab11d 100644 --- a/uitest/calc_tests/function_wizard.py +++ b/uitest/calc_tests/function_wizard.py @@ -10,7 +10,7 @@ from uitest_helper import UITest from helper import mkPropertyValues import time -from UITestCase import UITestCase +from uitest.framework import UITestCase try: import pyuno diff --git a/uitest/calc_tests/gridwin.py b/uitest/calc_tests/gridwin.py index 7077f4b..3366dc0 100644 --- a/uitest/calc_tests/gridwin.py +++ b/uitest/calc_tests/gridwin.py @@ -9,7 +9,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase import time diff --git a/uitest/calc_tests/gridwindow.py b/uitest/calc_tests/gridwindow.py index c3b2d1d..4dfa83a 100644 --- a/uitest/calc_tests/gridwindow.py +++ b/uitest/calc_tests/gridwindow.py @@ -11,7 +11,7 @@ from helper import mkPropertyValues from uihelper.calc import enter_text_to_cell -from UITestCase import UITestCase +from uitest.framework import UITestCase import time diff --git a/uitest/demo_ui/char_dialog.py b/uitest/demo_ui/char_dialog.py index 0cf545f..903b2b1 100644 --- a/uitest/demo_ui/char_dialog.py +++ b/uitest/demo_ui/char_dialog.py @@ -8,7 +8,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase import time diff --git a/uitest/demo_ui/checkbox.py b/uitest/demo_ui/checkbox.py index a15d686..718444e 100644 --- a/uitest/demo_ui/checkbox.py +++ b/uitest/demo_ui/checkbox.py @@ -9,7 +9,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase import time diff --git a/uitest/demo_ui/combobox.py b/uitest/demo_ui/combobox.py index b33644b..81c06ba 100644 --- a/uitest/demo_ui/combobox.py +++ b/uitest/demo_ui/combobox.py @@ -9,7 +9,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase class ComboBoxTest(UITestCase): diff --git a/uitest/demo_ui/edit.py b/uitest/demo_ui/edit.py index 8ddbb1c5..bb3b2ee 100644 --- a/uitest/demo_ui/edit.py +++ b/uitest/demo_ui/edit.py @@ -9,7 +9,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase try: import pyuno diff --git a/uitest/demo_ui/gridwin.py b/uitest/demo_ui/gridwin.py index 5c2fae9..60dfac5 100644 --- a/uitest/demo_ui/gridwin.py +++ b/uitest/demo_ui/gridwin.py @@ -9,7 +9,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase import time diff --git a/uitest/demo_ui/listbox.py b/uitest/demo_ui/listbox.py index f6857c2..487d476 100644 --- a/uitest/demo_ui/listbox.py +++ b/uitest/demo_ui/listbox.py @@ -9,7 +9,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase class ListBoxTest(UITestCase): diff --git a/uitest/demo_ui/radiobutton.py b/uitest/demo_ui/radiobutton.py index fef71f5..23d7aba 100644 --- a/uitest/demo_ui/radiobutton.py +++ b/uitest/demo_ui/radiobutton.py @@ -9,7 +9,7 @@ from uitest_helper import UITest from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase import time diff --git a/uitest/demo_ui/spinfield.py b/uitest/demo_ui/spinfield.py index 761c9ac..b581a03 100644 --- a/uitest/demo_ui/spinfield.py +++ b/uitest/demo_ui/spinfield.py @@ -12,7 +12,7 @@ from uitest_helper import get_state_as_dict import time -from UITestCase import UITestCase +from uitest.framework import UITestCase try: import pyuno diff --git a/uitest/demo_ui/tabcontrol.py b/uitest/demo_ui/tabcontrol.py index 1f5712d..222a423 100644 --- a/uitest/demo_ui/tabcontrol.py +++ b/uitest/demo_ui/tabcontrol.py @@ -13,7 +13,7 @@ from helper import mkPropertyValues from uihelper.calc import enter_text_to_cell -from UITestCase import UITestCase +from uitest.framework import UITestCase try: import pyuno diff --git a/uitest/demo_ui/tabdialog.py b/uitest/demo_ui/tabdialog.py index 99e7b9f..0cbc4ec 100644 --- a/uitest/demo_ui/tabdialog.py +++ b/uitest/demo_ui/tabdialog.py @@ -11,7 +11,7 @@ from helper import mkPropertyValues import time -from UITestCase import UITestCase +from uitest.framework import UITestCase class TabDialogTest(UITestCase): diff --git a/uitest/demo_ui/treelist.py b/uitest/demo_ui/treelist.py index 23c1199..3814344 100644 --- a/uitest/demo_ui/treelist.py +++ b/uitest/demo_ui/treelist.py @@ -14,7 +14,7 @@ from uihelper.calc import enter_text_to_cell from uitest_helper import get_state_as_dict -from UITestCase import UITestCase +from uitest.framework import UITestCase try: import pyuno diff --git a/uitest/impress_tests/start.py b/uitest/impress_tests/start.py index f82eb63..2de7482 100644 --- a/uitest/impress_tests/start.py +++ b/uitest/impress_tests/start.py @@ -9,7 +9,7 @@ from uitest_helper import UITest, get_state_as_dict from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase import time diff --git a/uitest/connection.py b/uitest/libreoffice/connection.py similarity index 100% rename from uitest/connection.py rename to uitest/libreoffice/connection.py diff --git a/uitest/test_main.py b/uitest/test_main.py index 4939d05..c755336 100644 --- a/uitest/test_main.py +++ b/uitest/test_main.py @@ -13,9 +13,9 @@ import calc_tests import importlib import importlib.machinery -from UITestCase import UITestCase +from uitest.framework import UITestCase -from connection import PersistentConnection, OfficeConnection +from libreoffice.connection import OfficeConnection def parseArgs(argv): (optlist,args) = getopt.getopt(argv[1:], "hr", diff --git a/uitest/UITestCase.py b/uitest/uitest/framework.py similarity index 93% rename from uitest/UITestCase.py rename to uitest/uitest/framework.py index 5e08804..a6f804b 100644 --- a/uitest/UITestCase.py +++ b/uitest/uitest/framework.py @@ -10,7 +10,7 @@ import time from uitest_helper import UITest -from connection import PersistentConnection, OfficeConnection +from libreoffice.connection import PersistentConnection, OfficeConnection class UITestCase(unittest.TestCase): diff --git a/uitest/writer_tests/start.py b/uitest/writer_tests/start.py index 13d99c9..40aebcb 100644 --- a/uitest/writer_tests/start.py +++ b/uitest/writer_tests/start.py @@ -9,7 +9,7 @@ from uitest_helper import UITest, get_state_as_dict from helper import mkPropertyValues -from UITestCase import UITestCase +from uitest.framework import UITestCase import time _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
