[LYN-2255] Made PrefabTestFixture have the prefab system enabled so that the duplicate tests pass on Jenkins (they rely on the PrefabEditorEntityOwnershipInterface being registered).

This commit is contained in:
Chris Galvan
2021-05-20 14:28:04 -05:00
parent 8d8504aec3
commit c105894aa5
4 changed files with 36 additions and 2 deletions
@@ -705,7 +705,7 @@ namespace AzToolsFramework
if (!success)
{
return AZ::Failure(AZStd::string("DuplicateEntitiesInInstance"));
return AZ::Failure(AZStd::string("Cannot duplicate multiple entities belonging to different instances with one operation"));
}
// Make a copy of our before instance DOM where we will add our duplicated entities
@@ -138,7 +138,7 @@ namespace UnitTest
if (!GetApplication())
{
// Create & Start a new ToolsApplication if there's no existing one
m_app = AZStd::make_unique<ToolsTestApplication>("ToolsApplication");
m_app = CreateTestApplication();
m_app->Start(AzFramework::Application::Descriptor());
}
@@ -216,6 +216,12 @@ namespace UnitTest
TestEditorActions m_editorActions;
ToolsApplicationMessageHandler m_messageHandler; // used to suppress trace messages in test output
// Override this if your test fixture needs to use a custom TestApplication
virtual AZStd::unique_ptr<ToolsTestApplication> CreateTestApplication()
{
return AZStd::make_unique<ToolsTestApplication>("ToolsApplication");
}
private:
AZStd::unique_ptr<ToolsTestApplication> m_app;
};
@@ -20,6 +20,17 @@
namespace UnitTest
{
PrefabTestToolsApplication::PrefabTestToolsApplication(AZStd::string appName)
: ToolsTestApplication(AZStd::move(appName))
{
}
bool PrefabTestToolsApplication::IsPrefabSystemEnabled() const
{
// Make sure our prefab tests always run with prefabs enabled
return true;
}
void PrefabTestFixture::SetUpEditorFixtureImpl()
{
// Acquire the system entity
@@ -44,6 +55,11 @@ namespace UnitTest
GetApplication()->RegisterComponentDescriptor(PrefabTestComponent::CreateDescriptor());
}
AZStd::unique_ptr<ToolsTestApplication> PrefabTestFixture::CreateTestApplication()
{
return AZStd::make_unique<PrefabTestToolsApplication>("PrefabTestApplication");
}
AZ::Entity* PrefabTestFixture::CreateEntity(const char* entityName, const bool shouldActivate)
{
// Circumvent the EntityContext system and generate a new entity with a transformcomponent
@@ -31,6 +31,16 @@ namespace UnitTest
using namespace AzToolsFramework::Prefab;
using namespace PrefabTestUtils;
class PrefabTestToolsApplication
: public ToolsTestApplication
{
public:
PrefabTestToolsApplication(AZStd::string appName);
// Make sure our prefab tests always run with prefabs enabled
bool IsPrefabSystemEnabled() const override;
};
class PrefabTestFixture
: public ToolsApplicationFixture,
public UnitTest::TraceBusRedirector
@@ -45,6 +55,8 @@ namespace UnitTest
void SetUpEditorFixtureImpl() override;
AZStd::unique_ptr<ToolsTestApplication> CreateTestApplication() override;
AZ::Entity* CreateEntity(const char* entityName, const bool shouldActivate = true);
void CompareInstances(const Instance& instanceA, const Instance& instanceB, bool shouldCompareLinkIds = true,