/* * 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 namespace EMotionFX { TEST_F(AnimGraphUIFixture, CanUseEditMenu) { RecordProperty("test_case_id", "C1698602 "); // Find the Edit menu. QMenu* editMenu = MenuUIFixture::FindMainMenuWithName("EMFX.MainWindow.EditMenu"); ASSERT_TRUE(editMenu) << "Unable to find edit menu."; EMotionFX::AnimGraph*animGraph = CreateAnimGraph(); ASSERT_TRUE(animGraph); EMStudio::NodeGraph* nodeGraph = GetActiveNodeGraph(); ASSERT_TRUE(nodeGraph); EMotionFX::AnimGraphNode* currentNode = nodeGraph->GetModelIndex().data(EMStudio::AnimGraphModel::ROLE_NODE_POINTER).value(); ASSERT_TRUE(currentNode) << "No current AnimGraphNode found"; // Create an anim graph node, so we have something to undo. CommandSystem::CreateAnimGraphNode(/*commandGroup=*/nullptr, animGraph, azrtti_typeid(), "Reference", currentNode, 0, 0); // Check the expected node now exists. uint32 numNodes = currentNode->GetNumChildNodes(); EXPECT_EQ(1, numNodes); // Undo. QAction* undoAction = MenuUIFixture::FindMenuActionWithObjectName(editMenu, "EMFX.MainWindow.UndoAction", "EMFX.MainWindow.EditMenu"); ASSERT_TRUE(undoAction); undoAction->trigger(); const uint32 numNodesAfterUndo = currentNode->GetNumChildNodes(); ASSERT_EQ(numNodesAfterUndo, numNodes - 1); // Redo. QAction* redoAction = MenuUIFixture::FindMenuActionWithObjectName(editMenu, "EMFX.MainWindow.RedoAction", "EMFX.MainWindow.EditMenu"); ASSERT_TRUE(redoAction); redoAction->trigger(); const uint32 numNodesAfterRedo = currentNode->GetNumChildNodes(); ASSERT_EQ(numNodesAfterRedo, numNodesAfterUndo + 1); } } // namespace EMotionFX