From 214b53de7398cdc113985b25e9c66280f501f2bf Mon Sep 17 00:00:00 2001 From: santorac <55155825+santorac@users.noreply.github.com> Date: Wed, 9 Feb 2022 16:22:44 -0800 Subject: [PATCH] Fixed a unit test. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- .../Material/MaterialTypeSourceDataTests.cpp | 44 ++++++++----------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/Gems/Atom/RPI/Code/Tests/Material/MaterialTypeSourceDataTests.cpp b/Gems/Atom/RPI/Code/Tests/Material/MaterialTypeSourceDataTests.cpp index c187660377..67b468d5bb 100644 --- a/Gems/Atom/RPI/Code/Tests/Material/MaterialTypeSourceDataTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Material/MaterialTypeSourceDataTests.cpp @@ -486,45 +486,37 @@ namespace UnitTest struct EnumeratePropertyGroupsResult { - const MaterialTypeSourceData::PropertyGroup* m_propertyGroup; - MaterialNameContext m_groupNameContext; - MaterialNameContext m_parentNameContext; + MaterialNameContext m_nameContext; - void Check(AZStd::string expectedIdContext, const MaterialTypeSourceData::PropertyGroup* expectedPropertyGroup) + void Check(AZStd::string expectedGroupId) { - Name groupFullId{m_propertyGroup->GetName()}; - m_parentNameContext.ContextualizeProperty(groupFullId); + Name imaginaryProperty{"someChildProperty"}; + m_nameContext.ContextualizeProperty(imaginaryProperty); - AZStd::string expectedPropertyId = expectedIdContext + expectedPropertyGroup->GetName(); - - EXPECT_EQ(expectedPropertyId, groupFullId.GetStringView()); - EXPECT_EQ(expectedPropertyGroup, m_propertyGroup); - - Name imaginaryPropertyName{"someChildProperty"}; - m_groupNameContext.ContextualizeProperty(imaginaryPropertyName); - EXPECT_EQ(AZStd::string(groupFullId.GetStringView()) + ".someChildProperty", imaginaryPropertyName.GetStringView()); + EXPECT_EQ(expectedGroupId + ".someChildProperty", imaginaryProperty.GetStringView()); } }; AZStd::vector enumeratePropertyGroupsResults; sourceData.EnumeratePropertyGroups([&enumeratePropertyGroupsResults]( - const MaterialTypeSourceData::PropertyGroup* propertyGroup, const MaterialNameContext& groupNameContext, const MaterialNameContext& parentNameContext) + const MaterialTypeSourceData::PropertyGroupStack& propertyGroupStack) { - enumeratePropertyGroupsResults.push_back(EnumeratePropertyGroupsResult{propertyGroup, groupNameContext, parentNameContext}); + MaterialNameContext nameContext = MaterialTypeSourceData::MakeMaterialNameContext(propertyGroupStack); + enumeratePropertyGroupsResults.push_back(EnumeratePropertyGroupsResult{nameContext}); return true; }); int resultIndex = 0; - enumeratePropertyGroupsResults[resultIndex++].Check("", layer1); - enumeratePropertyGroupsResults[resultIndex++].Check("layer1.", layer1_baseColor); - enumeratePropertyGroupsResults[resultIndex++].Check("layer1.", layer1_roughness); - enumeratePropertyGroupsResults[resultIndex++].Check("", layer2); - enumeratePropertyGroupsResults[resultIndex++].Check("layer2.", layer2_baseColor); - enumeratePropertyGroupsResults[resultIndex++].Check("layer2.", layer2_roughness); - enumeratePropertyGroupsResults[resultIndex++].Check("layer2.", layer2_clearCoat); - enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat.", layer2_clearCoat_roughness); - enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat.", layer2_clearCoat_normal); - enumeratePropertyGroupsResults[resultIndex++].Check("", blend); + enumeratePropertyGroupsResults[resultIndex++].Check("layer1"); + enumeratePropertyGroupsResults[resultIndex++].Check("layer1.baseColor"); + enumeratePropertyGroupsResults[resultIndex++].Check("layer1.roughness"); + enumeratePropertyGroupsResults[resultIndex++].Check("layer2"); + enumeratePropertyGroupsResults[resultIndex++].Check("layer2.baseColor"); + enumeratePropertyGroupsResults[resultIndex++].Check("layer2.roughness"); + enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat"); + enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat.roughness"); + enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat.normal"); + enumeratePropertyGroupsResults[resultIndex++].Check("blend"); EXPECT_EQ(resultIndex, enumeratePropertyGroupsResults.size()); // Check EnumerateProperties