From 65979ca6ebf341a4733b2755d099e365e6dd0fa0 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sun, 26 Jun 2016 03:03:52 +0200 Subject: 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 --- uitest/demo_ui/char_dialog.py | 6 +++--- uitest/test_main.py | 9 +++++++-- uitest/uitest/config.py | 10 ++++++++++ uitest/uitest/debug.py | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 uitest/uitest/config.py create mode 100644 uitest/uitest/debug.py (limited to 'uitest') diff --git a/uitest/demo_ui/char_dialog.py b/uitest/demo_ui/char_dialog.py index 903b2b199ff7..06c17bb67cb1 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 c75533685174..97afeb43f60c 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 000000000000..fa13274863ff --- /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 000000000000..8af6d8af9e7a --- /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: */ -- cgit