Files
o3de/Gems/EMotionFX/Code/Tests/Integration/CanAddSimpleMotionComponent.cpp
T
2021-03-08 14:30:57 -08:00

93 lines
4.2 KiB
C++

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <AzFramework/Components/TransformComponent.h>
#include <AzToolsFramework/Component/EditorComponentAPIComponent.h>
#include <Component/EditorComponentAPIBus.h>
#include <Entity/EditorEntityActionComponent.h>
#include <Integration/Editor/Components/EditorActorComponent.h>
#include <Integration/Editor/Components/EditorAnimGraphComponent.h>
#include <Integration/Editor/Components/EditorSimpleMotionComponent.h>
#include <ToolsComponents/EditorPendingCompositionComponent.h>
#include <UI/PropertyEditor/PropertyManagerComponent.h>
#include <Tests/SystemComponentFixture.h>
namespace EMotionFX
{
using CanAddSimpleMotionComponentFixture = ComponentFixture<
AZ::MemoryComponent,
AZ::AssetManagerComponent,
AZ::JobManagerComponent,
AZ::StreamerComponent,
AZ::UserSettingsComponent,
AzToolsFramework::Components::PropertyManagerComponent,
AzToolsFramework::Components::EditorEntityActionComponent,
AzToolsFramework::Components::EditorComponentAPIComponent,
EMotionFX::Integration::SystemComponent
>;
TEST_F(CanAddSimpleMotionComponentFixture, CanAddSimpleMotionComponent)
{
RecordProperty("test_case_id", "C1559180");
m_app.RegisterComponentDescriptor(Integration::ActorComponent::CreateDescriptor());
m_app.RegisterComponentDescriptor(Integration::AnimGraphComponent::CreateDescriptor());
m_app.RegisterComponentDescriptor(Integration::SimpleMotionComponent::CreateDescriptor());
m_app.RegisterComponentDescriptor(Integration::EditorActorComponent::CreateDescriptor());
m_app.RegisterComponentDescriptor(Integration::EditorAnimGraphComponent::CreateDescriptor());
m_app.RegisterComponentDescriptor(Integration::EditorSimpleMotionComponent::CreateDescriptor());
m_app.RegisterComponentDescriptor(AzFramework::TransformComponent::CreateDescriptor());
m_app.RegisterComponentDescriptor(AzToolsFramework::Components::EditorPendingCompositionComponent::CreateDescriptor());
auto entity = AZStd::make_unique<AZ::Entity>(AZ::EntityId(83502341));
entity->CreateComponent<AzToolsFramework::Components::EditorPendingCompositionComponent>();
entity->CreateComponent<AzFramework::TransformComponent>();
entity->CreateComponent<Integration::EditorActorComponent>();
entity->CreateComponent<Integration::EditorAnimGraphComponent>();
entity->Init();
entity->Activate();
AzToolsFramework::EditorComponentAPIRequests::AddComponentsOutcome componentOutcome;
AzToolsFramework::EditorComponentAPIBus::BroadcastResult(
componentOutcome,
&AzToolsFramework::EditorComponentAPIRequests::AddComponentsOfType,
entity->GetId(),
AZ::ComponentTypeList{azrtti_typeid<Integration::EditorSimpleMotionComponent>()}
);
EXPECT_TRUE(componentOutcome.IsSuccess()) << componentOutcome.GetError().c_str();
bool hasComponent = false;
AzToolsFramework::EditorComponentAPIBus::BroadcastResult(
hasComponent,
&AzToolsFramework::EditorComponentAPIRequests::HasComponentOfType,
entity->GetId(),
azrtti_typeid<Integration::EditorSimpleMotionComponent>()
);
EXPECT_TRUE(hasComponent);
bool isActive = true;
AzToolsFramework::EditorComponentAPIBus::BroadcastResult(
isActive,
&AzToolsFramework::EditorComponentAPIRequests::IsComponentEnabled,
componentOutcome.GetValue().at(0)
);
EXPECT_FALSE(isActive);
}
} // namespace EMotionFX