CanAddSimpleMotionComponent.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #include <AzCore/Component/ComponentApplicationBus.h>
  9. #include <AzCore/UserSettings/UserSettingsComponent.h>
  10. #include <AzCore/std/smart_ptr/unique_ptr.h>
  11. #include <AzFramework/Components/TransformComponent.h>
  12. #include <AzToolsFramework/Component/EditorComponentAPIComponent.h>
  13. #include <Component/EditorComponentAPIBus.h>
  14. #include <Entity/EditorEntityActionComponent.h>
  15. #include <Integration/Editor/Components/EditorActorComponent.h>
  16. #include <Integration/Editor/Components/EditorAnimGraphComponent.h>
  17. #include <Integration/Editor/Components/EditorSimpleMotionComponent.h>
  18. #include <ToolsComponents/EditorPendingCompositionComponent.h>
  19. #include <UI/PropertyEditor/PropertyManagerComponent.h>
  20. #include <Tests/SystemComponentFixture.h>
  21. namespace EMotionFX
  22. {
  23. using CanAddSimpleMotionComponentFixture = ComponentFixture<
  24. AZ::AssetManagerComponent,
  25. AZ::JobManagerComponent,
  26. AZ::StreamerComponent,
  27. AZ::UserSettingsComponent,
  28. AzToolsFramework::Components::PropertyManagerComponent,
  29. AzToolsFramework::Components::EditorEntityActionComponent,
  30. AzToolsFramework::Components::EditorComponentAPIComponent,
  31. EMotionFX::Integration::SystemComponent
  32. >;
  33. TEST_F(CanAddSimpleMotionComponentFixture, CanAddSimpleMotionComponent)
  34. {
  35. RecordProperty("test_case_id", "C1559180");
  36. m_app.RegisterComponentDescriptor(Integration::ActorComponent::CreateDescriptor());
  37. m_app.RegisterComponentDescriptor(Integration::AnimGraphComponent::CreateDescriptor());
  38. m_app.RegisterComponentDescriptor(Integration::SimpleMotionComponent::CreateDescriptor());
  39. m_app.RegisterComponentDescriptor(Integration::EditorActorComponent::CreateDescriptor());
  40. m_app.RegisterComponentDescriptor(Integration::EditorAnimGraphComponent::CreateDescriptor());
  41. m_app.RegisterComponentDescriptor(Integration::EditorSimpleMotionComponent::CreateDescriptor());
  42. m_app.RegisterComponentDescriptor(AzFramework::TransformComponent::CreateDescriptor());
  43. m_app.RegisterComponentDescriptor(AzToolsFramework::Components::EditorPendingCompositionComponent::CreateDescriptor());
  44. auto entity = AZStd::make_unique<AZ::Entity>(AZ::EntityId(83502341));
  45. entity->CreateComponent<AzToolsFramework::Components::EditorPendingCompositionComponent>();
  46. entity->CreateComponent<AzFramework::TransformComponent>();
  47. entity->CreateComponent<Integration::EditorActorComponent>();
  48. entity->CreateComponent<Integration::EditorAnimGraphComponent>();
  49. entity->Init();
  50. entity->Activate();
  51. AzToolsFramework::EditorComponentAPIRequests::AddComponentsOutcome componentOutcome;
  52. AzToolsFramework::EditorComponentAPIBus::BroadcastResult(
  53. componentOutcome,
  54. &AzToolsFramework::EditorComponentAPIRequests::AddComponentsOfType,
  55. entity->GetId(),
  56. AZ::ComponentTypeList{azrtti_typeid<Integration::EditorSimpleMotionComponent>()}
  57. );
  58. ASSERT_TRUE(componentOutcome.IsSuccess()) << componentOutcome.GetError().c_str();
  59. bool hasComponent = false;
  60. AzToolsFramework::EditorComponentAPIBus::BroadcastResult(
  61. hasComponent,
  62. &AzToolsFramework::EditorComponentAPIRequests::HasComponentOfType,
  63. entity->GetId(),
  64. azrtti_typeid<Integration::EditorSimpleMotionComponent>()
  65. );
  66. EXPECT_TRUE(hasComponent);
  67. bool isActive = true;
  68. AzToolsFramework::EditorComponentAPIBus::BroadcastResult(
  69. isActive,
  70. &AzToolsFramework::EditorComponentAPIRequests::IsComponentEnabled,
  71. componentOutcome.GetValue().at(0)
  72. );
  73. EXPECT_FALSE(isActive);
  74. }
  75. } // namespace EMotionFX