SurfaceMaterialsListTest.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 <AzTest/AzTest.h>
  9. #include <AzCore/Component/ComponentApplication.h>
  10. #include <TerrainRenderer/Components/TerrainSurfaceMaterialsListComponent.h>
  11. #include <MockAxisAlignedBoxShapeComponent.h>
  12. #include <TerrainTestFixtures.h>
  13. using ::testing::NiceMock;
  14. using ::testing::AtLeast;
  15. using ::testing::_;
  16. namespace UnitTest
  17. {
  18. class TerrainSurfaceMaterialsListTest
  19. : public TerrainTestFixture
  20. {
  21. protected:
  22. constexpr static inline float TestBoxHalfBounds = 128.0f;
  23. };
  24. TEST_F(TerrainSurfaceMaterialsListTest, SurfaceMaterialsListRequiresShapeToActivate)
  25. {
  26. // Check that the component requires a shape service to activate: trying to Activate the entity will cause the test to fail, so
  27. // use the EvaluateDependenciesGetDetails function to check the dependencies are met.
  28. auto entity = CreateEntity();
  29. entity->CreateComponent<Terrain::TerrainSurfaceMaterialsListComponent>();
  30. const AZ::Entity::DependencySortOutcome sortOutcome = entity->EvaluateDependenciesGetDetails();
  31. EXPECT_FALSE(sortOutcome.IsSuccess());
  32. entity.reset();
  33. }
  34. TEST_F(TerrainSurfaceMaterialsListTest, SurfaceMaterialsListActivatesSuccessfully)
  35. {
  36. auto entity = CreateTestBoxEntity(TestBoxHalfBounds);
  37. entity->CreateComponent<Terrain::TerrainSurfaceMaterialsListComponent>();
  38. ActivateEntity(entity.get());
  39. EXPECT_EQ(entity->GetState(), AZ::Entity::State::Active);
  40. entity.reset();
  41. }
  42. } // namespace UnitTest