AusweisApp2/test/helper/MockActivationContext.h

102 lines
1.9 KiB
C
Raw Normal View History

2017-07-03 09:30:10 +02:00
/*!
2017-12-20 14:54:05 +01:00
* \brief Mocked ActivationContext for unit tests.
*
2018-03-28 15:10:51 +02:00
* \copyright Copyright (c) 2014-2018 Governikus GmbH & Co. KG, Germany
2017-07-03 09:30:10 +02:00
*/
#pragma once
2017-12-20 14:54:05 +01:00
#include "ActivationContext.h"
2017-07-03 09:30:10 +02:00
#include "ActivationHandler.h"
namespace governikus
{
class MockActivationContext
: public ActivationContext
{
Q_OBJECT
bool mProcessingValue, mAlreadyActiveValue, mErroPageValue, mRedirectValue;
const QString mErrorMessageOnSend;
bool mSendProcessingCalled, mSendAlreadyActiveCalled, mSendErroPageCalled, mSendRedirectCalled;
public:
MockActivationContext(bool pProcessing = false, bool pAlreadyActive = false, bool pErroPage = false, bool pRedirect = false, const QString& pSendError = QString());
2017-12-20 14:54:05 +01:00
virtual ~MockActivationContext() override;
2017-07-03 09:30:10 +02:00
2017-07-03 09:33:28 +02:00
virtual QUrl getActivationURL() const override
2017-07-03 09:30:10 +02:00
{
return QUrl();
}
virtual bool sendProcessing() override
{
mSendProcessingCalled = true;
mSendError = mErrorMessageOnSend;
return mProcessingValue;
}
virtual bool sendOperationAlreadyActive() override
{
mSendAlreadyActiveCalled = true;
mSendError = mErrorMessageOnSend;
return mAlreadyActiveValue;
}
2017-07-03 09:33:28 +02:00
virtual bool sendErrorPage(HttpStatusCode pStatusCode, const GlobalStatus& pStatus) override
2017-07-03 09:30:10 +02:00
{
Q_UNUSED(pStatusCode);
2017-07-03 09:33:28 +02:00
Q_UNUSED(pStatus);
2017-07-03 09:30:10 +02:00
mSendErroPageCalled = true;
mSendError = mErrorMessageOnSend;
return mErroPageValue;
}
2017-07-03 09:33:28 +02:00
virtual bool sendRedirect(const QUrl& pRedirectAddress, const GlobalStatus& pStatus) override
2017-07-03 09:30:10 +02:00
{
Q_UNUSED(pRedirectAddress);
2017-07-03 09:33:28 +02:00
Q_UNUSED(pStatus);
2017-07-03 09:30:10 +02:00
mSendRedirectCalled = true;
mSendError = mErrorMessageOnSend;
return mRedirectValue;
}
bool isSendAlreadyActiveCalled() const
{
return mSendAlreadyActiveCalled;
}
bool isSendErroPageCalled() const
{
return mSendErroPageCalled;
}
bool isSendProcessingCalled() const
{
return mSendProcessingCalled;
}
bool isSendRedirectCalled() const
{
return mSendRedirectCalled;
}
};
} /* namespace governikus */