Propagate failure out from css.ui.test.XUITest::executeCommand/Dialog

Change-Id: Id7bd2d6f35f45d9957facf56d66cfc57a1e0ef6a
Reviewed-on: https://gerrit.libreoffice.org/39002
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
This commit is contained in:
Stephan Bergmann 2017-06-20 09:45:36 +02:00 committed by Markus Mohrhard
parent a6a447b08d
commit 37c157340f
5 changed files with 20 additions and 21 deletions

View File

@ -19,9 +19,9 @@ class UITEST_DLLPUBLIC UITest
{ {
public: public:
static void executeCommand(const OUString& rCommand); static bool executeCommand(const OUString& rCommand);
static void executeDialog(const OUString& rCommand); static bool executeDialog(const OUString& rCommand);
static std::unique_ptr<UIObject> getFocusTopWindow(); static std::unique_ptr<UIObject> getFocusTopWindow();

View File

@ -16,9 +16,9 @@ module com { module sun { module star { module ui { module test {
interface XUITest interface XUITest
{ {
void executeCommand([in] string command); boolean executeCommand([in] string command);
void executeDialog([in] string command); boolean executeDialog([in] string command);
XUIObject getTopFocusWindow(); XUIObject getTopFocusWindow();

View File

@ -70,7 +70,8 @@ class UITest(object):
def execute_dialog_through_command(self, command): def execute_dialog_through_command(self, command):
with EventListener(self._xContext, "DialogExecute") as event: with EventListener(self._xContext, "DialogExecute") as event:
self._xUITest.executeDialog(command) if not self._xUITest.executeDialog(command):
raise DialogNotExecutedException(command)
time_ = 0 time_ = 0
while time_ < MAX_WAIT: while time_ < MAX_WAIT:
if event.executed: if event.executed:
@ -83,7 +84,8 @@ class UITest(object):
def execute_modeless_dialog_through_command(self, command): def execute_modeless_dialog_through_command(self, command):
with EventListener(self._xContext, "ModelessDialogVisible") as event: with EventListener(self._xContext, "ModelessDialogVisible") as event:
self._xUITest.executeCommand(command) if not self._xUITest.executeCommand(command):
raise DialogNotExecutedException(command)
time_ = 0 time_ = 0
while time_ < MAX_WAIT: while time_ < MAX_WAIT:
if event.executed: if event.executed:
@ -160,7 +162,8 @@ class UITest(object):
def close_doc(self): def close_doc(self):
with EventListener(self._xContext, ["DialogExecute", "OnViewClosed"] ) as event: with EventListener(self._xContext, ["DialogExecute", "OnViewClosed"] ) as event:
self._xUITest.executeDialog(".uno:CloseDoc") if not self._xUITest.executeDialog(".uno:CloseDoc"):
print(".uno:CloseDoc failed")
time_ = 0 time_ = 0
while time_ < MAX_WAIT: while time_ < MAX_WAIT:
if event.hasExecuted("DialogExecute"): if event.hasExecuted("DialogExecute"):

View File

@ -17,24 +17,20 @@
#include <comphelper/dispatchcommand.hxx> #include <comphelper/dispatchcommand.hxx>
void UITest::executeCommand(const OUString& rCommand) bool UITest::executeCommand(const OUString& rCommand)
{ {
bool bSuccess = comphelper::dispatchCommand( return comphelper::dispatchCommand(
rCommand, rCommand,
{{"SynchronMode", -1, css::uno::Any(true), {{"SynchronMode", -1, css::uno::Any(true),
css::beans::PropertyState_DIRECT_VALUE}}); css::beans::PropertyState_DIRECT_VALUE}});
SAL_WARN_IF(!bSuccess, "vcl.uitest", "failed to execute command: " << rCommand);
} }
void UITest::executeDialog(const OUString& rCommand) bool UITest::executeDialog(const OUString& rCommand)
{ {
bool bSuccess = comphelper::dispatchCommand( return comphelper::dispatchCommand(
rCommand, rCommand,
{{"SynchronMode", -1, css::uno::Any(false), {{"SynchronMode", -1, css::uno::Any(false),
css::beans::PropertyState_DIRECT_VALUE}}); css::beans::PropertyState_DIRECT_VALUE}});
SAL_WARN_IF(!bSuccess, "vcl.uitest", "failed to execute dialog command: " << rCommand);
} }
std::unique_ptr<UIObject> UITest::getFocusTopWindow() std::unique_ptr<UIObject> UITest::getFocusTopWindow()

View File

@ -38,9 +38,9 @@ public:
UITestUnoObj(); UITestUnoObj();
void SAL_CALL executeCommand(const OUString& rCommand) override; sal_Bool SAL_CALL executeCommand(const OUString& rCommand) override;
void SAL_CALL executeDialog(const OUString& rCommand) override; sal_Bool SAL_CALL executeDialog(const OUString& rCommand) override;
css::uno::Reference<css::ui::test::XUIObject> SAL_CALL getTopFocusWindow() override; css::uno::Reference<css::ui::test::XUIObject> SAL_CALL getTopFocusWindow() override;
@ -59,16 +59,16 @@ UITestUnoObj::UITestUnoObj():
{ {
} }
void SAL_CALL UITestUnoObj::executeCommand(const OUString& rCommand) sal_Bool SAL_CALL UITestUnoObj::executeCommand(const OUString& rCommand)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
UITest::executeCommand(rCommand); return UITest::executeCommand(rCommand);
} }
void SAL_CALL UITestUnoObj::executeDialog(const OUString& rCommand) sal_Bool SAL_CALL UITestUnoObj::executeDialog(const OUString& rCommand)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
UITest::executeDialog(rCommand); return UITest::executeDialog(rCommand);
} }
css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UITestUnoObj::getTopFocusWindow() css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UITestUnoObj::getTopFocusWindow()