[GameLift][FlexMatch] Add client side change for match acceptance (#4634)

* [GameLift][FlexMatch] Add client side change for match acceptance required

Signed-off-by: Junbo Liang <junbo@amazon.com>
This commit is contained in:
Junbo Liang
2021-10-13 11:34:13 -07:00
committed by GitHub
parent 150060441e
commit 26d53690b9
17 changed files with 409 additions and 8 deletions
@@ -10,6 +10,7 @@
#include <AzCore/std/bind/bind.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <AzFramework/Session/ISessionHandlingRequests.h>
#include <AzFramework/Matchmaking/MatchmakingNotifications.h>
#include <AWSGameLiftClientLocalTicketTracker.h>
#include <AWSGameLiftSessionConstants.h>
@@ -109,6 +110,7 @@ namespace AWSGameLift
else if (ticket.GetStatus() == Aws::GameLift::Model::MatchmakingConfigurationStatus::REQUIRES_ACCEPTANCE)
{
// broadcast acceptance requires to player
AzFramework::MatchAcceptanceNotificationBus::Broadcast(&AzFramework::MatchAcceptanceNotifications::OnMatchAcceptance);
}
else
{
@@ -18,6 +18,7 @@
#include <AWSGameLiftClientManager.h>
#include <AWSGameLiftSessionConstants.h>
#include <Activity/AWSGameLiftAcceptMatchActivity.h>
#include <Activity/AWSGameLiftCreateSessionActivity.h>
#include <Activity/AWSGameLiftCreateSessionOnQueueActivity.h>
#include <Activity/AWSGameLiftJoinSessionActivity.h>
@@ -125,12 +126,53 @@ namespace AWSGameLift
void AWSGameLiftClientManager::AcceptMatch(const AzFramework::AcceptMatchRequest& acceptMatchRequest)
{
AZ_UNUSED(acceptMatchRequest);
if (AcceptMatchActivity::ValidateAcceptMatchRequest(acceptMatchRequest))
{
const AWSGameLiftAcceptMatchRequest& gameliftStartMatchmakingRequest =
static_cast<const AWSGameLiftAcceptMatchRequest&>(acceptMatchRequest);
AcceptMatchHelper(gameliftStartMatchmakingRequest);
}
}
void AWSGameLiftClientManager::AcceptMatchAsync(const AzFramework::AcceptMatchRequest& acceptMatchRequest)
{
AZ_UNUSED(acceptMatchRequest);
if (!AcceptMatchActivity::ValidateAcceptMatchRequest(acceptMatchRequest))
{
AzFramework::MatchmakingAsyncRequestNotificationBus::Broadcast(
&AzFramework::MatchmakingAsyncRequestNotifications::OnAcceptMatchAsyncComplete);
return;
}
const AWSGameLiftAcceptMatchRequest& gameliftStartMatchmakingRequest = static_cast<const AWSGameLiftAcceptMatchRequest&>(acceptMatchRequest);
AZ::JobContext* jobContext = nullptr;
AWSCore::AWSCoreRequestBus::BroadcastResult(jobContext, &AWSCore::AWSCoreRequests::GetDefaultJobContext);
AZ::Job* acceptMatchJob = AZ::CreateJobFunction(
[this, gameliftStartMatchmakingRequest]()
{
AcceptMatchHelper(gameliftStartMatchmakingRequest);
AzFramework::MatchmakingAsyncRequestNotificationBus::Broadcast(
&AzFramework::MatchmakingAsyncRequestNotifications::OnAcceptMatchAsyncComplete);
},
true, jobContext);
acceptMatchJob->Start();
}
void AWSGameLiftClientManager::AcceptMatchHelper(const AWSGameLiftAcceptMatchRequest& acceptMatchRequest)
{
auto gameliftClient = AZ::Interface<IAWSGameLiftInternalRequests>::Get()->GetGameLiftClient();
AZStd::string response;
if (!gameliftClient)
{
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftClientMissingErrorMessage);
}
else
{
AcceptMatchActivity::AcceptMatch(*gameliftClient, acceptMatchRequest);
}
}
AZStd::string AWSGameLiftClientManager::CreateSession(const AzFramework::CreateSessionRequest& createSessionRequest)
@@ -15,6 +15,7 @@
namespace AWSGameLift
{
struct AWSGameLiftAcceptMatchRequest;
struct AWSGameLiftCreateSessionRequest;
struct AWSGameLiftCreateSessionOnQueueRequest;
struct AWSGameLiftJoinSessionRequest;
@@ -158,6 +159,7 @@ namespace AWSGameLift
void LeaveSession() override;
private:
void AcceptMatchHelper(const AWSGameLiftAcceptMatchRequest& createSessionRequest);
AZStd::string CreateSessionHelper(const AWSGameLiftCreateSessionRequest& createSessionRequest);
AZStd::string CreateSessionOnQueueHelper(const AWSGameLiftCreateSessionOnQueueRequest& createSessionOnQueueRequest);
bool JoinSessionHelper(const AWSGameLiftJoinSessionRequest& joinSessionRequest);
@@ -0,0 +1,76 @@
/*
* 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.AcceptMatch
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/Interface/Interface.h>
#include <Activity/AWSGameLiftAcceptMatchActivity.h>
#include <AWSGameLiftSessionConstants.h>
#include <aws/core/utils/Outcome.h>
#include <aws/gamelift/model/AcceptMatchRequest.h>
namespace AWSGameLift
{
namespace AcceptMatchActivity
{
Aws::GameLift::Model::AcceptMatchRequest BuildAWSGameLiftAcceptMatchRequest(
const AWSGameLiftAcceptMatchRequest& acceptMatchRequest)
{
Aws::GameLift::Model::AcceptMatchRequest request;
request.SetAcceptanceType(acceptMatchRequest.m_acceptMatch ?
Aws::GameLift::Model::AcceptanceType::ACCEPT : Aws::GameLift::Model::AcceptanceType::REJECT);
Aws::Vector<Aws::String> playerIds;
for (const AZStd::string& playerId : acceptMatchRequest.m_playerIds)
{
playerIds.emplace_back(playerId.c_str());
}
request.SetPlayerIds(playerIds);
if (!acceptMatchRequest.m_ticketId.empty())
{
request.SetTicketId(acceptMatchRequest.m_ticketId.c_str());
}
AZ_TracePrintf(AWSGameLiftAcceptMatchActivityName, "Built AcceptMatchRequest with TicketId=%s", request.GetTicketId().c_str());
return request;
}
void AcceptMatch(const Aws::GameLift::GameLiftClient& gameliftClient,
const AWSGameLiftAcceptMatchRequest& AcceptMatchRequest)
{
AZ_TracePrintf(AWSGameLiftAcceptMatchActivityName, "Requesting AcceptMatch against Amazon GameLift service ...");
Aws::GameLift::Model::AcceptMatchRequest request = BuildAWSGameLiftAcceptMatchRequest(AcceptMatchRequest);
auto AcceptMatchOutcome = gameliftClient.AcceptMatch(request);
if (AcceptMatchOutcome.IsSuccess())
{
AZ_TracePrintf(AWSGameLiftAcceptMatchActivityName, "AcceptMatch request against Amazon GameLift service is complete");
}
else
{
AZ_Error(AWSGameLiftAcceptMatchActivityName, false, AWSGameLiftErrorMessageTemplate,
AcceptMatchOutcome.GetError().GetExceptionName().c_str(), AcceptMatchOutcome.GetError().GetMessage().c_str());
}
}
bool ValidateAcceptMatchRequest(const AzFramework::AcceptMatchRequest& AcceptMatchRequest)
{
auto gameliftAcceptMatchRequest = azrtti_cast<const AWSGameLiftAcceptMatchRequest*>(&AcceptMatchRequest);
bool isValid = gameliftAcceptMatchRequest &&
(gameliftAcceptMatchRequest->m_playerIds.size() > 0) &&
(!gameliftAcceptMatchRequest->m_ticketId.empty());
AZ_Error(AWSGameLiftAcceptMatchActivityName, isValid, AWSGameLiftAcceptMatchRequestInvalidErrorMessage);
return isValid;
}
} // namespace AcceptMatchActivity
} // namespace AWSGameLift
@@ -0,0 +1,31 @@
/*
* 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
*
*/
#pragma once
#include <Request/AWSGameLiftAcceptMatchRequest.h>
#include <aws/gamelift/GameLiftClient.h>
namespace AWSGameLift
{
namespace AcceptMatchActivity
{
static constexpr const char AWSGameLiftAcceptMatchActivityName[] = "AWSGameLiftAcceptMatchActivity";
static constexpr const char AWSGameLiftAcceptMatchRequestInvalidErrorMessage[] = "Invalid GameLift AcceptMatch request.";
// Build AWS GameLift AcceptMatchRequest by using AWSGameLiftAcceptMatchRequest
Aws::GameLift::Model::AcceptMatchRequest BuildAWSGameLiftAcceptMatchRequest(const AWSGameLiftAcceptMatchRequest& AcceptMatchRequest);
// Create AcceptMatchRequest and make a AcceptMatch call through GameLift client
void AcceptMatch(const Aws::GameLift::GameLiftClient& gameliftClient, const AWSGameLiftAcceptMatchRequest& AcceptMatchRequest);
// Validate AcceptMatchRequest and check required request parameters
bool ValidateAcceptMatchRequest(const AzFramework::AcceptMatchRequest& AcceptMatchRequest);
} // namespace AcceptMatchActivity
} // namespace AWSGameLift
@@ -5,12 +5,16 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/Interface/Interface.h>
#include <Activity/AWSGameLiftActivityUtils.h>
#include <Activity/AWSGameLiftStartMatchmakingActivity.h>
#include <AWSGameLiftSessionConstants.h>
#include <aws/core/utils/Outcome.h>
#include <aws/gamelift/model/StartMatchmakingRequest.h>
namespace AWSGameLift
{
namespace StartMatchmakingActivity
@@ -10,9 +10,7 @@
#include <Request/AWSGameLiftStartMatchmakingRequest.h>
#include <aws/core/utils/Outcome.h>
#include <aws/gamelift/GameLiftClient.h>
#include <aws/gamelift/model/StartMatchmakingRequest.h>
namespace AWSGameLift
{
@@ -25,7 +23,6 @@ namespace AWSGameLift
Aws::GameLift::Model::StartMatchmakingRequest BuildAWSGameLiftStartMatchmakingRequest(const AWSGameLiftStartMatchmakingRequest& startMatchmakingRequest);
// Create StartMatchmakingRequest and make a StartMatchmaking call through GameLift client
// Will also start polling the matchmaking ticket when get success outcome from GameLift client
AZStd::string StartMatchmaking(const Aws::GameLift::GameLiftClient& gameliftClient, const AWSGameLiftStartMatchmakingRequest& startMatchmakingRequest);
// Validate StartMatchmakingRequest and check required request parameters
@@ -11,6 +11,9 @@
#include <Activity/AWSGameLiftStopMatchmakingActivity.h>
#include <AWSGameLiftSessionConstants.h>
#include <aws/core/utils/Outcome.h>
#include <aws/gamelift/model/StopMatchmakingRequest.h>
namespace AWSGameLift
{
namespace StopMatchmakingActivity
@@ -10,9 +10,7 @@
#include <Request/AWSGameLiftStopMatchmakingRequest.h>
#include <aws/core/utils/Outcome.h>
#include <aws/gamelift/GameLiftClient.h>
#include <aws/gamelift/model/StopMatchmakingRequest.h>
namespace AWSGameLift
{
@@ -25,7 +23,6 @@ namespace AWSGameLift
Aws::GameLift::Model::StopMatchmakingRequest BuildAWSGameLiftStopMatchmakingRequest(const AWSGameLiftStopMatchmakingRequest& stopMatchmakingRequest);
// Create StopMatchmakingRequest and make a StopMatchmaking call through GameLift client
// Will also stop polling the matchmaking ticket when get success outcome from GameLift client
void StopMatchmaking(const Aws::GameLift::GameLiftClient& gameliftClient, const AWSGameLiftStopMatchmakingRequest& stopMatchmakingRequest);
// Validate StopMatchmakingRequest and check required request parameters
@@ -351,3 +351,41 @@ TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallAndTicketComple
WaitForProcessFinish();
ASSERT_TRUE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_RequiresAcceptanceAndTicketCompleteAtLast_ProcessContinuesAndStop)
{
Aws::GameLift::Model::MatchmakingTicket ticket1;
ticket1.SetStatus(Aws::GameLift::Model::MatchmakingConfigurationStatus::REQUIRES_ACCEPTANCE);
Aws::GameLift::Model::DescribeMatchmakingResult result1;
result1.AddTicketList(ticket1);
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome1(result1);
Aws::GameLift::Model::GameSessionConnectionInfo connectionInfo;
connectionInfo.SetIpAddress("DummyIpAddress");
connectionInfo.SetPort(123);
connectionInfo.AddMatchedPlayerSessions(
Aws::GameLift::Model::MatchedPlayerSession().WithPlayerId("player1").WithPlayerSessionId("playersession1"));
Aws::GameLift::Model::MatchmakingTicket ticket2;
ticket2.SetStatus(Aws::GameLift::Model::MatchmakingConfigurationStatus::COMPLETED);
ticket2.SetGameSessionConnectionInfo(connectionInfo);
Aws::GameLift::Model::DescribeMatchmakingResult result2;
result2.AddTicketList(ticket2);
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome2(result2);
EXPECT_CALL(*m_gameliftClientMockPtr, DescribeMatchmaking(::testing::_))
.WillOnce(::testing::Return(outcome1))
.WillOnce(::testing::Return(outcome2));
MatchAcceptanceNotificationsHandlerMock handlerMock1;
EXPECT_CALL(handlerMock1, OnMatchAcceptance()).Times(1);
SessionHandlingClientRequestsMock handlerMock2;
EXPECT_CALL(handlerMock2, RequestPlayerJoinSession(::testing::_)).Times(1).WillOnce(::testing::Return(true));
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish();
ASSERT_TRUE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
@@ -19,6 +19,7 @@
#include <AWSGameLiftClientManager.h>
#include <AWSGameLiftClientMocks.h>
#include <Request/AWSGameLiftAcceptMatchRequest.h>
#include <Request/AWSGameLiftCreateSessionOnQueueRequest.h>
#include <Request/AWSGameLiftCreateSessionRequest.h>
#include <Request/AWSGameLiftJoinSessionRequest.h>
@@ -1005,3 +1006,106 @@ TEST_F(AWSGameLiftClientManagerTest, StopMatchmakingAsync_CallWithValidRequest_G
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(AzFramework::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
}
@@ -9,6 +9,7 @@
#pragma once
#include <AzCore/Interface/Interface.h>
#include <AzFramework/Matchmaking/MatchmakingNotifications.h>
#include <AzFramework/Session/ISessionRequests.h>
#include <AzFramework/Session/ISessionHandlingRequests.h>
#include <AzFramework/Matchmaking/MatchmakingNotifications.h>
@@ -18,6 +19,8 @@
#include <aws/core/utils/Outcome.h>
#include <aws/gamelift/GameLiftClient.h>
#include <aws/gamelift/GameLiftErrors.h>
#include <aws/gamelift/model/AcceptMatchRequest.h>
#include <aws/gamelift/model/AcceptMatchResult.h>
#include <aws/gamelift/model/CreateGameSessionRequest.h>
#include <aws/gamelift/model/CreateGameSessionResult.h>
#include <aws/gamelift/model/CreatePlayerSessionRequest.h>
@@ -46,6 +49,7 @@ public:
{
}
MOCK_CONST_METHOD1(AcceptMatch, Model::AcceptMatchOutcome(const Model::AcceptMatchRequest&));
MOCK_CONST_METHOD1(CreateGameSession, Model::CreateGameSessionOutcome(const Model::CreateGameSessionRequest&));
MOCK_CONST_METHOD1(CreatePlayerSession, Model::CreatePlayerSessionOutcome(const Model::CreatePlayerSessionRequest&));
MOCK_CONST_METHOD1(DescribeMatchmaking, Model::DescribeMatchmakingOutcome(const Model::DescribeMatchmakingRequest&));
@@ -74,6 +78,23 @@ public:
MOCK_METHOD0(OnStopMatchmakingAsyncComplete, void());
};
class MatchAcceptanceNotificationsHandlerMock
: public AzFramework::MatchAcceptanceNotificationBus::Handler
{
public:
MatchAcceptanceNotificationsHandlerMock()
{
AzFramework::MatchAcceptanceNotificationBus::Handler::BusConnect();
}
~MatchAcceptanceNotificationsHandlerMock()
{
AzFramework::MatchAcceptanceNotificationBus::Handler::BusDisconnect();
}
MOCK_METHOD0(OnMatchAcceptance, void());
};
class SessionAsyncRequestNotificationsHandlerMock
: public AzFramework::SessionAsyncRequestNotificationBus::Handler
{
@@ -0,0 +1,77 @@
/*
* 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 <aws/gamelift/model/AcceptMatchRequest.h>
#include <AWSGameLiftClientFixture.h>
#include <Activity/AWSGameLiftAcceptMatchActivity.h>
#include <aws/gamelift/model/AcceptMatchRequest.h>
using namespace AWSGameLift;
using AWSGameLiftAcceptMatchActivityTest = AWSGameLiftClientFixture;
TEST_F(AWSGameLiftAcceptMatchActivityTest, BuildAWSGameLiftAcceptMatchRequest_Call_GetExpectedResult)
{
AWSGameLiftAcceptMatchRequest request;
request.m_acceptMatch = true;
request.m_ticketId = "dummyTicketId";
request.m_playerIds = { "dummyPlayerId" };
auto awsRequest = AcceptMatchActivity::BuildAWSGameLiftAcceptMatchRequest(request);
EXPECT_EQ(awsRequest.GetAcceptanceType(), Aws::GameLift::Model::AcceptanceType::ACCEPT);
EXPECT_TRUE(strcmp(awsRequest.GetTicketId().c_str(), request.m_ticketId.c_str()) == 0);
EXPECT_EQ(awsRequest.GetPlayerIds().size(), request.m_playerIds.size());
EXPECT_TRUE(strcmp(awsRequest.GetPlayerIds().begin()->c_str(), request.m_playerIds.begin()->c_str()) == 0);
}
TEST_F(AWSGameLiftAcceptMatchActivityTest, ValidateAcceptMatchRequest_CallWithBaseType_GetFalseResult)
{
AZ_TEST_START_TRACE_SUPPRESSION;
auto result = AcceptMatchActivity::ValidateAcceptMatchRequest(AzFramework::AcceptMatchRequest());
EXPECT_FALSE(result);
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
}
TEST_F(AWSGameLiftAcceptMatchActivityTest, ValidateAcceptMatchRequest_CallWithoutTicketId_GetFalseResult)
{
AWSGameLiftAcceptMatchRequest request;
request.m_acceptMatch = true;
request.m_playerIds = { "dummyPlayerId" };
AZ_TEST_START_TRACE_SUPPRESSION;
auto result = AcceptMatchActivity::ValidateAcceptMatchRequest(request);
EXPECT_FALSE(result);
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
}
TEST_F(AWSGameLiftAcceptMatchActivityTest, ValidateAcceptMatchRequest_CallWithoutPlayerIds_GetFalseResult)
{
AWSGameLiftAcceptMatchRequest request;
request.m_acceptMatch = true;
request.m_playerIds = { "dummyPlayerId" };
AZ_TEST_START_TRACE_SUPPRESSION;
auto result = AcceptMatchActivity::ValidateAcceptMatchRequest(request);
EXPECT_FALSE(result);
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
}
TEST_F(AWSGameLiftAcceptMatchActivityTest, ValidateAcceptMatchRequest_CallWithValidAttributes_GetTrueResult)
{
AWSGameLiftAcceptMatchRequest request;
request.m_acceptMatch = true;
request.m_ticketId = "dummyTicketId";
request.m_playerIds = { "dummyPlayerId" };
auto result = AcceptMatchActivity::ValidateAcceptMatchRequest(request);
EXPECT_TRUE(result);
}
@@ -9,6 +9,8 @@
#include <Activity/AWSGameLiftStartMatchmakingActivity.h>
#include <AWSGameLiftClientFixture.h>
#include <aws/gamelift/model/StartMatchmakingRequest.h>
using namespace AWSGameLift;
using AWSGameLiftStartMatchmakingActivityTest = AWSGameLiftClientFixture;
@@ -9,6 +9,8 @@
#include <Activity/AWSGameLiftStopMatchmakingActivity.h>
#include <AWSGameLiftClientFixture.h>
#include <aws/gamelift/model/StopMatchmakingRequest.h>
using namespace AWSGameLift;
using AWSGameLiftStopMatchmakingActivityTest = AWSGameLiftClientFixture;
@@ -18,6 +18,8 @@ set(FILES
Include/Request/IAWSGameLiftRequests.h
Source/Activity/AWSGameLiftActivityUtils.cpp
Source/Activity/AWSGameLiftActivityUtils.h
Source/Activity/AWSGameLiftAcceptMatchActivity.cpp
Source/Activity/AWSGameLiftAcceptMatchActivity.h
Source/Activity/AWSGameLiftCreateSessionActivity.cpp
Source/Activity/AWSGameLiftCreateSessionActivity.h
Source/Activity/AWSGameLiftCreateSessionOnQueueActivity.cpp
@@ -7,6 +7,7 @@
#
set(FILES
Tests/Activity/AWSGameLiftAcceptMatchActivityTest.cpp
Tests/Activity/AWSGameLiftCreateSessionActivityTest.cpp
Tests/Activity/AWSGameLiftCreateSessionOnQueueActivityTest.cpp
Tests/Activity/AWSGameLiftJoinSessionActivityTest.cpp