Fixed a unit test.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
monroegm-disable-blank-issue-2
santorac 4 years ago
parent 0ecf41f6bc
commit 214b53de73

@ -486,45 +486,37 @@ namespace UnitTest
struct EnumeratePropertyGroupsResult struct EnumeratePropertyGroupsResult
{ {
const MaterialTypeSourceData::PropertyGroup* m_propertyGroup; MaterialNameContext m_nameContext;
MaterialNameContext m_groupNameContext;
MaterialNameContext m_parentNameContext;
void Check(AZStd::string expectedIdContext, const MaterialTypeSourceData::PropertyGroup* expectedPropertyGroup) void Check(AZStd::string expectedGroupId)
{ {
Name groupFullId{m_propertyGroup->GetName()}; Name imaginaryProperty{"someChildProperty"};
m_parentNameContext.ContextualizeProperty(groupFullId); m_nameContext.ContextualizeProperty(imaginaryProperty);
AZStd::string expectedPropertyId = expectedIdContext + expectedPropertyGroup->GetName();
EXPECT_EQ(expectedPropertyId, groupFullId.GetStringView());
EXPECT_EQ(expectedPropertyGroup, m_propertyGroup);
Name imaginaryPropertyName{"someChildProperty"}; EXPECT_EQ(expectedGroupId + ".someChildProperty", imaginaryProperty.GetStringView());
m_groupNameContext.ContextualizeProperty(imaginaryPropertyName);
EXPECT_EQ(AZStd::string(groupFullId.GetStringView()) + ".someChildProperty", imaginaryPropertyName.GetStringView());
} }
}; };
AZStd::vector<EnumeratePropertyGroupsResult> enumeratePropertyGroupsResults; AZStd::vector<EnumeratePropertyGroupsResult> enumeratePropertyGroupsResults;
sourceData.EnumeratePropertyGroups([&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; return true;
}); });
int resultIndex = 0; int resultIndex = 0;
enumeratePropertyGroupsResults[resultIndex++].Check("", layer1); enumeratePropertyGroupsResults[resultIndex++].Check("layer1");
enumeratePropertyGroupsResults[resultIndex++].Check("layer1.", layer1_baseColor); enumeratePropertyGroupsResults[resultIndex++].Check("layer1.baseColor");
enumeratePropertyGroupsResults[resultIndex++].Check("layer1.", layer1_roughness); enumeratePropertyGroupsResults[resultIndex++].Check("layer1.roughness");
enumeratePropertyGroupsResults[resultIndex++].Check("", layer2); enumeratePropertyGroupsResults[resultIndex++].Check("layer2");
enumeratePropertyGroupsResults[resultIndex++].Check("layer2.", layer2_baseColor); enumeratePropertyGroupsResults[resultIndex++].Check("layer2.baseColor");
enumeratePropertyGroupsResults[resultIndex++].Check("layer2.", layer2_roughness); enumeratePropertyGroupsResults[resultIndex++].Check("layer2.roughness");
enumeratePropertyGroupsResults[resultIndex++].Check("layer2.", layer2_clearCoat); enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat");
enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat.", layer2_clearCoat_roughness); enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat.roughness");
enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat.", layer2_clearCoat_normal); enumeratePropertyGroupsResults[resultIndex++].Check("layer2.clearCoat.normal");
enumeratePropertyGroupsResults[resultIndex++].Check("", blend); enumeratePropertyGroupsResults[resultIndex++].Check("blend");
EXPECT_EQ(resultIndex, enumeratePropertyGroupsResults.size()); EXPECT_EQ(resultIndex, enumeratePropertyGroupsResults.size());
// Check EnumerateProperties // Check EnumerateProperties

Loading…
Cancel
Save