Files
o3de/Gems/Maestro/Code/Tests/MaestroTest.cpp
T
amzn-sean 38a03817bb Removal and Replacement of the CryTimer (gEnv->pTimer) (#5409)
Replaced and removed the CryTimer (gEnv->pTimer). The new TimeSystem is a merger of the current time functionality found in the engine.

* Rename TimeSystemComponent.h/.cpp to TimeSystem.h/.cpp
* Adding New TimeSystem
* remove old timer cvars
* small improvements to the time system.
 - updated parts to use the time conversion functions.
 - in AdvanceTickDeltaTimes applying t_simulationTickScale is now uses doubles instead of floats.
* Replace gEnv->pTimer / ITimer usages with TimeSystem
* Updating usages of AZ::TimeMs{ 0 } and AZ::TimeUs{ 0 } to AZ::Time::ZeroTimeMs and AZ::Time::ZeroTimeUs
* red code the CryTimer
* using TimeUs instead of TimeMs is some cases + updating usages of old cvars to new

Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com>
2021-11-15 12:11:58 +00:00

74 lines
1.9 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 <AzTest/AzTest.h>
#include <AzCore/UnitTest/UnitTest.h>
#include <Mocks/ICryPakMock.h>
#include <Mocks/IConsoleMock.h>
#include <AzCore/Memory/OSAllocator.h>
#include <ISystem.h>
using ::testing::NiceMock;
class MaestroTestEnvironment
: public AZ::Test::ITestEnvironment
, public UnitTest::TraceBusRedirector
{
public:
AZ_TEST_CLASS_ALLOCATOR(MaestroTestEnvironment);
virtual ~MaestroTestEnvironment()
{}
protected:
struct MockHolder
{
AZ_TEST_CLASS_ALLOCATOR(MockHolder);
NiceMock<CryPakMock> pak;
NiceMock<ConsoleMock> console;
};
void SetupEnvironment() override
{
AZ::AllocatorInstance<AZ::SystemAllocator>::Create();
// Mocks need to be destroyed before the allocators are destroyed,
// but if they are member variables, they get destroyed *after*
// TeardownEnvironment when this Environment class is destroyed
// by the GoogleTest framework.
//
// Mocks also do not have any public destroy or release method to
// manage their lifetime, so this solution manages the lifetime
// and ordering via the heap.
m_mocks = new MockHolder();
m_stubEnv.pCryPak = &m_mocks->pak;
m_stubEnv.pConsole = &m_mocks->console;
gEnv = &m_stubEnv;
BusConnect();
}
void TeardownEnvironment() override
{
BusDisconnect();
// Destroy mocks before AZ allocators
delete m_mocks;
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
}
private:
SSystemGlobalEnvironment m_stubEnv;
MockHolder* m_mocks;
};
AZ_UNIT_TEST_HOOK(new MaestroTestEnvironment)