AusweisApp2/test/helper/MockActivationContext.h

101 lines
1.9 KiB
C
Raw Permalink 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.
*
2019-05-22 10:08:38 +02:00
* \copyright Copyright (c) 2014-2019 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;
}
2019-01-03 15:06:22 +01:00
virtual bool sendErrorPage(http_status pStatusCode, const GlobalStatus& pStatus) override
2017-07-03 09:30:10 +02:00
{
2019-09-30 17:22:19 +02:00
Q_UNUSED(pStatusCode)
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
{
2019-09-30 17:22:19 +02:00
Q_UNUSED(pRedirectAddress)
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;
}
};
2019-01-03 15:06:22 +01:00
} // namespace governikus