103 lines
3 KiB
C++
103 lines
3 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Harbour //
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @file authenticationFixture.h
|
|
/// @cond PREVENTS_DOXYGEN_WARNING
|
|
#pragma once
|
|
#include "tests/fixture/memoryCheckFixture.h"
|
|
#include <ubiservices/core/configs/config.h>
|
|
#include <ubiservices/core/errors/errorCodes.h>
|
|
#include <ubiservices/core/notifications/notificationSource.h>
|
|
#include <ubiservices/facade.h>
|
|
#if !defined(US_SDK_S2S)
|
|
#include <ubiservices/services/authentication/playerCredentials.h>
|
|
#endif
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace US_NS {;
|
|
|
|
struct EventNotification;
|
|
|
|
namespace AsyncHelper
|
|
{
|
|
::testing::AssertionResult waitSuccess(const AsyncResultBase& result, TimeMilli timeout = NS_COMMON::DEFAULT_WAIT_TIME);
|
|
::testing::AssertionResult waitFailure(const AsyncResultBase& result, Errors::ErrorCode error);
|
|
bool waitFailureResponse(const AsyncResultBase& result, Errors::ErrorCode error);
|
|
}
|
|
|
|
namespace EventsNotificationHelper
|
|
{
|
|
inline bool waitForEventConfig(ListenerHandler<EventNotification>& handler);
|
|
}
|
|
|
|
class AuthenticationFixtureBase : public LeakChecker
|
|
{
|
|
|
|
};
|
|
|
|
// Creates many facades (number specified in the template argument).
|
|
template<uint32 facadesCount = 1, bool executeLogin = true>
|
|
class AuthenticationFixture : public AuthenticationFixtureBase
|
|
{
|
|
protected:
|
|
AuthenticationFixture();
|
|
#if defined(US_SDK_S2S)
|
|
virtual ~AuthenticationFixture() = default;
|
|
#else
|
|
virtual ~AuthenticationFixture();
|
|
#endif
|
|
|
|
void SetUp() override;
|
|
void TearDown() override;
|
|
|
|
uint32 getInstancesCount() const;
|
|
|
|
Facade& getFacade(uint32 index = 0);
|
|
const Facade& getFacade(uint32 index = 0) const;
|
|
const Facade& getFacadeConst(uint32 index = 0) const;
|
|
|
|
FacadeInternal& getFacadeInternal(uint32 index = 0);
|
|
const FacadeInternal& getFacadeInternal(uint32 index = 0) const;
|
|
|
|
ListenerHandler<EventNotification>& getHandler(uint32 index = 0);
|
|
#if !defined(US_SDK_S2S)
|
|
const PlayerCredentials& getCredentials(uint32 index = 0) const;
|
|
|
|
Vector<String> getWebSocketContentTypes() const;
|
|
String getWebSocketJsonData() const;
|
|
#endif
|
|
|
|
#if !defined(US_SDK_S2S)
|
|
bool isEnvironmentNot(Environment target = Environment::Uat);
|
|
#endif
|
|
|
|
void testCall();
|
|
|
|
#if !defined(US_DLL)
|
|
void waitForPostLoginCompletion(uint32 waitTimeInMSec = 10000);
|
|
#endif
|
|
|
|
static const uint32 m_facadesCount = facadesCount;
|
|
static const bool m_executeLogin = executeLogin;
|
|
|
|
private:
|
|
US_CLASS_COPY_NOT_ALLOWED(AuthenticationFixture);
|
|
|
|
void SetUp(uint32 index);
|
|
void TearDown(uint32 index);
|
|
bool isLoginRequired() const;
|
|
|
|
bool m_loginIsSuccessfulArray[facadesCount];
|
|
Facade* m_facades[facadesCount];
|
|
ListenerHandler<EventNotification>* m_handlers[facadesCount];
|
|
#if !defined(US_SDK_S2S)
|
|
mutable Vector<String>* m_notificationContentTypes;
|
|
PlayerCredentials* m_credentials[facadesCount];
|
|
#endif
|
|
};
|
|
|
|
};
|
|
|
|
#include "authenticationFixture.inl"
|
|
|
|
/// @endcond
|