1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00
capybara-webkit/src/InvocationResult.cpp

32 lines
800 B
C++
Raw Normal View History

2013-01-20 18:57:04 -05:00
#include "InvocationResult.h"
2013-02-02 17:32:54 -05:00
#include "ErrorMessage.h"
2013-01-20 18:57:04 -05:00
InvocationResult::InvocationResult(QVariant result, bool error) {
m_result = result;
m_error = error;
}
const QVariant &InvocationResult::result() const {
return m_result;
}
bool InvocationResult::hasError() {
return m_error;
}
2013-02-02 17:32:54 -05:00
ErrorMessage *InvocationResult::errorMessage() {
if (!m_result.canConvert<QVariantMap>())
return new ErrorMessage(m_result.toString());
QVariantMap error = m_result.toMap();
QString message = error["message"].toString();
if (error["name"] == "Capybara.ClickFailed")
2013-05-21 07:58:46 -04:00
return new ErrorMessage("ClickFailed", message);
else if (error["name"] == "Capybara.NodeNotAttachedError")
return new ErrorMessage("NodeNotAttachedError", message);
2013-02-02 17:32:54 -05:00
else
return new ErrorMessage(message);
}