{lyn7065} adding ProcPrefab Prefab::Tempate flag method (#4765)
* {lyn7065} adding ProcPrefab Prefab::Tempate flag method
Signed-off-by: jackalbe <23512001+jackalbe@users.noreply.github.com>
* updated based on comments
Signed-off-by: jackalbe <23512001+jackalbe@users.noreply.github.com>
* moved validation logic to IsValid()
Signed-off-by: jackalbe <23512001+jackalbe@users.noreply.github.com>
* added more guards around the source string
Signed-off-by: jackalbe <23512001+jackalbe@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <Prefab/PrefabTestFixture.h>
|
||||
#include <Prefab/Procedural/ProceduralPrefabAsset.h>
|
||||
#include <AzCore/Serialization/Json/RegistrationContext.h>
|
||||
#include <AzToolsFramework/Prefab/Template/Template.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
@@ -132,4 +133,32 @@ namespace UnitTest
|
||||
EXPECT_TRUE(outputValue.HasMember("member"));
|
||||
EXPECT_STREQ(outputValue.FindMember("member")->value.GetString(), "value");
|
||||
}
|
||||
|
||||
TEST_F(ProceduralPrefabAssetTest, Template_IsProcPrefab_DefaultsToNotProcPrefab)
|
||||
{
|
||||
AzToolsFramework::Prefab::PrefabDom dom;
|
||||
dom.SetObject();
|
||||
dom.AddMember("Source", "foo.prefab", dom.GetAllocator());
|
||||
AzToolsFramework::Prefab::Template fooTemplate("foo", AZStd::move(dom));
|
||||
EXPECT_FALSE(fooTemplate.IsProcedural());
|
||||
}
|
||||
|
||||
TEST_F(ProceduralPrefabAssetTest, Template_IsProcPrefab_DomDrivesFlagToTrue)
|
||||
{
|
||||
AzToolsFramework::Prefab::PrefabDom dom;
|
||||
dom.SetObject();
|
||||
dom.AddMember("Source", "foo.procprefab", dom.GetAllocator());
|
||||
AzToolsFramework::Prefab::Template fooTemplate("foo", AZStd::move(dom));
|
||||
EXPECT_TRUE(fooTemplate.IsProcedural());
|
||||
// the second time should use the cached version of the flag
|
||||
EXPECT_TRUE(fooTemplate.IsProcedural());
|
||||
}
|
||||
|
||||
TEST_F(ProceduralPrefabAssetTest, Template_IsProcPrefab_FailsWithNoSource)
|
||||
{
|
||||
AzToolsFramework::Prefab::PrefabDom dom;
|
||||
dom.SetObject();
|
||||
AzToolsFramework::Prefab::Template fooTemplate("foo", AZStd::move(dom));
|
||||
EXPECT_FALSE(fooTemplate.IsProcedural());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user