/* * 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" #include "LmbrCentralReflectionTest.h" #include "Shape/EditorCompoundShapeComponent.h" namespace LmbrCentral { // Serialized legacy EditorCompoundShapeComponent v1. const char kEditorCompoundComponentVersion1[] = R"DELIMITER( )DELIMITER"; class LoadEditorCompoundShapeComponentFromVersion1 : public LoadEditorComponentTest { protected: const char* GetSourceDataBuffer() const override { return kEditorCompoundComponentVersion1; } }; TEST_F(LoadEditorCompoundShapeComponentFromVersion1, Application_IsRunning) { ASSERT_NE(GetApplication(), nullptr); } TEST_F(LoadEditorCompoundShapeComponentFromVersion1, Components_Load) { EXPECT_NE(m_object.get(), nullptr); } TEST_F(LoadEditorCompoundShapeComponentFromVersion1, EditorComponent_Found) { EXPECT_EQ(m_entity->GetComponents().size(), 2); EXPECT_NE(m_entity->FindComponent(m_object->GetId()), nullptr); } TEST_F(LoadEditorCompoundShapeComponentFromVersion1, HasChildId_Succeeds) { const AZ::u64 potentialIds[] = { 9,0,2,1,0 }; for (const AZ::u64 id : potentialIds) { bool hasReference = false; LmbrCentral::CompoundShapeComponentHierarchyRequestsBus::EventResult(hasReference, m_entity->GetId(), &LmbrCentral::CompoundShapeComponentHierarchyRequestsBus::Events::HasChildId, AZ::EntityId(id)); EXPECT_TRUE(hasReference); } } TEST_F(LoadEditorCompoundShapeComponentFromVersion1, HasChildId_Fails) { const AZ::u64 potentialIds[] = { 8,6,7,5,3 }; for (const AZ::u64 id : potentialIds) { bool hasReference = false; LmbrCentral::CompoundShapeComponentHierarchyRequestsBus::EventResult(hasReference, m_entity->GetId(), &LmbrCentral::CompoundShapeComponentHierarchyRequestsBus::Events::HasChildId, AZ::EntityId(id)); EXPECT_FALSE(hasReference); } } TEST_F(LoadEditorCompoundShapeComponentFromVersion1, ValidateChildIds_Succeeds) { bool valid = false; LmbrCentral::CompoundShapeComponentHierarchyRequestsBus::EventResult(valid, m_entity->GetId(), &LmbrCentral::CompoundShapeComponentHierarchyRequestsBus::Events::ValidateChildIds); EXPECT_TRUE(valid); } }