HasBlendshapes.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <gmock/gmock.h>
  10. #include <AzCore/std/smart_ptr/make_shared.h>
  11. #include <AzCore/std/smart_ptr/unique_ptr.h>
  12. #include <AzCore/std/string/string.h>
  13. #include <SceneAPI/SceneCore/Containers/SceneGraph.h>
  14. #include <SceneAPI/SceneCore/Mocks/DataTypes/GraphData/MockIBlendShapeData.h>
  15. #include <SceneAPI/SceneCore/Mocks/DataTypes/GraphData/MockIMeshData.h>
  16. #include <Generation/Components/MeshOptimizer/MeshOptimizerComponent.h>
  17. #include <InitSceneAPIFixture.h>
  18. namespace AZ::SceneGenerationComponents
  19. {
  20. class HasBlendShapesFixture
  21. : public SceneProcessing::InitSceneAPIFixture
  22. {
  23. public:
  24. HasBlendShapesFixture()
  25. // NodeIndex's constructor is private. We can't initialize this value until SetUp when the allocators and
  26. // the graph are made. So just get some value in place to be filled in later.
  27. : m_meshIndex(*reinterpret_cast<SceneAPI::Containers::SceneGraph::NodeIndex*>(&m_meshIndex))
  28. {
  29. }
  30. void SetUp() override
  31. {
  32. SceneProcessing::InitSceneAPIFixture::SetUp();
  33. m_graph = AZStd::make_unique<SceneAPI::Containers::SceneGraph>();
  34. const SceneAPI::Containers::SceneGraph::NodeIndex root = GetGraph().GetRoot();
  35. m_meshIndex = GetGraph().AddChild(root, "testMesh", AZStd::make_shared<SceneAPI::DataTypes::MockIMeshData>());
  36. }
  37. SceneAPI::Containers::SceneGraph& GetGraph() { return *m_graph; }
  38. SceneAPI::Containers::SceneGraph::NodeIndex GetMeshNodeIndex() { return m_meshIndex; }
  39. private:
  40. AZStd::unique_ptr<SceneAPI::Containers::SceneGraph> m_graph;
  41. SceneAPI::Containers::SceneGraph::NodeIndex m_meshIndex;
  42. };
  43. TEST_F(HasBlendShapesFixture, DoesNotHaveBlendShapes)
  44. {
  45. EXPECT_FALSE(SceneGenerationComponents::MeshOptimizerComponent::HasAnyBlendShapeChild(GetGraph(), GetMeshNodeIndex()));
  46. }
  47. TEST_F(HasBlendShapesFixture, HasBlendShapes)
  48. {
  49. GetGraph().AddChild(GetMeshNodeIndex(), "blendShape", AZStd::make_shared<SceneAPI::DataTypes::MockIBlendShapeData>());
  50. EXPECT_TRUE(SceneGenerationComponents::MeshOptimizerComponent::HasAnyBlendShapeChild(GetGraph(), GetMeshNodeIndex()));
  51. }
  52. } // namespace AZ::SceneGenerationComponents