/* * 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 "LmbrCentralEditor.h" #include "LmbrCentralReflectionTest.h" #include "Physics/EditorStaticPhysicsComponent.h" #include #include using namespace LmbrCentral; // Serialized legacy PhysicsComponent containing StaticPhysicsBehavior. // PhysicsComponent is wrapped by a GenericComponentWrapper because it's being used by the editor. // This should get converted to an EditorStaticPhysicsComponent. const char kWrappedLegacyPhysicsComponentWithStaticBehavior[] = R"DELIMITER( )DELIMITER"; /** * m_object points to GenericComponentWrapper. * m_editorPhysicsComponent points to component within the wrapper. */ class LoadEditorStaticPhysicsComponentFromLegacyData : public LoadReflectedObjectTest { protected: const char* GetSourceDataBuffer() const override { return kWrappedLegacyPhysicsComponentWithStaticBehavior; } void SetUp() override { LoadReflectedObjectTest::SetUp(); if (m_object) { if (m_editorPhysicsComponent = azrtti_cast(m_object->GetTemplate())) { m_editorPhysicsComponent->GetConfiguration(m_editorPhysicsConfig); } } } EditorStaticPhysicsComponent* m_editorPhysicsComponent = nullptr; EditorStaticPhysicsConfig m_editorPhysicsConfig; }; TEST_F(LoadEditorStaticPhysicsComponentFromLegacyData, Application_IsRunning) { ASSERT_NE(GetApplication(), nullptr); } TEST_F(LoadEditorStaticPhysicsComponentFromLegacyData, Components_Load) { EXPECT_NE(m_object.get(), nullptr); } TEST_F(LoadEditorStaticPhysicsComponentFromLegacyData, EditorComponentWithinWrapper_Found) { EXPECT_NE(m_editorPhysicsComponent, nullptr); } TEST_F(LoadEditorStaticPhysicsComponentFromLegacyData, EnabledInitially_MatchesSourceData) { EXPECT_EQ(m_editorPhysicsConfig.m_enabledInitially, false); } // Serialized kEditorStaticPhysicsConfigurationV1 version 1. // This version was accidentally reflected as a templated class. const char kEditorStaticPhysicsConfigurationV1[] = R"DELIMITER( )DELIMITER"; class LoadEditorStaticPhysicsConfigurationV1 : public LoadReflectedObjectTest { const char* GetSourceDataBuffer() const override { return kEditorStaticPhysicsConfigurationV1; } }; TEST_F(LoadEditorStaticPhysicsConfigurationV1, Load_Succeeds) { EXPECT_NE(m_object.get(), nullptr); } #endif // ENABLE_CRY_PHYSICS