Files
o3de/Code/Editor/Lib/Tests/test_Main.cpp
T
Esteban Papp 21f9a789c1 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>
2021-11-10 08:57:39 -08:00

57 lines
1.5 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include <AzTest/AzTest.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/UnitTest/UnitTest.h>
#include <EditorEnvironment.h>
#include <QApplication>
class EditorLibTestEnvironment
: public ::UnitTest::TraceBusHook
{
public:
~EditorLibTestEnvironment() override = default;
protected:
void SetupEnvironment() override
{
::UnitTest::TraceBusHook::SetupEnvironment();
AZ::Environment::Create(nullptr);
AZ::AllocatorInstance<AZ::SystemAllocator>::Create();
AttachEditorAZEnvironment(AZ::Environment::GetInstance());
}
void TeardownEnvironment() override
{
DetachEditorAZEnvironment();
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
AZ::Environment::Destroy();
::UnitTest::TraceBusHook::TeardownEnvironment();
}
};
AZTEST_EXPORT int AZ_UNIT_TEST_HOOK_NAME(int argc, char** argv)
{
::testing::InitGoogleMock(&argc, argv);
// NOTE - this line makes this code different from AZ_UNIT_TEST_HOOK()
QApplication app(argc, argv);
// end
AZ::Test::ApplyGlobalParameters(&argc, argv);
AZ::Test::printUnusedParametersWarning(argc, argv);
AZ::Test::addTestEnvironments({new EditorLibTestEnvironment});
int result = RUN_ALL_TESTS();
return result;
}
IMPLEMENT_TEST_EXECUTABLE_MAIN()