CanCreateMotionSet.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <QPushButton>
  10. #include <QWidget>
  11. #include <QAction>
  12. #include <QtTest>
  13. #include <QTreeWidget>
  14. #include <QToolBar>
  15. #include <Tests/UI/UIFixture.h>
  16. #include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h>
  17. #include <EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetsWindowPlugin.h>
  18. #include <EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetManagementWindow.h>
  19. namespace EMotionFX
  20. {
  21. TEST_F(UIFixture, CanCreateMotionSet)
  22. {
  23. /*
  24. Test Rail ID: C16735973
  25. Overview: Create a Motion Set using the Toolbar plus (+) icon
  26. Expected Result: When the button to create a Motion Set is pressed, a motion set should be created and added into the UI.
  27. */
  28. RecordProperty("test_case_id", "C16735973");
  29. // Get pointers to useful UI objects
  30. auto motionSetsWindowPlugin = static_cast<EMStudio::MotionSetsWindowPlugin*>(
  31. EMStudio::GetPluginManager()->FindActivePlugin(EMStudio::MotionSetsWindowPlugin::CLASS_ID)
  32. );
  33. ASSERT_TRUE(motionSetsWindowPlugin) << "Motion Sets Plugin could not be found";
  34. EMStudio::MotionSetManagementWindow* managerWindow = motionSetsWindowPlugin->GetManagementWindow();
  35. ASSERT_TRUE(managerWindow) << "Motion Sets Manager could not be found";
  36. QTreeWidget* treeWidget = managerWindow->findChild<QTreeWidget*>("EMFX.MotionSetManagementWindow.MotionSetsTree");
  37. ASSERT_TRUE(treeWidget) << "Motion Set Manager's Tree Widget could not be found";
  38. QAbstractItemModel* model = treeWidget->model();
  39. ASSERT_TRUE(model) << "Tree Widget's Data Model could not be found";
  40. // Validate state before creating a new motion set
  41. const size_t oldNumMotionSets = GetMotionManager().GetNumMotionSets();
  42. ASSERT_EQ(treeWidget->topLevelItemCount(), oldNumMotionSets) << "Expected exactly 0 TopLevelItems in TreeWidget";
  43. // Find and click the plus (+) icon on the toolbar (to create new motion set)
  44. // Found through the Manager Window's Toolbar's Actions
  45. QToolBar* toolBar = managerWindow->findChild<QToolBar*>("MotionSetManagementWindow.ToolBar");
  46. ASSERT_TRUE(toolBar) << "Motion Set Management ToolBar could not be found";
  47. QWidget* newMotionSetButton = GetWidgetFromToolbar(toolBar, "Add new motion set");
  48. ASSERT_TRUE(newMotionSetButton) << "Could not find new motion set button. Did the text description change?";
  49. QTest::mouseClick(newMotionSetButton, Qt::LeftButton);
  50. // Refresh the window to make sure the new MotionSet will show in the TreeWidget
  51. managerWindow->ReInit();
  52. // Validate state after clicking "add motionset" button
  53. ASSERT_EQ(GetMotionManager().GetNumMotionSets(), oldNumMotionSets + 1) << "The default and the newly created motion set should be present.";
  54. ASSERT_EQ(model->rowCount(), GetMotionManager().GetNumMotionSets());
  55. }
  56. }