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. namespace UnitTest
  20. {
  21. using EntityList = AZStd::vector<AZ::Entity*>;
  22. class EntityOwnershipServiceTestFixture
  23. : public LeakDetectionFixture
  24. {
  25. protected:
  26. AzFramework::RootSliceAsset GetRootSliceAsset();
  27. void SetUpEntityOwnershipServiceTest();
  28. void TearDownEntityOwnershipServiceTest();
  29. AzFramework::SliceInstantiationTicket AddSlice(const EntityList& entityList, const bool isAsynchronous = false);
  30. void AddEditorSlice(
  31. AZ::Data::Asset<AZ::SliceAsset>& sliceAsset, const AZ::Transform& worldTransform, const EntityList& entityList);
  32. AzFramework::SliceInstantiationTicket AddSlice(const EntityList& entityList, const bool isAsynchronous,
  33. AZ::Data::Asset<AZ::SliceAsset>& sliceAsset);
  34. void HandleEntitiesAdded(const AzFramework::EntityList& entityList);
  35. void HandleEntitiesRemoved(const AzFramework::EntityIdList& entityIds);
  36. bool ValidateEntities(const AzFramework::EntityList&);
  37. void AddSliceComponentToAsset(AZ::Data::Asset<AZ::SliceAsset>& sliceAsset, const EntityList& entityList);
  38. AZStd::unique_ptr<AzFramework::Application> m_app;
  39. bool m_entitiesAddedCallbackTriggered = false;
  40. bool m_entityRemovedCallbackTriggered = false;
  41. bool m_validateEntitiesCallbackTriggered = false;
  42. bool m_areEntitiesValidForContext = true;
  43. class EntityOwnershipServiceApplication : public AzToolsFramework::ToolsApplication
  44. {
  45. public:
  46. AZ::ComponentTypeList GetRequiredSystemComponents() const override;
  47. };
  48. };
  49. }