2
0

ReadOnlyEntityFixture.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <AzCore/Component/TransformBus.h>
  10. #include <AzCore/UnitTest/TestTypes.h>
  11. #include <AzTest/AzTest.h>
  12. #include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
  13. #include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityBus.h>
  14. #include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
  15. namespace AzToolsFramework
  16. {
  17. class ReadOnlyEntityFixture
  18. : public UnitTest::ToolsApplicationFixture<>
  19. {
  20. protected:
  21. void SetUpEditorFixtureImpl() override;
  22. void TearDownEditorFixtureImpl() override;
  23. void GenerateTestHierarchy();
  24. AZ::EntityId CreateEditorEntity(const char* name, AZ::EntityId parentId);
  25. AZStd::unordered_map<AZStd::string, AZ::EntityId> m_entityMap;
  26. ReadOnlyEntityPublicInterface* m_readOnlyEntityPublicInterface = nullptr;
  27. public:
  28. inline static const char* RootEntityName = "Root";
  29. inline static const char* ChildEntityName = "Child";
  30. inline static const char* GrandChild1EntityName = "GrandChild1";
  31. inline static const char* GrandChild2EntityName = "GrandChild2";
  32. };
  33. class ReadOnlyHandlerAlwaysTrue
  34. : public ReadOnlyEntityQueryRequestBus::Handler
  35. {
  36. public:
  37. ReadOnlyHandlerAlwaysTrue();
  38. ~ReadOnlyHandlerAlwaysTrue();
  39. // ReadOnlyEntityQueryNotificationBus overrides ...
  40. void IsReadOnly(const AZ::EntityId& entityId, bool& isReadOnly) override;
  41. };
  42. class ReadOnlyHandlerAlwaysFalse
  43. : public ReadOnlyEntityQueryRequestBus::Handler
  44. {
  45. public:
  46. ReadOnlyHandlerAlwaysFalse();
  47. ~ReadOnlyHandlerAlwaysFalse();
  48. // ReadOnlyEntityQueryNotificationBus overrides ...
  49. void IsReadOnly([[maybe_unused]] const AZ::EntityId& entityId, [[maybe_unused]] bool& isReadOnly) override {}
  50. };
  51. class ReadOnlyHandlerEntityId
  52. : public ReadOnlyEntityQueryRequestBus::Handler
  53. {
  54. public:
  55. ReadOnlyHandlerEntityId(AZ::EntityId entityId);
  56. ~ReadOnlyHandlerEntityId();
  57. // ReadOnlyEntityQueryNotificationBus overrides ...
  58. void IsReadOnly(const AZ::EntityId& entityId, bool& isReadOnly) override;
  59. private:
  60. AZ::EntityId m_entityId;
  61. };
  62. }