diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-03-24 00:35:18 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-06-18 17:01:42 +0200 |
commit | 29cd5a2f5e14a7f3d95cacb644a69a2df91ea8f8 (patch) | |
tree | 7166981631bfb6791cdc1086837b8656a18699bf /uitest/uitest_helper.py | |
parent | 24d5e156cb82430fd315a55115a3d2b43ef559e6 (diff) |
uitest: move uitest python part from dev-tools
Change-Id: I5a6464cb4e110d1da48b5f525f63e0a7de6dea58
Diffstat (limited to 'uitest/uitest_helper.py')
-rw-r--r-- | uitest/uitest_helper.py | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/uitest/uitest_helper.py b/uitest/uitest_helper.py new file mode 100644 index 000000000000..3f46618e6aa6 --- /dev/null +++ b/uitest/uitest_helper.py @@ -0,0 +1,77 @@ +# -*- 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 time + +from helper import EventListener + +class UITest(object): + + def __init__(self, xUITest, xContext): + self._xUITest = xUITest + self._xContext = xContext + + def execute_dialog_through_command(self, command): + with EventListener(self._xContext, "DialogExecute") as event: + self._xUITest.executeCommand(command) + time_ = 0 + while time_ < 30: + if event.executed: + time.sleep(1) + return + time_ += 1 + time.sleep(1) + + # report a failure here + print("failure execute modal dialog") + + def execute_modeless_dialog_through_command(self, command): + with EventListener(self._xContext, "ModelessDialogVisible") as event: + self._xUITest.executeCommand(command) + time_ = 0 + while time_ < 30: + if event.executed: + time.sleep(1) + return + time_ += 1 + time.sleep(1) + + # report a failure here + print("failure execute modeless dialog") + + def create_doc_in_start_center(self, app): + xStartCenter = self._xUITest.getTopFocusWindow() + xBtn = xStartCenter.getChild(app + "_all") + with EventListener(self._xContext, "OnNew") as event: + xBtn.executeAction("CLICK", tuple()) + time_ = 0 + while time_ < 30: + if event.executed: + return + time_ += 1 + time.sleep(1) + + print("failure doc in start center") + + # report a failure here + + def close_doc(self): + # also need to handle "OnViewClosed" event + with EventListener(self._xContext, "DialogExecute") as event: + self._xUITest.executeCommand(".uno.CloseDoc") + time_ = 0 + while time_ < 30: + if event.executed: + xCloseDlg = self._xUITest.getTopFocusWindow() + xNoBtn = xCloseDlg.getChild("discard") + xNoBtn.executeAction("CLICK", tuple()) + return + + time_ += 1 + time.sleep(1) + +# vim:set shiftwidth=4 softtabstop=4 expandtab: */ |