PrefabInstanceDomGeneratorTests.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <Prefab/PrefabInstanceDomGeneratorTestFixture.h>
  9. namespace UnitTest
  10. {
  11. using PrefabInstanceDomGeneratorTests = PrefabInstanceDomGeneratorTestFixture;
  12. TEST_F(PrefabInstanceDomGeneratorTests, GenerateInstanceDomForDescendantOfFocusedLevel)
  13. {
  14. // Generate a prefab DOM for the Wheel instance while the Level is in focus
  15. GenerateAndValidateInstanceDom(m_wheelInstance->get(), m_tireAlias, m_entityOverrideValueOnLevel);
  16. }
  17. TEST_F(PrefabInstanceDomGeneratorTests, GenerateInstanceDomForFocusedPrefab)
  18. {
  19. // Generate a prefab DOM for the Wheel instance while the Wheel instance is in focus
  20. m_prefabFocusPublicInterface->FocusOnOwningPrefab(m_wheelInstance->get().GetContainerEntityId());
  21. GenerateAndValidateInstanceDom(m_wheelInstance->get(), m_tireAlias, m_entityValueOnWheel);
  22. }
  23. TEST_F(PrefabInstanceDomGeneratorTests, GenerateInstanceDomForAncestorOfFocusedPrefab)
  24. {
  25. // Generate a prefab DOM for the Car instance while the Wheel instance is in focus
  26. m_prefabFocusPublicInterface->FocusOnOwningPrefab(m_wheelInstance->get().GetContainerEntityId());
  27. GenerateAndValidateInstanceDom(m_carInstance->get(), m_tireAlias, m_entityValueOnWheel);
  28. }
  29. TEST_F(PrefabInstanceDomGeneratorTests, GenerateEntityDomForDescendantOfFocusedPrefab)
  30. {
  31. const AZ::Entity& tireEntity = m_wheelInstance->get().GetEntity(m_tireAlias)->get();
  32. // Focus is on Level by default
  33. GenerateAndValidateEntityDom(tireEntity, m_entityOverrideValueOnLevel);
  34. // Change focus to Car
  35. m_prefabFocusPublicInterface->FocusOnOwningPrefab(m_carInstance->get().GetContainerEntityId());
  36. GenerateAndValidateEntityDom(tireEntity, m_entityOverrideValueOnCar);
  37. // Change focus to Wheel
  38. m_prefabFocusPublicInterface->FocusOnOwningPrefab(m_wheelInstance->get().GetContainerEntityId());
  39. GenerateAndValidateEntityDom(tireEntity, m_entityValueOnWheel);
  40. }
  41. TEST_F(PrefabInstanceDomGeneratorTests, GenerateEntityDomForContainerOfFocusedPrefab)
  42. {
  43. const AZ::Entity& containerEntity = m_wheelInstance->get().GetContainerEntity()->get();
  44. // Change focus to Wheel, so the container entity DOM should come from the root
  45. m_prefabFocusPublicInterface->FocusOnOwningPrefab(m_wheelInstance->get().GetContainerEntityId());
  46. GenerateAndValidateEntityDom(containerEntity, m_wheelContainerOverrideValueOnLevel);
  47. }
  48. } // namespace UnitTest