Converted to use AZ::Events for hiearchy notifications. Added unittests.

Signed-off-by: AMZN-Olex <5432499+AMZN-Olex@users.noreply.github.com>
This commit is contained in:
AMZN-Olex
2021-09-14 11:50:51 -04:00
parent 088511577b
commit fcd5b3f184
9 changed files with 131 additions and 37 deletions
@@ -226,7 +226,6 @@ namespace Multiplayer
ReplicationRecord notifyRecord = currentRecord;
entity.FindComponent<NetworkHierarchyChildComponent>()->SerializeStateDeltaMessage(currentRecord, outSerializer);
entity.FindComponent<NetworkHierarchyChildComponent>()->NotifyStateDeltaChanges(notifyRecord);
}
@@ -287,6 +286,30 @@ namespace Multiplayer
);
}
TEST_F(ClientSimpleHierarchyTests, Client_Sends_NetworkHierarchy_Updated_Event_On_Child_Detached_On_Server)
{
MockNetworkHierarchyCallbackHandler mock;
EXPECT_CALL(mock, OnNetworkHierarchyUpdated(m_rootEntity->GetId()));
m_rootEntity->FindComponent<NetworkHierarchyRootComponent>()->BindNetworkHierarchyChangedEventHandler(mock.m_changedHandler);
// simulate server detaching a child entity
SetParentIdOnNetworkTransform(*m_childEntity, InvalidNetEntityId);
SetHierarchyRootFieldOnNetworkHierarchyChildOnClient(*m_childEntity, InvalidNetEntityId);
}
TEST_F(ClientSimpleHierarchyTests, Client_Sends_NetworkHierarchy_Leave_Event_On_Child_Detached_On_Server)
{
MockNetworkHierarchyCallbackHandler mock;
EXPECT_CALL(mock, OnNetworkHierarchyLeave);
m_childEntity->FindComponent<NetworkHierarchyChildComponent>()->BindNetworkHierarchyLeaveEventHandler(mock.m_leaveHandler);
// simulate server detaching a child entity
SetParentIdOnNetworkTransform(*m_childEntity, InvalidNetEntityId);
SetHierarchyRootFieldOnNetworkHierarchyChildOnClient(*m_childEntity, InvalidNetEntityId);
}
/*
* Parent -> Child -> ChildOfChild
*/