/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include "LmbrCentral_precompiled.h" #if ENABLE_CRY_PHYSICS #include "LmbrCentral.h" #include "LmbrCentralReflectionTest.h" #include "Physics/StaticPhysicsComponent.h" #include using namespace LmbrCentral; // Serialized legacy PhysicsComponent containing StaticPhysicsBehavior. // This should get converted to a StaticPhysicsComponent. const char kLegacyPhysicsComponentWithStaticBehavior[] = R"DELIMITER( )DELIMITER"; class LoadStaticPhysicsComponentFromLegacyData : public LoadReflectedObjectTest { protected: void SetUp() override { LoadReflectedObjectTest::SetUp(); if (m_object) { m_object->GetConfiguration(m_staticPhysicsConfig); } } const char* GetSourceDataBuffer() const override { return kLegacyPhysicsComponentWithStaticBehavior; } AzFramework::StaticPhysicsConfig m_staticPhysicsConfig; }; TEST_F(LoadStaticPhysicsComponentFromLegacyData, Application_IsRunning) { ASSERT_NE(GetApplication(), nullptr); } TEST_F(LoadStaticPhysicsComponentFromLegacyData, Component_Loads) { EXPECT_NE(m_object.get(), nullptr); } TEST_F(LoadStaticPhysicsComponentFromLegacyData, ComponentId_MatchesSourceData) { EXPECT_EQ(m_object->GetId(), 123); } TEST_F(LoadStaticPhysicsComponentFromLegacyData, EnabledInitially_MatchesSourceData) { EXPECT_EQ(m_staticPhysicsConfig.m_enabledInitially, false); } // A legacy PhysicsComponent with no behavior should be converted to a StaticPhysicsComponent. const char kLegacyPhysicsComponentLackingBehavior[] = R"DELIMITER( )DELIMITER"; class LoadStaticPhysicsComponentFromLegacyDataLackingBehavior : public LoadReflectedObjectTest { const char* GetSourceDataBuffer() const override { return kLegacyPhysicsComponentLackingBehavior; } }; TEST_F(LoadStaticPhysicsComponentFromLegacyDataLackingBehavior, Component_Loads) { EXPECT_NE(m_object, nullptr); } TEST_F(LoadStaticPhysicsComponentFromLegacyDataLackingBehavior, ComponentId_MatchesSourceData) { EXPECT_EQ(m_object->GetId(), 951); } #endif // ENABLE_CRY_PHYSICS