/* * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace EMotionFX { TEST_F(PreviewMotionFixture, PreviewMotionTests) { AnimGraph* animGraph = CreateAnimGraph(); EXPECT_NE(animGraph, nullptr) << "Cannot find newly created anim graph."; auto nodeGraph = GetActiveNodeGraph(); EXPECT_TRUE(nodeGraph) << "Node graph not found."; // Serialize motion node members, the motion id for rin_idle. EMotionFX::AnimGraphMotionNode* tempMotionNode = aznew EMotionFX::AnimGraphMotionNode(); tempMotionNode->SetMotionIds({ "rin_idle" }); AZ::Outcome serializedMotionNode = MCore::ReflectionSerializer::SerializeMembersExcept(tempMotionNode, {}); EMotionFX::AnimGraphNode* currentNode = nodeGraph->GetModelIndex().data(EMStudio::AnimGraphModel::ROLE_NODE_POINTER).value(); ASSERT_TRUE(currentNode) << "No current AnimGraphNode found"; CommandSystem::CreateAnimGraphNode(/*commandGroup=*/nullptr, currentNode->GetAnimGraph(), azrtti_typeid(), "Motion", currentNode, 0, 0, serializedMotionNode.GetValue()); // Check motion node has been created. AnimGraphMotionNode* motionNode = static_cast(animGraph->GetNode(1)); EXPECT_NE(motionNode, nullptr) << "Cannot find newly created motion node."; nodeGraph->SelectAllNodes(); const AZStd::vector selectedAnimGraphNodes = nodeGraph->GetSelectedAnimGraphNodes(); m_blendGraphWidget->OnContextMenuEvent(m_blendGraphWidget, QPoint(0, 0), QPoint(0, 0), m_animGraphPlugin, selectedAnimGraphNodes, true, false, m_animGraphPlugin->GetActionFilter()); // Check that Preview Motion action is available in the context menu. QMenu* selectedNodeContextMenu = m_blendGraphWidget->findChild("BlendGraphWidget.SelectedNodeMenu"); ASSERT_TRUE(selectedNodeContextMenu) << "Selected node context menu was not found."; QAction* previewMotionAction = GetNamedAction(selectedNodeContextMenu, QString("Preview rin_idle")); ASSERT_TRUE(previewMotionAction) << "Preview motion action not found."; delete tempMotionNode; } } // end namespace EMotionFX