ConnectionUnitTests.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #include <native/unittests/AssetProcessorUnitTests.h>
  9. class ConnectionForSendTest : public Connection
  10. {
  11. public:
  12. ConnectionForSendTest() : Connection() {}
  13. ~ConnectionForSendTest() = default;
  14. ConnectionForSendTest(ConnectionForSendTest&) = delete;
  15. ConnectionForSendTest(ConnectionForSendTest&&) = delete;
  16. MOCK_METHOD2(Send, size_t(unsigned int /*serial*/, const AzFramework::AssetSystem::BaseAssetProcessorMessage& /*message*/));
  17. };
  18. class ConnectionUnitTest
  19. : public UnitTest::AssetProcessorUnitTestBase
  20. {
  21. protected:
  22. ::testing::NiceMock<ConnectionForSendTest> m_testConnection;
  23. };
  24. TEST_F(ConnectionUnitTest, SendPerPlatform_SendMessage_Succeeds)
  25. {
  26. m_testConnection.SetAssetPlatformsString("pc");
  27. AzFramework::AssetSystem::AssetNotificationMessage testMessage;
  28. EXPECT_CALL(m_testConnection, Send(testing::_, testing::_)).Times(0);
  29. m_testConnection.SendPerPlatform(0, testMessage, "mac");
  30. EXPECT_CALL(m_testConnection, Send(testing::_, testing::_)).Times(1);
  31. m_testConnection.SendPerPlatform(0, testMessage, "pc");
  32. m_testConnection.SetAssetPlatformsString("pc,android");
  33. EXPECT_CALL(m_testConnection, Send(testing::_, testing::_)).Times(1);
  34. m_testConnection.SendPerPlatform(0, testMessage, "pc");
  35. EXPECT_CALL(m_testConnection, Send(testing::_, testing::_)).Times(0);
  36. m_testConnection.SendPerPlatform(0, testMessage, "mac");
  37. EXPECT_CALL(m_testConnection, Send(testing::_, testing::_)).Times(1);
  38. m_testConnection.SendPerPlatform(0, testMessage, "android");
  39. EXPECT_CALL(m_testConnection, Send(testing::_, testing::_)).Times(0);
  40. // Intended partial string match test - shouldn't send
  41. m_testConnection.SendPerPlatform(0, testMessage, "es");
  42. }