IMultiplayerConnectionMock.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzNetworking/ConnectionLayer/IConnection.h>
  10. #include <gmock/gmock.h>
  11. // The following is a mock of IConnection used to test endpoints in MultiplayerSystemComponent
  12. // without an actual IConnection
  13. using namespace AzNetworking;
  14. class IMultiplayerConnectionMock : public IConnection
  15. {
  16. public:
  17. IMultiplayerConnectionMock(ConnectionId connectionId, const IpAddress& address, ConnectionRole connectionRole)
  18. : IConnection(connectionId, address)
  19. , m_role(connectionRole)
  20. {
  21. ;
  22. }
  23. ~IMultiplayerConnectionMock() override{};
  24. MOCK_METHOD1(SendReliablePacket, bool(const IPacket&));
  25. MOCK_METHOD1(SendUnreliablePacket, PacketId(const IPacket&));
  26. MOCK_CONST_METHOD1(WasPacketAcked, bool(const PacketId));
  27. MOCK_CONST_METHOD0(GetConnectionState, ConnectionState());
  28. ConnectionRole GetConnectionRole() const override
  29. {
  30. return m_role;
  31. };
  32. MOCK_METHOD2(Disconnect, bool(DisconnectReason, TerminationEndpoint));
  33. MOCK_METHOD1(SetConnectionMtu, void(uint32_t));
  34. MOCK_CONST_METHOD0(GetConnectionMtu, uint32_t());
  35. MOCK_METHOD1(SetConnectionMtu, void(const ConnectionQuality&));
  36. MOCK_METHOD1(SetConnectionQuality, void(const ConnectionQuality&));
  37. ConnectionRole m_role;
  38. };