CanSeeJoints.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
  10. #include <EMotionStudio/EMStudioSDK/Source/NodeHierarchyWidget.h>
  11. #include <Editor/Plugins/SkeletonOutliner/SkeletonOutlinerPlugin.h>
  12. #include <Editor/SkeletonModel.h>
  13. #include <Tests/TestAssetCode/ActorFactory.h>
  14. #include <Tests/TestAssetCode/SimpleActors.h>
  15. #include <Tests/UI/UIFixture.h>
  16. namespace EMotionFX
  17. {
  18. using CanSeeJointsFixture = UIFixture;
  19. TEST_F(CanSeeJointsFixture, CanSeeOpenGLAndNodesTab)
  20. {
  21. const int numJoints = 5;
  22. RecordProperty("test_case_id", "C16019759");
  23. AZStd::unique_ptr<Actor> actor = ActorFactory::CreateAndInit<PlaneActorWithJoints>(5, "JointTestsActor");
  24. ActorInstance* actorInstance = ActorInstance::Create(actor.get());
  25. // Change the Editor mode to Character
  26. EMStudio::GetMainWindow()->ApplicationModeChanged("Character");
  27. // Find the skeletonOutlinerPlugin
  28. auto skeletonOutliner = static_cast<EMotionFX::SkeletonOutlinerPlugin*>(
  29. EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SkeletonOutlinerPlugin::CLASS_ID));
  30. EXPECT_TRUE(skeletonOutliner) << "SkeletonOutlinerPlugin plugin not found!";
  31. // Select the newly created actor instance
  32. AZStd::string result;
  33. AZStd::string command = AZStd::string::format("Select -actorInstanceID %u", actorInstance->GetID());
  34. EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommand(command, result));
  35. QTreeView* treeView =
  36. skeletonOutliner->GetDockWidget()->findChild<QTreeView*>("EMFX.SkeletonOutlinerPlugin.SkeletonOutlinerTreeView");
  37. EXPECT_TRUE(treeView) << "Skeleton Outliner Hierarchy not found";
  38. // Select the node containing the mesh
  39. const QAbstractItemModel* model = treeView->model();
  40. const QModelIndex rootJointIndex = model->index(0, SkeletonModel::COLUMN_NAME);
  41. EXPECT_TRUE(rootJointIndex.isValid()) << "Character Node not found";
  42. EXPECT_TRUE(rootJointIndex.data(Qt::DisplayRole) == "Character");
  43. QModelIndex rootItem = model->index(0, SkeletonModel::COLUMN_NAME, model->index(0, 0));
  44. EXPECT_TRUE(rootItem.isValid()) << "Root node not found";
  45. EXPECT_TRUE(rootItem.data(Qt::DisplayRole) == "rootJoint");
  46. for (int i = 1; i < numJoints; ++i)
  47. {
  48. rootItem = rootItem.model()->index(0, SkeletonModel::COLUMN_NAME, rootItem);
  49. EXPECT_TRUE(rootItem.data(Qt::DisplayRole) == AZStd::string::format("joint%i", i).c_str());
  50. }
  51. actorInstance->Destroy();
  52. }
  53. } // namespace EMotionFX