Integrating up through commit 90f050496

This commit is contained in:
alexpete
2021-04-07 14:03:29 -07:00
parent 8f2ed080a9
commit c2cbd430fe
2694 changed files with 285622 additions and 176874 deletions
@@ -49,26 +49,27 @@ namespace UnitTest
AZStd::unique_ptr<Instance> secondInstance =
m_prefabSystemComponent->InstantiatePrefab(newInstance->GetTemplateId());
// Activate the entities so that we can find them via the component application bus
secondInstance->InitializeEntities();
secondInstance->ActivateEntities();
AZ::Entity* secondNewEntity = nullptr;
AZ::ComponentApplicationBus::BroadcastResult(secondNewEntity,
&AZ::ComponentApplicationBus::Events::FindEntity, secondInstance->GetEntityId(newEntityAlias));
ASSERT_TRUE(secondNewEntity);
PrefabTestComponent* secondComponent = secondNewEntity->FindComponent<PrefabTestComponent>();
ASSERT_TRUE(secondComponent);
// Validate that the entity reference is preserved in the second instance
ASSERT_TRUE(secondComponent->m_entityIdProperty.IsValid());
ASSERT_EQ(secondComponent->m_entityIdProperty, secondInstance->GetEntityId(referencedEntityAlias));
bool found = false;
secondInstance->GetConstEntities([&](const AZ::Entity& entity)
{
if (entity.GetId() == secondInstance->GetEntityId(newEntityAlias))
{
PrefabTestComponent* secondComponent = entity.FindComponent<PrefabTestComponent>();
EXPECT_NE(nullptr, secondComponent);
if (secondComponent)
{
// Validate that the entity reference is preserved in the second instance
EXPECT_TRUE(secondComponent->m_entityIdProperty.IsValid());
EXPECT_EQ(secondComponent->m_entityIdProperty, secondInstance->GetEntityId(referencedEntityAlias));
}
found = true;
}
return true;
});
EXPECT_TRUE(found);
}
TEST_F(PrefabEntityAliasTests, PrefabEntityAlias_ReferenceNotInSameHierarchy_ReferenceGoesToNull)
TEST_F(PrefabEntityAliasTests, DISABLED_PrefabEntityAlias_ReferenceNotInSameHierarchy_ReferenceGoesToNull)
{
// Make a new entity with a test component
AZ::Entity* newEntity = CreateEntity("New Entity", false);
@@ -98,21 +99,19 @@ namespace UnitTest
AZStd::unique_ptr<Instance> secondInstance =
m_prefabSystemComponent->InstantiatePrefab(firstInstance->GetTemplateId());
// Activate the entities so that we can find them via the component application bus
secondInstance->InitializeEntities();
secondInstance->ActivateEntities();
AZ::Entity* secondNewEntity = nullptr;
AZ::ComponentApplicationBus::BroadcastResult(secondNewEntity,
&AZ::ComponentApplicationBus::Events::FindEntity, secondInstance->GetEntityId(newEntityAlias));
ASSERT_TRUE(secondNewEntity);
PrefabTestComponent* secondComponent = secondNewEntity->FindComponent<PrefabTestComponent>();
ASSERT_TRUE(secondComponent);
ASSERT_FALSE(secondComponent->m_entityIdProperty.IsValid());
size_t count = 0;
secondInstance->GetConstEntities([&](const AZ::Entity& entity)
{
count++;
PrefabTestComponent* secondComponent = entity.FindComponent<PrefabTestComponent>();
EXPECT_NE(nullptr, secondComponent);
if (secondComponent)
{
EXPECT_FALSE(secondComponent->m_entityIdProperty.IsValid());
}
return true;
});
EXPECT_EQ(1, count);
}
TEST_F(PrefabEntityAliasTests, PrefabEntityAlias_ReferenceEntityFoundInNestedInstance_ReferencePersists)
@@ -165,29 +164,27 @@ namespace UnitTest
ASSERT_TRUE(secondRootInstance);
// Activate the entities so that we can find them via the component application bus
secondRootInstance->InitializeNestedEntities();
secondRootInstance->ActivateNestedEntities();
// Find the new instances versions of the new and referenced entities using the aliases we saved
AZ::EntityId secondNewEntityId = secondRootInstance->GetEntityId(newEntityAlias);
InstanceOptionalReference secondNestedInstance = secondRootInstance->FindNestedInstance(nestedAlias);
ASSERT_TRUE(secondNestedInstance);
AZ::EntityId secondReferencedEntityId = secondNestedInstance->get().GetEntityId(referencedEntityAlias);
AZ::Entity* secondNewEntity = nullptr;
AZ::ComponentApplicationBus::BroadcastResult(secondNewEntity,
&AZ::ComponentApplicationBus::Events::FindEntity, secondNewEntityId);
ASSERT_TRUE(secondNewEntity);
PrefabTestComponent* secondComponent = secondNewEntity->FindComponent<PrefabTestComponent>();
ASSERT_TRUE(secondComponent);
EXPECT_TRUE(secondComponent->m_entityIdProperty.IsValid());
EXPECT_EQ(secondComponent->m_entityIdProperty, secondReferencedEntityId);
size_t count = 0;
secondRootInstance->GetConstEntities([&](const AZ::Entity& entity)
{
count++;
PrefabTestComponent* secondComponent = entity.FindComponent<PrefabTestComponent>();
EXPECT_NE(nullptr, secondComponent);
if (secondComponent)
{
EXPECT_TRUE(secondComponent->m_entityIdProperty.IsValid());
EXPECT_EQ(secondComponent->m_entityIdProperty, secondReferencedEntityId);
}
return true;
});
EXPECT_EQ(1, count);
}
TEST_F(PrefabEntityAliasTests, PrefabEntityAlias_ReferenceEntityFoundInParentInstance_ReferencePersists)
@@ -244,7 +241,8 @@ namespace UnitTest
m_instanceToTemplateInterface->GeneratePatch(patch, entityDomBeforeUpdate, entityDomAfterUpdate);
// Patch the nested prefab to reference an entity in its parent
m_instanceToTemplateInterface->PatchEntityInTemplate(patch, newEntity->GetId());
ASSERT_TRUE(m_instanceToTemplateInterface->PatchEntityInTemplate(patch, newEntity->GetId()));
m_instanceUpdateExecutorInterface->UpdateTemplateInstancesInQueue();
// Using the aliases we saved grab the updated entities so we can verify the entity reference is still preserved
InstanceOptionalReference updatedNestedInstance = rootInstance->FindNestedInstance(nestedAlias);
@@ -253,10 +251,6 @@ namespace UnitTest
AZ::EntityId updatedNewEntityId = updatedNestedInstance->get().GetEntityId(entityAlias);
AZ::Entity* updatedNewEntity = nullptr;
// Activate the entities so that we can find them via the component application bus
rootInstance->InitializeNestedEntities();
rootInstance->ActivateNestedEntities();
AZ::ComponentApplicationBus::BroadcastResult(updatedNewEntity,
&AZ::ComponentApplicationBus::Events::FindEntity, updatedNewEntityId);