EditorCylinderShapeComponentTests.cpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "LmbrCentralReflectionTest.h"
  9. #include "Shape/EditorCylinderShapeComponent.h"
  10. namespace LmbrCentral
  11. {
  12. // Serialized legacy EditorCylinderShapeComponent v1.
  13. const char kEditorCylinderComponentVersion1[] =
  14. R"DELIMITER(<ObjectStream version="1">
  15. <Class name="EditorCylinderShapeComponent" field="element" version="1" type="{D5FC4745-3C75-47D9-8C10-9F89502487DE}">
  16. <Class name="EditorComponentBase" field="BaseClass1" version="1" type="{D5346BD4-7F20-444E-B370-327ACD03D4A0}">
  17. <Class name="AZ::Component" field="BaseClass1" type="{EDFCB2CF-F75D-43BE-B26B-F35821B29247}">
  18. <Class name="AZ::u64" field="Id" value="2283148451428660584" type="{D6597933-47CD-4FC8-B911-63F3E2B0993A}"/>
  19. </Class>
  20. </Class>
  21. <Class name="CylinderShapeConfig" field="Configuration" version="1" type="{53254779-82F1-441E-9116-81E1FACFECF4}">
  22. <Class name="float" field="Height" value="1.5700000" type="{EA2C3E90-AFBE-44D4-A90D-FAAF79BAF93D}"/>
  23. <Class name="float" field="Radius" value="0.5700000" type="{EA2C3E90-AFBE-44D4-A90D-FAAF79BAF93D}"/>
  24. </Class>
  25. </Class>
  26. </ObjectStream>)DELIMITER";
  27. class LoadEditorCylinderShapeComponentFromVersion1
  28. : public LoadEditorComponentTest<EditorCylinderShapeComponent>
  29. {
  30. protected:
  31. const char* GetSourceDataBuffer() const override { return kEditorCylinderComponentVersion1; }
  32. };
  33. TEST_F(LoadEditorCylinderShapeComponentFromVersion1, Application_IsRunning)
  34. {
  35. ASSERT_NE(GetApplication(), nullptr);
  36. }
  37. TEST_F(LoadEditorCylinderShapeComponentFromVersion1, Components_Load)
  38. {
  39. EXPECT_NE(m_object.get(), nullptr);
  40. }
  41. TEST_F(LoadEditorCylinderShapeComponentFromVersion1, EditorComponent_Found)
  42. {
  43. EXPECT_EQ(m_entity->GetComponents().size(), 2);
  44. EXPECT_NE(m_entity->FindComponent(m_object->GetId()), nullptr);
  45. }
  46. TEST_F(LoadEditorCylinderShapeComponentFromVersion1, Height_MatchesSourceData)
  47. {
  48. float height = 0.0f;
  49. CylinderShapeComponentRequestsBus::EventResult(
  50. height, m_entity->GetId(), &CylinderShapeComponentRequests::GetHeight);
  51. EXPECT_FLOAT_EQ(height, 1.57f);
  52. }
  53. TEST_F(LoadEditorCylinderShapeComponentFromVersion1, Radius_MatchesSourceData)
  54. {
  55. float radius = 0.0f;
  56. CylinderShapeComponentRequestsBus::EventResult(
  57. radius, m_entity->GetId(), &CylinderShapeComponentRequests::GetRadius);
  58. EXPECT_FLOAT_EQ(radius, 0.57f);
  59. }
  60. }