add mock device debugs

recheck rule tests
pull/135/head
Simon Stürz 2016-03-04 16:09:08 +01:00 committed by Michael Zanetti
parent 99cf429335
commit ef874a8c42
2 changed files with 8 additions and 0 deletions

View File

@ -63,6 +63,7 @@ void HttpDaemon::incomingConnection(qintptr socket)
void HttpDaemon::actionExecuted(const ActionTypeId &actionTypeId)
{
qCDebug(dcMockDevice) << "Log actions executed" << actionTypeId.toString();
m_actionList.append(qMakePair<ActionTypeId, QDateTime>(actionTypeId, QDateTime::currentDateTime()));
}
@ -81,19 +82,24 @@ void HttpDaemon::readClient()
QUrl url("http://foo.bar" + tokens[1]);
QUrlQuery query(url);
if (url.path() == "/setstate") {
qCDebug(dcMockDevice) << "Set state value" << query.queryItems().first().second;
emit setState(StateTypeId(query.queryItems().first().first), QVariant(query.queryItems().first().second));
} else if (url.path() == "/generateevent") {
emit triggerEvent(EventTypeId(query.queryItemValue("eventtypeid")));
} else if (url.path() == "/actionhistory") {
qCDebug(dcMockDevice) << "Get action history called";
QTextStream os(socket);
os.setAutoDetectUnicode(true);
os << generateHeader();
for (int i = 0; i < m_actionList.count(); ++i) {
os << m_actionList.at(i).first.toString() << '\n';
qCDebug(dcMockDevice) << " " << m_actionList.at(i).first.toString();
}
socket->close();
return;
} else if (url.path() == "/clearactionhistory") {
qCDebug(dcMockDevice) << "Clear action history";
m_actionList.clear();
}
if (tokens[0] == "GET") {

View File

@ -818,6 +818,7 @@ void TestRules::executeRuleActions()
cleanupMockHistory();
// EXECUTE actions
qDebug() << "Execute rule actions";
QVariantMap executeParams;
executeParams.insert("ruleId", ruleId.toString());
response = injectAndWait("Rules.ExecuteActions", executeParams);
@ -835,6 +836,7 @@ void TestRules::executeRuleActions()
cleanupMockHistory();
// EXECUTE exit actions
qDebug() << "Execute rule exit actions";
response = injectAndWait("Rules.ExecuteExitActions", executeParams);
verifyRuleError(response, ruleError);