PrefabUndoComponentPropertyTestFixture.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #include <AzToolsFramework/Prefab/Overrides/PrefabOverridePublicInterface.h>
  11. namespace UnitTest
  12. {
  13. using namespace AzToolsFramework::Prefab;
  14. class PrefabUndoComponentPropertyTestFixture
  15. : public PrefabTestFixture
  16. {
  17. protected:
  18. inline static const char* WheelEntityName = "WheelEntity";
  19. inline static const char* CarPrefabName = "CarPrefab";
  20. inline static const char* SuperCarPrefabName = "SuperCarPrefab";
  21. //! Contains entity info of the created entity.
  22. struct EntityInfo
  23. {
  24. AZ::EntityId m_entityId;
  25. EntityAlias m_entityAlias;
  26. };
  27. //! Contains instance info of the created prefab instance.
  28. struct InstanceInfo
  29. {
  30. AZ::EntityId m_containerEntityId;
  31. InstanceAlias m_instanceAlias;
  32. };
  33. //! Contains a change patch to the property value.
  34. struct PropertyChangePatch
  35. {
  36. AZ::Dom::Path m_pathToPropertyFromOwningEntity;
  37. AZ::Dom::Value m_propertyValue;
  38. };
  39. void SetUpEditorFixtureImpl() override;
  40. //! Creates entities and prefabs for testing. SuperCar prefab owns a Car prefab. Car prefab owns a Wheel entity.
  41. //! @{
  42. void CreateWheelEntityHierarchy(EntityInfo& wheelEntityInfo);
  43. void CreateCarPrefabHierarchy(InstanceInfo& carInstanceInfo, EntityInfo& wheelEntityInfo);
  44. void CreateSuperCarPrefabHierarchy(InstanceInfo& superCarInstanceInfo, InstanceInfo& carInstanceInfo, EntityInfo& wheelEntityInfo);
  45. //! @}
  46. //! Generates property change patch for various properties.
  47. //! The data will be used in configuring undo nodes.
  48. //! @{
  49. PropertyChangePatch MakeTransformTranslationPropertyChangePatch(const AZ::EntityId entityId, const AZ::Vector3& translation);
  50. PropertyChangePatch MakeTransformStaticPropertyChangePatch(const AZ::EntityId entityId, const float isStatic);
  51. //! @}
  52. //! Helper function to convert AZ::Dom::Value to PrefabDom (rapidjson::Document).
  53. void ConvertToPrefabDomValue(PrefabDom& outputDom, const AZ::Dom::Value& domValue);
  54. PrefabOverridePublicInterface* m_prefabOverridePublicInterface = nullptr;
  55. };
  56. } // namespace UnitTest