3
0

CanAddReferenceNode.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 <gtest/gtest.h>
  9. #include <QModelIndex>
  10. #include <QPushButton>
  11. #include <QtTest>
  12. #include <Tests/UI/AnimGraphUIFixture.h>
  13. #include <EMotionFX/Source/AnimGraphReferenceNode.h>
  14. #include <EMotionFX/Source/AnimGraphManager.h>
  15. #include <EMotionFX/Source/AnimGraphObject.h>
  16. #include <EMotionFX/Source/AnimGraphObjectFactory.h>
  17. #include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
  18. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h>
  19. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendGraphViewWidget.h>
  20. #include <EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendGraphWidget.h>
  21. #include <GraphCanvas/Widgets/NodePalette/NodePaletteTreeView.h>
  22. namespace EMotionFX
  23. {
  24. TEST_F(AnimGraphUIFixture, CanAddReferenceNode)
  25. {
  26. RecordProperty("test_case_id", "C21948788");
  27. auto animGraph = CreateAnimGraph();
  28. ASSERT_TRUE(animGraph) << "Failed to create AnimGraph";
  29. auto nodeGraph = GetActiveNodeGraph();
  30. ASSERT_TRUE(nodeGraph) << "NodeGraph not found";
  31. EMotionFX::AnimGraphNode* currentNode = nodeGraph->GetModelIndex().data(EMStudio::AnimGraphModel::ROLE_NODE_POINTER).value<EMotionFX::AnimGraphNode*>();
  32. ASSERT_TRUE(currentNode) << "No current AnimGraphNode found";
  33. // Launch the node graph context menu.
  34. const AZStd::vector<EMotionFX::AnimGraphNode*> selectedAnimGraphNodes = nodeGraph->GetSelectedAnimGraphNodes();
  35. m_blendGraphWidget->OnContextMenuEvent(m_blendGraphWidget, QPoint(0, 0), QPoint(0, 0), m_animGraphPlugin, selectedAnimGraphNodes, true, false, m_animGraphPlugin->GetActionFilter());
  36. // Add the Reference node through the context menu.
  37. auto* tree = UIFixture::GetFirstChildOfType<GraphCanvas::NodePaletteTreeView>(m_blendGraphWidget);
  38. ASSERT_TRUE(tree);
  39. const QModelIndex idx = UIFixture::GetIndexFromName(tree, "Reference");
  40. ASSERT_TRUE(idx.isValid());
  41. // Selection should spawn the node
  42. tree->setCurrentIndex(idx);
  43. // Check the expected node now exists.
  44. size_t numNodesAfter = currentNode->GetNumChildNodes();
  45. EXPECT_EQ(1, numNodesAfter);
  46. AnimGraphNode* newNode = currentNode->GetChildNode(0);
  47. ASSERT_STREQ(newNode->GetName(), "Reference0");
  48. QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
  49. }
  50. } // namespace EMotionFX