Files
o3de/Gems/EMotionFX/Code/Tests/SelectionListTests.cpp
T
2021-06-23 10:55:22 -07:00

44 lines
1.4 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <EMotionFX/Source/Actor.h>
#include <EMotionFX/Source/Node.h>
#include <EMotionFX/CommandSystem/Source/SelectionList.h>
#include <Tests/SystemComponentFixture.h>
namespace EMotionFX
{
TEST_F(SystemComponentFixture, SelectionListDanglingActorTest)
{
CommandSystem::SelectionList selectionList;
Actor* actor = aznew Actor("TestActor");
selectionList.AddActor(actor);
EXPECT_EQ(selectionList.GetNumSelectedActors(), 1) << "Actor should be in selection list.";
delete actor;
EXPECT_EQ(selectionList.GetNumSelectedActors(), 0)
<< "Actor destruction should have automatially removed the actor from the selection list.";
}
TEST_F(SystemComponentFixture, SelectionListDanglingJointTest)
{
CommandSystem::SelectionList selectionList;
Actor* actor = aznew Actor("TestActor");
Node* joint = Node::Create("TestJoint", actor->GetSkeleton());
actor->AddNode(joint);
selectionList.AddNode(joint);
EXPECT_EQ(selectionList.GetNumSelectedNodes(), 1) << "Joint should be in selection list.";
delete actor;
EXPECT_EQ(selectionList.GetNumSelectedNodes(), 0)
<< "Actor destruction should have automatially removed all corresponding joint from the selection list.";
}
} // end namespace EMotionFX