PrefabInstanceDomGeneratorTestFixture.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <Prefab/PrefabTestFixture.h>
  10. namespace UnitTest
  11. {
  12. using namespace AzToolsFramework::Prefab;
  13. //! Fixture for testing instance DOM generation based on the focused prefab via existing template DOMS
  14. class PrefabInstanceDomGeneratorTestFixture
  15. : public PrefabTestFixture
  16. {
  17. protected:
  18. void SetUpEditorFixtureImpl() override;
  19. void GenerateAndValidateInstanceDom(const Instance& instance, EntityAlias entityAlias, float expectedValue);
  20. void GenerateAndValidateEntityDom(const AZ::Entity& entity, float expectedValue);
  21. // Protected members
  22. const float m_entityOverrideValueOnLevel = 1.0f;
  23. const float m_entityOverrideValueOnCar = 2.0f;
  24. const float m_entityValueOnWheel = 3.0f;
  25. const float m_wheelContainerOverrideValueOnLevel = 1.0f;
  26. InstanceOptionalReference m_carInstance;
  27. InstanceOptionalReference m_wheelInstance;
  28. EntityAlias m_tireAlias;
  29. PrefabFocusPublicInterface* m_prefabFocusPublicInterface = nullptr;
  30. private:
  31. void SetUpInstanceHierarchy();
  32. void InitializePrefabTemplates();
  33. //! Finds an entity in the provided instance by recursing through its nested prefab hierarchy
  34. EntityOptionalReference FindEntityInInstanceHierarchy(
  35. Instance& instance,
  36. EntityAlias entityAlias);
  37. //! Helpers that apply patches to in-memory template DOMs to simulate overrides
  38. void GenerateWorldXEntityPatch(
  39. const EntityAlias& entityAlias,
  40. float updatedXValue,
  41. Instance& owningInstance,
  42. PrefabDom& patchOut);
  43. void UpdateWorldXEntityPatch(PrefabDom& patch, double newValue);
  44. void ApplyEntityPatchToTemplate(
  45. PrefabDom& patch,
  46. const EntityAlias& entityAlias,
  47. const Instance& owningInstance,
  48. const Instance& targetInstance);
  49. // Private members
  50. InstanceDomGeneratorInterface* m_instanceDomGeneratorInterface = nullptr;
  51. };
  52. }