/*
* Copyright (c) Contributors to the Open 3D Engine Project
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "LmbrCentral_precompiled.h"
#include "LmbrCentralReflectionTest.h"
#include "Shape/EditorPolygonPrismShapeComponent.h"
namespace LmbrCentral
{
// Serialized legacy EditorPolygonPrismShapeComponent v1.
const char kEditorPolygonPrismComponentVersion1[] =
R"DELIMITER(
)DELIMITER";
class LoadEditorPolygonPrismShapeComponentFromVersion1
: public LoadEditorComponentTest
{
protected:
const char* GetSourceDataBuffer() const override { return kEditorPolygonPrismComponentVersion1; }
};
TEST_F(LoadEditorPolygonPrismShapeComponentFromVersion1, Application_IsRunning)
{
ASSERT_NE(GetApplication(), nullptr);
}
TEST_F(LoadEditorPolygonPrismShapeComponentFromVersion1, Components_Load)
{
EXPECT_NE(m_object.get(), nullptr);
}
TEST_F(LoadEditorPolygonPrismShapeComponentFromVersion1, EditorComponent_Found)
{
EXPECT_EQ(m_entity->GetComponents().size(), 2);
EXPECT_NE(m_entity->FindComponent(m_object->GetId()), nullptr);
}
TEST_F(LoadEditorPolygonPrismShapeComponentFromVersion1, Height_MatchesSourceData)
{
AZ::ConstPolygonPrismPtr polygonPrism;
PolygonPrismShapeComponentRequestBus::EventResult(polygonPrism, m_entity->GetId(), &PolygonPrismShapeComponentRequestBus::Events::GetPolygonPrism);
EXPECT_FLOAT_EQ(polygonPrism->GetHeight(), 1.57f);
}
TEST_F(LoadEditorPolygonPrismShapeComponentFromVersion1, Vertices_MatchesSourceData)
{
AZ::ConstPolygonPrismPtr polygonPrism;
PolygonPrismShapeComponentRequestBus::EventResult(polygonPrism, m_entity->GetId(), &PolygonPrismShapeComponentRequestBus::Events::GetPolygonPrism);
AZStd::vector sourceVertices =
{
AZ::Vector2(-0.57f, -0.57f),
AZ::Vector2(0.57f, -0.57f),
AZ::Vector2(0.57f, 0.57f),
AZ::Vector2(-0.57f, 0.57f)
};
EXPECT_EQ(polygonPrism->m_vertexContainer.GetVertices(), sourceVertices);
}
}