Merged the Editor.Camera.Tests with the Editor.Tests (#5463)

* Merged the Edtiror.Camera.Tests witht eh Editor.Tests

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Adds dependency to Camera.Editor gem which is used by the test

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Inheirts from TraceBusHook instead of adding the default env to the test

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* makes order consistent between Setup/Teardown

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* adds missing header for non-unity builds

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Removes dependency to Camera gem

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-11-10 08:57:39 -08:00
committed by GitHub
parent ab37eb138c
commit 21f9a789c1
8 changed files with 39 additions and 81 deletions
@@ -17,43 +17,33 @@
namespace UnitTest
{
class EditorCameraTestEnvironment : public AZ::Test::GemTestEnvironment
{
// AZ::Test::GemTestEnvironment overrides ...
void AddGemsAndComponents() override;
};
void EditorCameraTestEnvironment::AddGemsAndComponents()
{
AddDynamicModulePaths({ CAMERA_EDITOR_MODULE });
AddComponentDescriptors({ AzToolsFramework::Components::TransformComponent::CreateDescriptor() });
}
class EditorCameraFixture : public ::testing::Test
{
public:
AZ::ComponentApplication* m_application = nullptr;
AtomToolsFramework::ModularCameraViewportContext* m_cameraViewportContextView = nullptr;
AZStd::unique_ptr<SandboxEditor::EditorModularViewportCameraComposer> m_editorModularViewportCameraComposer;
AZStd::unique_ptr<AZ::DynamicModuleHandle> m_editorLibHandle;
AzFramework::ViewportControllerListPtr m_controllerList;
AZStd::unique_ptr<AZ::Entity> m_entity;
AZ::Entity* m_entity = nullptr;
AZ::ComponentDescriptor* m_transformComponent = nullptr;
static const AzFramework::ViewportId TestViewportId;
void SetUp() override
{
m_editorLibHandle = AZ::DynamicModuleHandle::Create("EditorLib");
[[maybe_unused]] const bool loaded = m_editorLibHandle->Load(true);
AZ_Assert(loaded, "EditorLib could not be loaded");
m_application = aznew AZ::ComponentApplication;
AZ::ComponentApplication::Descriptor appDesc;
m_entity = m_application->Create(appDesc);
m_transformComponent = AzToolsFramework::Components::TransformComponent::CreateDescriptor();
m_application->RegisterComponentDescriptor(m_transformComponent);
m_controllerList = AZStd::make_shared<AzFramework::ViewportControllerList>();
m_controllerList->RegisterViewportContext(TestViewportId);
m_entity = AZStd::make_unique<AZ::Entity>();
m_entity->Init();
m_entity->CreateComponent<AzToolsFramework::Components::TransformComponent>();
m_entity->Activate();
m_controllerList = AZStd::make_shared<AzFramework::ViewportControllerList>();
m_controllerList->RegisterViewportContext(TestViewportId);
m_editorModularViewportCameraComposer = AZStd::make_unique<SandboxEditor::EditorModularViewportCameraComposer>(TestViewportId);
auto controller = m_editorModularViewportCameraComposer->CreateModularViewportCameraController();
@@ -72,8 +62,17 @@ namespace UnitTest
{
m_editorModularViewportCameraComposer.reset();
m_cameraViewportContextView = nullptr;
m_entity.reset();
m_editorLibHandle = {};
if (m_application)
{
m_application->UnregisterComponentDescriptor(m_transformComponent);
delete m_transformComponent;
m_transformComponent = nullptr;
m_application->Destroy();
delete m_application;
m_application = nullptr;
}
}
};
@@ -211,15 +210,3 @@ namespace UnitTest
EXPECT_THAT(currentReferenceFrame, IsClose(AZ::Transform::CreateIdentity()));
}
} // namespace UnitTest
// required to support running integration tests with the Camera Gem
AZTEST_EXPORT int AZ_UNIT_TEST_HOOK_NAME(int argc, char** argv)
{
::testing::InitGoogleMock(&argc, argv);
AZ::Test::printUnusedParametersWarning(argc, argv);
AZ::Test::addTestEnvironments({ new UnitTest::EditorCameraTestEnvironment() });
int result = RUN_ALL_TESTS();
return result;
}
IMPLEMENT_TEST_EXECUTABLE_MAIN();