You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/PhysX/Code/Tests/EditorTestUtilities.h

61 lines
2.1 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 <AzCore/UnitTest/TestTypes.h>
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
#include <AzFramework/Physics/SystemBus.h>
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
#include <System/PhysXSystem.h>
namespace AzPhysics
{
struct TriggerEvent;
}
namespace PhysXEditorTests
{
using EntityPtr = AZStd::unique_ptr<AZ::Entity>;
//! Creates a default editor entity in an inactive state.
EntityPtr CreateInactiveEditorEntity(const char* entityName);
//! Creates and activates a game entity from an editor entity.
EntityPtr CreateActiveGameEntityFromEditorEntity(AZ::Entity* editorEntity);
//! Class used for loading system components from this gem.
class PhysXEditorSystemComponentEntity
: public AZ::Entity
{
friend class PhysXEditorFixture;
};
//! Test fixture which creates a tools application, loads the PhysX runtime gem and creates a default physics world.
//! The application is created for the whole test case, rather than individually for each test, due to a known
//! problem with buses when repeatedly loading and unloading gems. A new default world is created for each test.
class PhysXEditorFixture
: public UnitTest::AllocatorsTestFixture
, public Physics::DefaultWorldBus::Handler
{
public:
void SetUp() override;
void TearDown() override;
// DefaultWorldBus
AzPhysics::SceneHandle GetDefaultSceneHandle() const override;
AzPhysics::SceneHandle m_defaultSceneHandle = AzPhysics::InvalidSceneHandle;
AzPhysics::Scene* m_defaultScene = nullptr;
// workaround for parameterized tests causing issues with this (and any derived) fixture
void ValidateInvalidEditorShapeColliderComponentParams(float radius, float height);
};
} // namespace PhysXEditorTests