diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-03-14 14:37:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-03-17 12:30:41 +0100 |
commit | f1cc5d2229956e3698fd40a4d900fe45e7f8e160 (patch) | |
tree | 91c6d4dcafd5932c60ff2b46f845053bc9dcdd00 /vcl/source/uitest/uiobject.cxx | |
parent | 32a0b409282554df7d66b7212ddd0fe187f86690 (diff) |
throw exception for errors in uitest actions
so we abort early when a uitest goes wrong,
instead of letting tests become fragile
because it looks like its passing, but the code
is just accidentally working
Remove code in python uitests that was not actually
doing anything (and now crashes because we throw an exception
for actions that don't mean anything)
Change-Id: I9c52f9fdc06f1c01e9b93b58a5200f9c3684db1f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112471
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/uitest/uiobject.cxx')
-rw-r--r-- | vcl/source/uitest/uiobject.cxx | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx index 75fae39da51b..fc72053074c6 100644 --- a/vcl/source/uitest/uiobject.cxx +++ b/vcl/source/uitest/uiobject.cxx @@ -337,7 +337,6 @@ StringMap WindowUIObject::get_state() void WindowUIObject::execute(const OUString& rAction, const StringMap& rParameters) { - bool bHandled = true; if (rAction == "SET") { for (auto const& parameter : rParameters) @@ -369,8 +368,12 @@ void WindowUIObject::execute(const OUString& rAction, } else { - SAL_WARN("vcl.uitest", "missing parameter TEXT to action TYPE"); - return; + OStringBuffer buf; + for (auto const & rPair : rParameters) + buf.append(",").append(rPair.first.toUtf8()).append("=").append(rPair.second.toUtf8()); + SAL_WARN("vcl.uitest", "missing parameter TEXT to action TYPE " + << buf.makeStringAndClear()); + throw std::logic_error("missing parameter TEXT to action TYPE"); } } else if (rAction == "FOCUS") @@ -379,12 +382,12 @@ void WindowUIObject::execute(const OUString& rAction, } else { - bHandled = false; - } - - if (!bHandled) - { - SAL_WARN("vcl.uitest", "unknown action or parameter for " << get_name() << ". Action: " << rAction); + OStringBuffer buf; + for (auto const & rPair : rParameters) + buf.append(",").append(rPair.first.toUtf8()).append("=").append(rPair.second.toUtf8()); + SAL_WARN("vcl.uitest", "unknown action for " << get_name() + << ". Action: " << rAction << buf.makeStringAndClear()); + throw std::logic_error("unknown action"); } } @@ -726,15 +729,9 @@ void EditUIObject::execute(const OUString& rAction, bool bHandled = true; if (rAction == "TYPE") { - if (rParameters.find("TEXT") != rParameters.end()) + auto it = rParameters.find("TEXT"); + if (it != rParameters.end()) { - auto it = rParameters.find("TEXT"); - if (it == rParameters.end()) - { - SAL_WARN("vcl.uitest", "missing parameter TEXT to action SET"); - return; - } - const OUString& rText = it->second; auto aKeyEvents = generate_key_events_from_text(rText); for (auto const& keyEvent : aKeyEvents) @@ -904,13 +901,15 @@ CheckBoxUIObject::~CheckBoxUIObject() } void CheckBoxUIObject::execute(const OUString& rAction, - const StringMap& /*rParameters*/) + const StringMap& rParameters) { if (rAction == "CLICK") { // don't use toggle directly, it does not set the value mxCheckBox->ImplCheck(); } + else + WindowUIObject::execute(rAction, rParameters); } StringMap CheckBoxUIObject::get_state() @@ -959,12 +958,14 @@ RadioButtonUIObject::~RadioButtonUIObject() } void RadioButtonUIObject::execute(const OUString& rAction, - const StringMap& /*rParameters*/) + const StringMap& rParameters) { if (rAction == "CLICK") { mxRadioButton->ImplCallClick(); } + else + WindowUIObject::execute(rAction, rParameters); } StringMap RadioButtonUIObject::get_state() @@ -1013,12 +1014,9 @@ TabPageUIObject::~TabPageUIObject() } void TabPageUIObject::execute(const OUString& rAction, - const StringMap& /*rParameters*/) + const StringMap& rParameters) { - if (rAction == "SELECT") - { - /* code */ - } + WindowUIObject::execute(rAction, rParameters); } StringMap TabPageUIObject::get_state() @@ -1218,7 +1216,7 @@ SpinUIObject::~SpinUIObject() } void SpinUIObject::execute(const OUString& rAction, - const StringMap& /*rParameters*/) + const StringMap& rParameters) { if (rAction == "UP") { @@ -1228,6 +1226,8 @@ void SpinUIObject::execute(const OUString& rAction, { mxSpinButton->Down(); } + else + WindowUIObject::execute(rAction, rParameters); } StringMap SpinUIObject::get_state() |