1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include <AzCore/Component/ComponentApplication.h>
- #include <AzCore/Serialization/EditContext.h>
- #include <AzCore/Serialization/SerializeContext.h>
- #include <AzCore/std/smart_ptr/make_shared.h>
- #include <Multiplayer/Session/SessionConfig.h>
- #include <Credential/AWSCredentialBus.h>
- #include <ResourceMapping/AWSResourceMappingBus.h>
- #include <AWSCoreBus.h>
- #include <AWSGameLiftClientFixture.h>
- #include <AWSGameLiftClientManager.h>
- #include <AWSGameLiftClientMocks.h>
- #include <Request/AWSGameLiftAcceptMatchRequest.h>
- #include <Request/AWSGameLiftCreateSessionOnQueueRequest.h>
- #include <Request/AWSGameLiftCreateSessionRequest.h>
- #include <Request/AWSGameLiftJoinSessionRequest.h>
- #include <Request/AWSGameLiftSearchSessionsRequest.h>
- #include <Request/IAWSGameLiftInternalRequests.h>
- #include <Request/AWSGameLiftStartMatchmakingRequest.h>
- #include <Request/AWSGameLiftStopMatchmakingRequest.h>
- using namespace AWSGameLift;
- MATCHER_P(SearchSessionsResponseMatcher, expectedResponse, "")
- {
- // Custome matcher for checking the SearchSessionsResponse type argument.
- AZ_UNUSED(result_listener);
- bool result = arg.m_nextToken == expectedResponse.m_nextToken;
- result &= arg.m_sessionConfigs.size() == expectedResponse.m_sessionConfigs.size();
- for (int index = 0; index < arg.m_sessionConfigs.size(); ++index)
- {
- result &= arg.m_sessionConfigs[index].m_creationTime == expectedResponse.m_sessionConfigs[index].m_creationTime;
- result &= arg.m_sessionConfigs[index].m_terminationTime == expectedResponse.m_sessionConfigs[index].m_terminationTime;
- result &= arg.m_sessionConfigs[index].m_creatorId == expectedResponse.m_sessionConfigs[index].m_creatorId;
- result &= arg.m_sessionConfigs[index].m_sessionProperties == expectedResponse.m_sessionConfigs[index].m_sessionProperties;
- result &= arg.m_sessionConfigs[index].m_sessionId == expectedResponse.m_sessionConfigs[index].m_sessionId;
- result &= arg.m_sessionConfigs[index].m_sessionName == expectedResponse.m_sessionConfigs[index].m_sessionName;
- result &= arg.m_sessionConfigs[index].m_dnsName == expectedResponse.m_sessionConfigs[index].m_dnsName;
- result &= arg.m_sessionConfigs[index].m_ipAddress == expectedResponse.m_sessionConfigs[index].m_ipAddress;
- result &= arg.m_sessionConfigs[index].m_port == expectedResponse.m_sessionConfigs[index].m_port;
- result &= arg.m_sessionConfigs[index].m_maxPlayer == expectedResponse.m_sessionConfigs[index].m_maxPlayer;
- result &= arg.m_sessionConfigs[index].m_currentPlayer == expectedResponse.m_sessionConfigs[index].m_currentPlayer;
- result &= arg.m_sessionConfigs[index].m_status == expectedResponse.m_sessionConfigs[index].m_status;
- result &= arg.m_sessionConfigs[index].m_statusReason == expectedResponse.m_sessionConfigs[index].m_statusReason;
- }
- return result;
- }
- class AWSResourceMappingRequestsHandlerMock
- : public AWSCore::AWSResourceMappingRequestBus::Handler
- {
- public:
- AWSResourceMappingRequestsHandlerMock()
- {
- AWSCore::AWSResourceMappingRequestBus::Handler::BusConnect();
- }
- ~ AWSResourceMappingRequestsHandlerMock()
- {
- AWSCore::AWSResourceMappingRequestBus::Handler::BusDisconnect();
- }
- MOCK_CONST_METHOD0(GetDefaultRegion, AZStd::string());
- MOCK_CONST_METHOD0(GetDefaultAccountId, AZStd::string());
- MOCK_CONST_METHOD1(HasResource, bool(const AZStd::string&));
- MOCK_CONST_METHOD1(GetResourceAccountId, AZStd::string(const AZStd::string&));
- MOCK_CONST_METHOD1(GetResourceNameId, AZStd::string(const AZStd::string&));
- MOCK_CONST_METHOD1(GetResourceRegion, AZStd::string(const AZStd::string&));
- MOCK_CONST_METHOD1(GetResourceType, AZStd::string(const AZStd::string&));
- MOCK_CONST_METHOD1(GetServiceUrlByServiceName, AZStd::string(const AZStd::string&));
- MOCK_CONST_METHOD2(GetServiceUrlByRESTApiIdAndStage, AZStd::string(const AZStd::string&, const AZStd::string&));
- MOCK_METHOD1(ReloadConfigFile, void(bool));
- };
- class AWSCredentialRequestsHandlerMock
- : public AWSCore::AWSCredentialRequestBus::Handler
- {
- public:
- AWSCredentialRequestsHandlerMock()
- {
- AWSCore::AWSCredentialRequestBus::Handler::BusConnect();
- }
- ~AWSCredentialRequestsHandlerMock()
- {
- AWSCore::AWSCredentialRequestBus::Handler::BusDisconnect();
- }
- MOCK_CONST_METHOD0(GetCredentialHandlerOrder, int());
- MOCK_METHOD0(GetCredentialsProvider, std::shared_ptr<Aws::Auth::AWSCredentialsProvider>());
- };
- class AWSCoreRequestsHandlerMock
- : public AWSCore::AWSCoreRequestBus::Handler
- {
- public:
- AWSCoreRequestsHandlerMock()
- {
- AWSCore::AWSCoreRequestBus::Handler::BusConnect();
- }
- ~AWSCoreRequestsHandlerMock()
- {
- AWSCore::AWSCoreRequestBus::Handler::BusDisconnect();
- }
- MOCK_METHOD0(GetDefaultJobContext, AZ::JobContext*());
- MOCK_METHOD0(GetDefaultConfig, AWSCore::AwsApiJobConfig*());
- };
- class AWSGameLiftClientManagerTest
- : public AWSGameLiftClientFixture
- , public IAWSGameLiftInternalRequests
- {
- protected:
- void SetUp() override
- {
- AWSGameLiftClientFixture::SetUp();
- AZ::Interface<IAWSGameLiftInternalRequests>::Register(this);
- m_gameliftClientMockPtr = AZStd::make_shared<GameLiftClientMock>();
- m_gameliftClientManager = AZStd::make_unique<AWSGameLiftClientManager>();
- m_gameliftClientManager->ActivateManager();
- }
- void TearDown() override
- {
- m_gameliftClientManager->DeactivateManager();
- m_gameliftClientManager.reset();
- m_gameliftClientMockPtr.reset();
- AZ::Interface<IAWSGameLiftInternalRequests>::Unregister(this);
- AWSGameLiftClientFixture::TearDown();
- }
- AZStd::shared_ptr<Aws::GameLift::GameLiftClient> GetGameLiftClient() const
- {
- return m_gameliftClientMockPtr;
- }
- void SetGameLiftClient(AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient)
- {
- AZ_UNUSED(gameliftClient);
- m_gameliftClientMockPtr.reset();
- }
- AWSGameLiftSearchSessionsRequest GetValidSearchSessionsRequest()
- {
- AWSGameLiftSearchSessionsRequest request;
- request.m_aliasId = "dummyAliasId";
- request.m_fleetId = "dummyFleetId";
- request.m_location = "dummyLocation";
- request.m_filterExpression = "dummyFilterExpression";
- request.m_sortExpression = "dummySortExpression";
- request.m_maxResult = 1;
- request.m_nextToken = "dummyNextToken";
- return request;
- }
- Aws::GameLift::Model::SearchGameSessionsOutcome GetValidSearchGameSessionsOutcome()
- {
- Aws::GameLift::Model::GameProperty gameProperty;
- gameProperty.SetKey("dummyKey");
- gameProperty.SetValue("dummyValue");
- Aws::Vector<Aws::GameLift::Model::GameProperty> gameProperties = { gameProperty };
- Aws::GameLift::Model::GameSession gameSession;
- gameSession.SetCreationTime(Aws::Utils::DateTime(0.0));
- gameSession.SetTerminationTime(Aws::Utils::DateTime(0.0));
- gameSession.SetCreatorId("dummyCreatorId");
- gameSession.SetGameProperties(gameProperties);
- gameSession.SetGameSessionId("dummyGameSessionId");
- gameSession.SetName("dummyGameSessionName");
- gameSession.SetIpAddress("dummyIpAddress");
- gameSession.SetPort(0);
- gameSession.SetMaximumPlayerSessionCount(2);
- gameSession.SetCurrentPlayerSessionCount(1);
- gameSession.SetStatus(Aws::GameLift::Model::GameSessionStatus::TERMINATED);
- gameSession.SetStatusReason(Aws::GameLift::Model::GameSessionStatusReason::INTERRUPTED);
- // TODO: Update the AWS Native SDK to set the new game session attributes.
- // gameSession.SetDnsName("dummyDnsName");
- Aws::GameLift::Model::SearchGameSessionsResult result;
- result.SetNextToken("dummyNextToken");
- result.SetGameSessions({ gameSession });
- return Aws::GameLift::Model::SearchGameSessionsOutcome(result);
- }
- Multiplayer::SearchSessionsResponse GetValidSearchSessionsResponse()
- {
- Multiplayer::SessionConfig sessionConfig;
- sessionConfig.m_creationTime = 0;
- sessionConfig.m_terminationTime = 0;
- sessionConfig.m_creatorId = "dummyCreatorId";
- sessionConfig.m_sessionProperties["dummyKey"] = "dummyValue";
- sessionConfig.m_matchmakingData = "dummyMatchmakingData";
- sessionConfig.m_sessionId = "dummyGameSessionId";
- sessionConfig.m_sessionName = "dummyGameSessionName";
- sessionConfig.m_ipAddress = "dummyIpAddress";
- sessionConfig.m_port = 0;
- sessionConfig.m_maxPlayer = 2;
- sessionConfig.m_currentPlayer = 1;
- sessionConfig.m_status = "Terminated";
- sessionConfig.m_statusReason = "Interrupted";
- // TODO: Update the AWS Native SDK to set the new game session attributes.
- // sessionConfig.m_dnsName = "dummyDnsName";
- Multiplayer::SearchSessionsResponse response;
- response.m_nextToken = "dummyNextToken";
- response.m_sessionConfigs = { sessionConfig };
- return response;
- }
- AWSGameLiftStartMatchmakingRequest GetValidStartMatchmakingRequest()
- {
- AWSGameLiftStartMatchmakingRequest request;
- request.m_configurationName = "dummyConfiguration";
- request.m_ticketId = DummyMatchmakingTicketId;
- AWSGameLiftPlayer player;
- player.m_playerAttributes["dummy"] = "{\"N\": \"1\"}";
- player.m_playerId = DummyPlayerId;
- player.m_latencyInMs["us-east-1"] = 10;
- request.m_players.emplace_back(player);
- return request;
- }
- Aws::GameLift::Model::StartMatchmakingOutcome GetValidStartMatchmakingResponse()
- {
- Aws::GameLift::Model::MatchmakingTicket ticket;
- ticket.SetTicketId(DummyMatchmakingTicketId);
- Aws::GameLift::Model::StartMatchmakingResult result;
- result.SetMatchmakingTicket(ticket);
- Aws::GameLift::Model::StartMatchmakingOutcome outcome(result);
- return outcome;
- }
- static const char* const DummyMatchmakingTicketId;
- static const char* const DummyPlayerId;
- public:
- AZStd::unique_ptr<AWSGameLiftClientManager> m_gameliftClientManager;
- AZStd::shared_ptr<GameLiftClientMock> m_gameliftClientMockPtr;
- };
- const char* const AWSGameLiftClientManagerTest::DummyMatchmakingTicketId = "dummyTicketId";
- const char* const AWSGameLiftClientManagerTest::DummyPlayerId = "dummyPlayerId";
- TEST_F(AWSGameLiftClientManagerTest, ConfigureGameLiftClient_CallWithoutRegion_GetFalseAsResult)
- {
- AWSCoreRequestsHandlerMock coreHandlerMock;
- EXPECT_CALL(coreHandlerMock, GetDefaultConfig()).Times(1).WillOnce(nullptr);
- AZ_TEST_START_TRACE_SUPPRESSION;
- auto result = m_gameliftClientManager->ConfigureGameLiftClient("");
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_FALSE(result);
- }
- TEST_F(AWSGameLiftClientManagerTest, ConfigureGameLiftClient_CallWithoutCredential_GetFalseAsResult)
- {
- AWSCoreRequestsHandlerMock coreHandlerMock;
- EXPECT_CALL(coreHandlerMock, GetDefaultConfig()).Times(1).WillOnce(nullptr);
- AWSResourceMappingRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultRegion()).Times(1).WillOnce(::testing::Return("us-west-2"));
- AZ_TEST_START_TRACE_SUPPRESSION;
- auto result = m_gameliftClientManager->ConfigureGameLiftClient("");
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_FALSE(result);
- }
- TEST_F(AWSGameLiftClientManagerTest, ConfigureGameLiftClient_CallWithRegionAndCredential_GetTrueAsResult)
- {
- AWSCoreRequestsHandlerMock coreHandlerMock;
- EXPECT_CALL(coreHandlerMock, GetDefaultConfig()).Times(1).WillOnce(nullptr);
- AWSCredentialRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetCredentialsProvider())
- .Times(1)
- .WillOnce(::testing::Return(std::make_shared<Aws::Auth::SimpleAWSCredentialsProvider>("dummyAccess", "dummySecret", "")));
- auto result = m_gameliftClientManager->ConfigureGameLiftClient("us-west-2");
- EXPECT_TRUE(result);
- }
- TEST_F(AWSGameLiftClientManagerTest, CreatePlayerId_CreateWithoutBracketsOrDashes_GetExpectedResult)
- {
- auto result = m_gameliftClientManager->CreatePlayerId(false, false);
- EXPECT_FALSE(result.starts_with("{"));
- EXPECT_FALSE(result.ends_with("}"));
- EXPECT_FALSE(result.contains("-"));
- }
- TEST_F(AWSGameLiftClientManagerTest, CreatePlayerId_CreateWithBrackets_GetExpectedResult)
- {
- auto result = m_gameliftClientManager->CreatePlayerId(true, false);
- EXPECT_TRUE(result.starts_with("{"));
- EXPECT_TRUE(result.ends_with("}"));
- EXPECT_FALSE(result.contains("-"));
- }
- TEST_F(AWSGameLiftClientManagerTest, CreatePlayerId_CreateWithDashes_GetExpectedResult)
- {
- auto result = m_gameliftClientManager->CreatePlayerId(false, true);
- EXPECT_FALSE(result.starts_with("{"));
- EXPECT_FALSE(result.ends_with("}"));
- EXPECT_TRUE(result.contains("-"));
- }
- TEST_F(AWSGameLiftClientManagerTest, CreatePlayerId_CreateWithBracketsAndDashes_GetExpectedResult)
- {
- auto result = m_gameliftClientManager->CreatePlayerId(true, true);
- EXPECT_TRUE(result.starts_with("{"));
- EXPECT_TRUE(result.ends_with("}"));
- EXPECT_TRUE(result.contains("-"));
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSession_CallWithoutClientSetup_GetEmptyResponse)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->ConfigureGameLiftClient("");
- AWSGameLiftCreateSessionRequest request;
- request.m_aliasId = "dummyAlias";
- auto response = m_gameliftClientManager->CreateSession(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(2); // capture 2 error message
- EXPECT_TRUE(response == "");
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSession_CallWithInvalidRequest_GetEmptyResponse)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- auto response = m_gameliftClientManager->CreateSession(Multiplayer::CreateSessionRequest());
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_TRUE(response == "");
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSession_CallWithValidRequest_GetSuccessOutcome)
- {
- AWSGameLiftCreateSessionRequest request;
- request.m_aliasId = "dummyAlias";
- Aws::GameLift::Model::CreateGameSessionResult result;
- result.SetGameSession(Aws::GameLift::Model::GameSession());
- Aws::GameLift::Model::CreateGameSessionOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreateGameSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- m_gameliftClientManager->CreateSession(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSession_CallWithValidRequest_GetErrorOutcome)
- {
- AWSGameLiftCreateSessionRequest request;
- request.m_aliasId = "dummyAlias";
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::CreateGameSessionOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreateGameSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->CreateSession(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSessionAsync_CallWithInvalidRequest_GetNotificationWithEmptyResponse)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnCreateSessionAsyncComplete(AZStd::string())).Times(1);
- m_gameliftClientManager->CreateSessionAsync(Multiplayer::CreateSessionRequest());
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSessionAsync_CallWithValidRequest_GetNotificationWithSuccessOutcome)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftCreateSessionRequest request;
- request.m_aliasId = "dummyAlias";
- Aws::GameLift::Model::CreateGameSessionResult result;
- result.SetGameSession(Aws::GameLift::Model::GameSession());
- Aws::GameLift::Model::CreateGameSessionOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreateGameSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnCreateSessionAsyncComplete(::testing::_)).Times(1);
- m_gameliftClientManager->CreateSessionAsync(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSessionAsync_CallWithValidRequest_GetNotificationWithErrorOutcome)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftCreateSessionRequest request;
- request.m_aliasId = "dummyAlias";
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::CreateGameSessionOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreateGameSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnCreateSessionAsyncComplete(AZStd::string(""))).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->CreateSessionAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueue_CallWithoutClientSetup_GetEmptyResponse)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->ConfigureGameLiftClient("");
- AWSGameLiftCreateSessionOnQueueRequest request;
- request.m_queueName = "dummyQueue";
- request.m_placementId = "dummyPlacementId";
- auto response = m_gameliftClientManager->CreateSession(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(2); // capture 2 error message
- EXPECT_TRUE(response == "");
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueue_CallWithValidRequest_GetSuccessOutcome)
- {
- AWSGameLiftCreateSessionOnQueueRequest request;
- request.m_queueName = "dummyQueue";
- request.m_placementId = "dummyPlacementId";
- Aws::GameLift::Model::StartGameSessionPlacementResult result;
- result.SetGameSessionPlacement(Aws::GameLift::Model::GameSessionPlacement());
- Aws::GameLift::Model::StartGameSessionPlacementOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, StartGameSessionPlacement(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- m_gameliftClientManager->CreateSession(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueue_CallWithValidRequest_GetErrorOutcome)
- {
- AWSGameLiftCreateSessionOnQueueRequest request;
- request.m_queueName = "dummyQueue";
- request.m_placementId = "dummyPlacementId";
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::StartGameSessionPlacementOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, StartGameSessionPlacement(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->CreateSession(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueueAsync_CallWithValidRequest_GetNotificationWithSuccessOutcome)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftCreateSessionOnQueueRequest request;
- request.m_queueName = "dummyQueue";
- request.m_placementId = "dummyPlacementId";
- Aws::GameLift::Model::StartGameSessionPlacementResult result;
- result.SetGameSessionPlacement(Aws::GameLift::Model::GameSessionPlacement());
- Aws::GameLift::Model::StartGameSessionPlacementOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, StartGameSessionPlacement(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnCreateSessionAsyncComplete(::testing::_)).Times(1);
- m_gameliftClientManager->CreateSessionAsync(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueueAsync_CallWithValidRequest_GetNotificationWithErrorOutcome)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftCreateSessionOnQueueRequest request;
- request.m_queueName = "dummyQueue";
- request.m_placementId = "dummyPlacementId";
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::StartGameSessionPlacementOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, StartGameSessionPlacement(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnCreateSessionAsyncComplete(AZStd::string(""))).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->CreateSessionAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithoutClientSetup_GetFalseResponse)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->ConfigureGameLiftClient("");
- AWSGameLiftJoinSessionRequest request;
- request.m_playerId = "dummyPlayerId";
- request.m_sessionId = "dummySessionId";
- auto response = m_gameliftClientManager->JoinSession(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(2); // capture 2 error message
- EXPECT_FALSE(response);
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithInvalidRequest_GetFalseResponse)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- auto response = m_gameliftClientManager->JoinSession(Multiplayer::JoinSessionRequest());
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_FALSE(response);
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequestButNoRequestHandler_GetSuccessOutcomeButFalseResponse)
- {
- AWSGameLiftJoinSessionRequest request;
- request.m_sessionId = "dummySessionId";
- request.m_playerId = "dummyPlayerId";
- Aws::GameLift::Model::CreatePlayerSessionResult result;
- result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
- Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- AZ_TEST_START_TRACE_SUPPRESSION;
- auto response = m_gameliftClientManager->JoinSession(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_FALSE(response);
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequest_GetErrorOutcomeAndFalseResponse)
- {
- AWSGameLiftJoinSessionRequest request;
- request.m_sessionId = "dummySessionId";
- request.m_playerId = "dummyPlayerId";
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- AZ_TEST_START_TRACE_SUPPRESSION;
- auto response = m_gameliftClientManager->JoinSession(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_FALSE(response);
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequestAndRequestHandler_GetSuccessOutcomeButFalseResponse)
- {
- SessionHandlingClientRequestsMock handlerMock;
- EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_)).Times(1).WillOnce(::testing::Return(false));
- AWSGameLiftJoinSessionRequest request;
- request.m_sessionId = "dummySessionId";
- request.m_playerId = "dummyPlayerId";
- Aws::GameLift::Model::CreatePlayerSessionResult result;
- result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
- Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- auto response = m_gameliftClientManager->JoinSession(request);
- EXPECT_FALSE(response);
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequestAndRequestHandler_GetSuccessOutcomeAndTrueResponse)
- {
- SessionHandlingClientRequestsMock handlerMock;
- EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_)).Times(1).WillOnce(::testing::Return(true));
- AWSGameLiftJoinSessionRequest request;
- request.m_sessionId = "dummySessionId";
- request.m_playerId = "dummyPlayerId";
- Aws::GameLift::Model::CreatePlayerSessionResult result;
- result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
- Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- auto response = m_gameliftClientManager->JoinSession(request);
- EXPECT_TRUE(response);
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithInvalidRequest_GetNotificationWithFalseResponse)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnJoinSessionAsyncComplete(false)).Times(1);
- m_gameliftClientManager->JoinSessionAsync(Multiplayer::JoinSessionRequest());
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequestButNoRequestHandler_GetSuccessOutcomeButNotificationWithFalseResponse)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftJoinSessionRequest request;
- request.m_sessionId = "dummySessionId";
- request.m_playerId = "dummyPlayerId";
- Aws::GameLift::Model::CreatePlayerSessionResult result;
- result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
- Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnJoinSessionAsyncComplete(false)).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->JoinSessionAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequest_GetErrorOutcomeAndNotificationWithFalseResponse)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftJoinSessionRequest request;
- request.m_sessionId = "dummySessionId";
- request.m_playerId = "dummyPlayerId";
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnJoinSessionAsyncComplete(false)).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->JoinSessionAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequestAndRequestHandler_GetSuccessOutcomeButNotificationWithFalseResponse)
- {
- AWSCoreRequestsHandlerMock coreHandlerMock;
- EXPECT_CALL(coreHandlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- SessionHandlingClientRequestsMock handlerMock;
- EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_)).Times(1).WillOnce(::testing::Return(false));
- AWSGameLiftJoinSessionRequest request;
- request.m_sessionId = "dummySessionId";
- request.m_playerId = "dummyPlayerId";
- Aws::GameLift::Model::CreatePlayerSessionResult result;
- result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
- Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnJoinSessionAsyncComplete(false)).Times(1);
- m_gameliftClientManager->JoinSessionAsync(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequestAndRequestHandler_GetSuccessOutcomeAndNotificationWithTrueResponse)
- {
- AWSCoreRequestsHandlerMock coreHandlerMock;
- EXPECT_CALL(coreHandlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- SessionHandlingClientRequestsMock handlerMock;
- EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_)).Times(1).WillOnce(::testing::Return(true));
- AWSGameLiftJoinSessionRequest request;
- request.m_sessionId = "dummySessionId";
- request.m_playerId = "dummyPlayerId";
- Aws::GameLift::Model::CreatePlayerSessionResult result;
- result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
- Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnJoinSessionAsyncComplete(true)).Times(1);
- m_gameliftClientManager->JoinSessionAsync(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, SearchSessions_CallWithValidRequestAndErrorOutcome_GetErrorWithEmptyResponse)
- {
- AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::SearchGameSessionsOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, SearchGameSessions(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- AZ_TEST_START_TRACE_SUPPRESSION;
- auto result = m_gameliftClientManager->SearchSessions(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_TRUE(result.m_sessionConfigs.size() == 0);
- }
- TEST_F(AWSGameLiftClientManagerTest, SearchSessions_CallWithValidRequestAndSuccessOutcome_GetNotificationWithValidResponse)
- {
- AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
- Aws::GameLift::Model::SearchGameSessionsOutcome outcome = GetValidSearchGameSessionsOutcome();
- EXPECT_CALL(*m_gameliftClientMockPtr, SearchGameSessions(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- Multiplayer::SearchSessionsResponse expectedResponse = GetValidSearchSessionsResponse();
- auto result = m_gameliftClientManager->SearchSessions(request);
- EXPECT_TRUE(result.m_sessionConfigs.size() != 0);
- }
- TEST_F(AWSGameLiftClientManagerTest, SearchSessionsAsync_CallWithoutClientSetup_GetErrorWithEmptyResponse)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- EXPECT_FALSE(m_gameliftClientManager->ConfigureGameLiftClient(""));
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock,
- OnSearchSessionsAsyncComplete(SearchSessionsResponseMatcher(Multiplayer::SearchSessionsResponse()))).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->SearchSessionsAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, SearchSessionsAsync_CallWithInvalidRequest_GetErrorWithEmptyResponse)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock,
- OnSearchSessionsAsyncComplete(SearchSessionsResponseMatcher(Multiplayer::SearchSessionsResponse()))).Times(1);
- m_gameliftClientManager->SearchSessionsAsync(Multiplayer::SearchSessionsRequest());
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, SearchSessionsAsync_CallWithValidRequestAndErrorOutcome_GetErrorWithEmptyResponse)
- {
- AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::SearchGameSessionsOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, SearchGameSessions(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock,
- OnSearchSessionsAsyncComplete(SearchSessionsResponseMatcher(Multiplayer::SearchSessionsResponse()))).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->SearchSessionsAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, SearchSessionsAsync_CallWithValidRequestAndSuccessOutcome_GetNotificationWithValidResponse)
- {
- AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
- AWSCoreRequestsHandlerMock coreHandlerMock;
- EXPECT_CALL(coreHandlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- Aws::GameLift::Model::SearchGameSessionsOutcome outcome = GetValidSearchGameSessionsOutcome();
- EXPECT_CALL(*m_gameliftClientMockPtr, SearchGameSessions(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- Multiplayer::SearchSessionsResponse expectedResponse = GetValidSearchSessionsResponse();
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock,
- OnSearchSessionsAsyncComplete(SearchSessionsResponseMatcher(expectedResponse))).Times(1);
- m_gameliftClientManager->SearchSessionsAsync(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, LeaveSession_CallWithInterfaceNotRegistered_GetExpectedError)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->LeaveSession();
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, LeaveSession_CallWithInterfaceRegistered_LeaveSessionRequestSent)
- {
- SessionHandlingClientRequestsMock handlerMock;
- EXPECT_CALL(handlerMock, RequestPlayerLeaveSession).Times(1);
- m_gameliftClientManager->LeaveSession();
- }
- TEST_F(AWSGameLiftClientManagerTest, LeaveSessionAsync_CallWithInterfaceNotRegistered_GetExpectedError)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->LeaveSessionAsync();
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, LeaveSessionAsync_CallWithInterfaceRegistered_LeaveSessionAsyncRequestSentAndGetNotification)
- {
- SessionHandlingClientRequestsMock handlerMock;
- EXPECT_CALL(handlerMock, RequestPlayerLeaveSession).Times(1);
- SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
- EXPECT_CALL(sessionHandlerMock, OnLeaveSessionAsyncComplete()).Times(1);
- m_gameliftClientManager->LeaveSessionAsync();
- }
- TEST_F(AWSGameLiftClientManagerTest, StartMatchmaking_CallWithoutClientSetup_GetFalseResponse)
- {
- AWSGameLiftStartMatchmakingRequest request = GetValidStartMatchmakingRequest();
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->ConfigureGameLiftClient("");
- AZStd::string response = m_gameliftClientManager->StartMatchmaking(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(2); // capture 2 error message
- EXPECT_TRUE(response.empty());
- }
- TEST_F(AWSGameLiftClientManagerTest, StartMatchmaking_CallWithInvalidRequest_GetErrorWithEmptyResponse)
- {
- AWSGameLiftStartMatchmakingRequest request;
- request.m_configurationName = "dummyConfiguration";
- AWSGameLiftPlayer player;
- player.m_playerAttributes["dummy"] = "{\"A\": \"1\"}";
- request.m_players.emplace_back(player);
- AZ_TEST_START_TRACE_SUPPRESSION;
- AZStd::string response = m_gameliftClientManager->StartMatchmaking(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_TRUE(response.empty());
- }
- TEST_F(AWSGameLiftClientManagerTest, StartMatchmaking_CallWithValidRequest_GetSuccessOutcome)
- {
- AWSGameLiftStartMatchmakingRequest request = GetValidStartMatchmakingRequest();
- Aws::GameLift::Model::StartMatchmakingOutcome outcome = GetValidStartMatchmakingResponse();
- EXPECT_CALL(*m_gameliftClientMockPtr, StartMatchmaking(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- AZStd::string response = m_gameliftClientManager->StartMatchmaking(request);
- EXPECT_EQ(response, DummyMatchmakingTicketId);
- }
- TEST_F(AWSGameLiftClientManagerTest, StartMatchmaking_CallWithValidRequest_GetErrorOutcome)
- {
- AWSGameLiftStartMatchmakingRequest request = GetValidStartMatchmakingRequest();
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::StartMatchmakingOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, StartMatchmaking(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->StartMatchmaking(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, StartMatchmakingAsync_CallWithInvalidRequest_GetNotificationWithErrorOutcome)
- {
- AWSGameLiftStartMatchmakingRequest request;
- request.m_configurationName = "dummyConfiguration";
- AWSGameLiftPlayer player;
- player.m_playerAttributes["dummy"] = "{\"A\": \"1\"}";
- request.m_players.emplace_back(player);
- MatchmakingAsyncRequestNotificationsHandlerMock matchmakingHandlerMock;
- EXPECT_CALL(matchmakingHandlerMock, OnStartMatchmakingAsyncComplete(AZStd::string{})).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->StartMatchmakingAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, StartMatchmakingAsync_CallWithValidRequest_GetNotificationWithSuccessOutcome)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftStartMatchmakingRequest request = GetValidStartMatchmakingRequest();
- Aws::GameLift::Model::StartMatchmakingOutcome outcome = GetValidStartMatchmakingResponse();
- EXPECT_CALL(*m_gameliftClientMockPtr, StartMatchmaking(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- MatchmakingAsyncRequestNotificationsHandlerMock matchmakingHandlerMock;
- EXPECT_CALL(matchmakingHandlerMock, OnStartMatchmakingAsyncComplete(AZStd::string(DummyMatchmakingTicketId))).Times(1);
- m_gameliftClientManager->StartMatchmakingAsync(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, StartMatchmakingAsync_CallWithValidRequest_GetNotificationWithErrorOutcome)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftStartMatchmakingRequest request = GetValidStartMatchmakingRequest();
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::StartMatchmakingOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, StartMatchmaking(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- MatchmakingAsyncRequestNotificationsHandlerMock matchmakingHandlerMock;
- EXPECT_CALL(matchmakingHandlerMock, OnStartMatchmakingAsyncComplete(AZStd::string{})).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->StartMatchmakingAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, StopMatchmaking_CallWithoutClientSetup_GetError)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->ConfigureGameLiftClient("");
- AWSGameLiftStopMatchmakingRequest request;
- request.m_ticketId = DummyMatchmakingTicketId;
- m_gameliftClientManager->StopMatchmaking(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(2); // capture 2 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, StopMatchmaking_CallWithInvalidRequest_GetError)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->StopMatchmaking(Multiplayer::StopMatchmakingRequest());
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, StopMatchmaking_CallWithValidRequest_Success)
- {
- AWSGameLiftStopMatchmakingRequest request;
- request.m_ticketId = DummyMatchmakingTicketId;
- Aws::GameLift::Model::StopMatchmakingResult result;
- Aws::GameLift::Model::StopMatchmakingResult outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, StopMatchmaking(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- m_gameliftClientManager->StopMatchmaking(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, StopMatchmaking_CallWithValidRequest_GetError)
- {
- AWSGameLiftStopMatchmakingRequest request;
- request.m_ticketId = DummyMatchmakingTicketId;
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::StopMatchmakingOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, StopMatchmaking(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->StopMatchmaking(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, StopMatchmakingAsync_CallWithInvalidRequest_GetNotificationWithError)
- {
- AWSGameLiftStopMatchmakingRequest request;
- MatchmakingAsyncRequestNotificationsHandlerMock matchmakingHandlerMock;
- EXPECT_CALL(matchmakingHandlerMock, OnStopMatchmakingAsyncComplete()).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->StopMatchmakingAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, StopMatchmakingAsync_CallWithValidRequest_GetNotification)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftStopMatchmakingRequest request;
- request.m_ticketId = DummyMatchmakingTicketId;
- Aws::GameLift::Model::StopMatchmakingResult result;
- Aws::GameLift::Model::StopMatchmakingOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, StopMatchmaking(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- MatchmakingAsyncRequestNotificationsHandlerMock matchmakingHandlerMock;
- EXPECT_CALL(matchmakingHandlerMock, OnStopMatchmakingAsyncComplete()).Times(1);
- m_gameliftClientManager->StopMatchmakingAsync(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, StopMatchmakingAsync_CallWithValidRequest_GetNotificationWithError)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftStopMatchmakingRequest request;
- request.m_ticketId = DummyMatchmakingTicketId;
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::StopMatchmakingOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, StopMatchmaking(::testing::_))
- .Times(1)
- .WillOnce(::testing::Return(outcome));
- MatchmakingAsyncRequestNotificationsHandlerMock matchmakingHandlerMock;
- EXPECT_CALL(matchmakingHandlerMock, OnStopMatchmakingAsyncComplete()).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->StopMatchmakingAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, AcceptMatch_CallWithoutClientSetup_GetError)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->ConfigureGameLiftClient("");
- AWSGameLiftAcceptMatchRequest request;
- request.m_acceptMatch = true;
- request.m_playerIds = { DummyPlayerId };
- request.m_ticketId = DummyMatchmakingTicketId;
- m_gameliftClientManager->AcceptMatch(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(2); // capture 2 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, AcceptMatch_CallWithInvalidRequest_GetError)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->AcceptMatch(Multiplayer::AcceptMatchRequest());
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, AcceptMatch_CallWithValidRequest_Success)
- {
- AWSGameLiftAcceptMatchRequest request;
- request.m_acceptMatch = true;
- request.m_playerIds = { DummyPlayerId };
- request.m_ticketId = DummyMatchmakingTicketId;
- Aws::GameLift::Model::AcceptMatchResult result;
- Aws::GameLift::Model::AcceptMatchResult outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, AcceptMatch(::testing::_)).Times(1).WillOnce(::testing::Return(outcome));
- m_gameliftClientManager->AcceptMatch(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, AcceptMatch_CallWithValidRequest_GetError)
- {
- AWSGameLiftAcceptMatchRequest request;
- request.m_acceptMatch = true;
- request.m_playerIds = { DummyPlayerId };
- request.m_ticketId = DummyMatchmakingTicketId;
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::AcceptMatchOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, AcceptMatch(::testing::_)).Times(1).WillOnce(::testing::Return(outcome));
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->AcceptMatch(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, AcceptMatchAsync_CallWithInvalidRequest_GetNotificationWithError)
- {
- AWSGameLiftAcceptMatchRequest request;
- MatchmakingAsyncRequestNotificationsHandlerMock matchmakingHandlerMock;
- EXPECT_CALL(matchmakingHandlerMock, OnAcceptMatchAsyncComplete()).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->AcceptMatchAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
- TEST_F(AWSGameLiftClientManagerTest, AcceptMatchAsync_CallWithValidRequest_GetNotification)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftAcceptMatchRequest request;
- request.m_acceptMatch = true;
- request.m_playerIds = { DummyPlayerId };
- request.m_ticketId = DummyMatchmakingTicketId;
- Aws::GameLift::Model::AcceptMatchResult result;
- Aws::GameLift::Model::AcceptMatchOutcome outcome(result);
- EXPECT_CALL(*m_gameliftClientMockPtr, AcceptMatch(::testing::_)).Times(1).WillOnce(::testing::Return(outcome));
- MatchmakingAsyncRequestNotificationsHandlerMock matchmakingHandlerMock;
- EXPECT_CALL(matchmakingHandlerMock, OnAcceptMatchAsyncComplete()).Times(1);
- m_gameliftClientManager->AcceptMatchAsync(request);
- }
- TEST_F(AWSGameLiftClientManagerTest, AcceptMatchAsync_CallWithValidRequest_GetNotificationWithError)
- {
- AWSCoreRequestsHandlerMock handlerMock;
- EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
- AWSGameLiftAcceptMatchRequest request;
- request.m_acceptMatch = true;
- request.m_playerIds = { DummyPlayerId };
- request.m_ticketId = DummyMatchmakingTicketId;
- Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
- Aws::GameLift::Model::AcceptMatchOutcome outcome(error);
- EXPECT_CALL(*m_gameliftClientMockPtr, AcceptMatch(::testing::_)).Times(1).WillOnce(::testing::Return(outcome));
- MatchmakingAsyncRequestNotificationsHandlerMock matchmakingHandlerMock;
- EXPECT_CALL(matchmakingHandlerMock, OnAcceptMatchAsyncComplete()).Times(1);
- AZ_TEST_START_TRACE_SUPPRESSION;
- m_gameliftClientManager->AcceptMatchAsync(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- }
|