Files
o3de/Gems/PhysX/Code/Tests/PhysXTestEnvironment.h
T
Steve Pham 38261d0800 Shorten copyright headers by splitting into 2 lines (#2213)
* Updated all copyright headers to split the longer original copyright line into 2 shorter lines

Signed-off-by: Steve Pham <spham@amazon.com>
2021-07-16 15:25:48 -07:00

78 lines
2.0 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
*
*/
#pragma once
#include <AzTest/AzTest.h>
#include <AzFramework/IO/LocalFileIO.h>
#include <AzCore/Component/ComponentApplication.h>
#include <System/PhysXSystem.h>
namespace PhysX
{
// We can't load the PhysX gem the same way we do LmbrCentral, because that would lead to the AZ::Environment
// being create twice. This is used to initialize the PhysX system component and create the descriptors for all
// the PhysX components.
class PhysXApplication
: public AZ::ComponentApplication
{
public:
PhysXApplication();
AZ::ComponentTypeList GetRequiredSystemComponents() const override;
void CreateReflectionManager() override;
void Destroy() override;
private:
PhysXSystem m_physXSystem;
};
class Environment
{
public:
virtual ~Environment() = default;
protected:
void SetupInternal();
void TeardownInternal();
// Flag to enable pvd in tests
static bool s_enablePvd;
PhysXApplication* m_application;
AZ::Entity* m_systemEntity;
AZStd::unique_ptr<AZ::ComponentDescriptor> m_transformComponentDescriptor;
AZStd::unique_ptr<AZ::IO::LocalFileIO> m_fileIo;
void LoadPhysXLibraryModules();
void UnloadPhysXLibraryModules();
using PhysXLibraryModules = AZStd::vector<AZStd::unique_ptr<AZ::DynamicModuleHandle>>;
AZStd::unique_ptr<PhysXLibraryModules> m_physXLibraryModules;
};
class TestEnvironment
: public AZ::Test::ITestEnvironment
, public Environment
{
public:
void SetupEnvironment() override
{
SetupInternal();
}
void TeardownEnvironment() override
{
TeardownInternal();
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
}
};
}