3
0

EntityOwnershipServiceTestFixture.h 2.3 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. #pragma once
  9. #include <AzCore/Asset/AssetManager.h>
  10. #include <AzCore/Component/ComponentApplication.h>
  11. #include <AzCore/Memory/PoolAllocator.h>
  12. #include <AzCore/Slice/SliceAssetHandler.h>
  13. #include <AzCore/Slice/SliceComponent.h>
  14. #include <AzCore/UnitTest/TestTypes.h>
  15. #include <AzFramework/Application/Application.h>
  16. #include <AzFramework/Entity/GameEntityContextComponent.h>
  17. #include <AzFramework/Entity/SliceEntityOwnershipService.h>
  18. #include <AzToolsFramework/Application/ToolsApplication.h>
  19. #include <AzToolsFramework/Entity/SliceEditorEntityOwnershipService.h>
  20. namespace UnitTest
  21. {
  22. using EntityList = AZStd::vector<AZ::Entity*>;
  23. class EntityOwnershipServiceTestFixture
  24. : public LeakDetectionFixture
  25. {
  26. protected:
  27. AzFramework::RootSliceAsset GetRootSliceAsset();
  28. void SetUpEntityOwnershipServiceTest();
  29. void TearDownEntityOwnershipServiceTest();
  30. AzFramework::SliceInstantiationTicket AddSlice(const EntityList& entityList, const bool isAsynchronous = false);
  31. void AddEditorSlice(
  32. AZ::Data::Asset<AZ::SliceAsset>& sliceAsset, const AZ::Transform& worldTransform, const EntityList& entityList);
  33. AzFramework::SliceInstantiationTicket AddSlice(const EntityList& entityList, const bool isAsynchronous,
  34. AZ::Data::Asset<AZ::SliceAsset>& sliceAsset);
  35. void HandleEntitiesAdded(const AzFramework::EntityList& entityList);
  36. void HandleEntitiesRemoved(const AzFramework::EntityIdList& entityIds);
  37. bool ValidateEntities(const AzFramework::EntityList&);
  38. void AddSliceComponentToAsset(AZ::Data::Asset<AZ::SliceAsset>& sliceAsset, const EntityList& entityList);
  39. AZStd::unique_ptr<AzFramework::Application> m_app;
  40. bool m_entitiesAddedCallbackTriggered = false;
  41. bool m_entityRemovedCallbackTriggered = false;
  42. bool m_validateEntitiesCallbackTriggered = false;
  43. bool m_areEntitiesValidForContext = true;
  44. class EntityOwnershipServiceApplication : public AzToolsFramework::ToolsApplication
  45. {
  46. public:
  47. AZ::ComponentTypeList GetRequiredSystemComponents() const override;
  48. };
  49. };
  50. }