3
0

ScriptCanvasTestingSystemComponent.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 <AzCore/Serialization/SerializeContext.h>
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include "ScriptCanvasTestingSystemComponent.h"
  11. #include "ScriptCanvasTestBus.h"
  12. #include "Framework/ScriptCanvasTestVerify.h"
  13. #include "Nodes/BehaviorContextObjectTestNode.h"
  14. #include <TestAutoGenFunctionRegistry.generated.h>
  15. #include <TestAutoGenNodeableRegistry.generated.h>
  16. REGISTER_SCRIPTCANVAS_AUTOGEN_FUNCTION(ScriptCanvasTestingEditorStatic);
  17. REGISTER_SCRIPTCANVAS_AUTOGEN_NODEABLE(ScriptCanvasTestingEditorStatic);
  18. namespace ScriptCanvasTestingNodes
  19. {
  20. void BehaviorContextObjectTest::Reflect(AZ::ReflectContext* context)
  21. {
  22. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  23. if (serializeContext)
  24. {
  25. serializeContext->Class<BehaviorContextObjectTest>()
  26. ->Version(0)
  27. ->Field("String", &BehaviorContextObjectTest::m_string)
  28. ->Field("Name", &BehaviorContextObjectTest::m_name)
  29. ;
  30. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  31. {
  32. editContext->Class<BehaviorContextObjectTest>("Behavior Context Object Test", "An Object that lives within Behavior Context exclusively for testing")
  33. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  34. ->Attribute(AZ::Edit::Attributes::Category, "Tests/Behavior Context")
  35. ->Attribute(AZ::Edit::Attributes::CategoryStyle, ".method")
  36. ->Attribute(ScriptCanvas::Attributes::Node::TitlePaletteOverride, "TestingNodeTitlePalette")
  37. ->DataElement(AZ::Edit::UIHandlers::Default, &BehaviorContextObjectTest::m_string, "String", "")
  38. ;
  39. }
  40. }
  41. if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
  42. {
  43. behaviorContext->Class<BehaviorContextObjectTest>()
  44. ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
  45. ->Attribute(AZ::Script::Attributes::Category, "Tests/Behavior Context")
  46. ->Method("SetString", &BehaviorContextObjectTest::SetString)
  47. ->Method("GetString", &BehaviorContextObjectTest::GetString)
  48. ->Property("Name", BehaviorValueProperty(&BehaviorContextObjectTest::m_name))
  49. ->Constant("Always24", BehaviorConstant(24))
  50. ;
  51. }
  52. }
  53. }
  54. namespace ScriptCanvasTesting
  55. {
  56. void ScriptCanvasTestingSystemComponent::Reflect(AZ::ReflectContext* context)
  57. {
  58. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  59. {
  60. serialize->Class<ScriptCanvasTestingSystemComponent, AZ::Component>()
  61. ->Version(0)
  62. ;
  63. if (AZ::EditContext* ec = serialize->GetEditContext())
  64. {
  65. ec->Class<ScriptCanvasTestingSystemComponent>("ScriptCanvasTesting", "")
  66. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  67. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  68. ;
  69. }
  70. }
  71. ScriptCanvasTestingNodes::BehaviorContextObjectTest::Reflect(context);
  72. ScriptCanvasTesting::Reflect(context);
  73. }
  74. void ScriptCanvasTestingSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  75. {
  76. provided.push_back(AZ_CRC("ScriptCanvasTestingService", 0xd2b424fc));
  77. }
  78. void ScriptCanvasTestingSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  79. {
  80. incompatible.push_back(AZ_CRC("ScriptCanvasTestingService", 0xd2b424fc));
  81. }
  82. void ScriptCanvasTestingSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  83. {
  84. (void)required;
  85. }
  86. void ScriptCanvasTestingSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  87. {
  88. (void)dependent;
  89. }
  90. void ScriptCanvasTestingSystemComponent::Init()
  91. {
  92. }
  93. void ScriptCanvasTestingSystemComponent::Activate()
  94. {
  95. ScriptCanvasEditor::UnitTestVerificationBus::Handler::BusConnect();
  96. }
  97. void ScriptCanvasTestingSystemComponent::Deactivate()
  98. {
  99. ScriptCanvasEditor::UnitTestVerificationBus::Handler::BusDisconnect();
  100. }
  101. ScriptCanvasEditor::UnitTestResult ScriptCanvasTestingSystemComponent::Verify(ScriptCanvasEditor::Reporter reporter)
  102. {
  103. return ScriptCanvasTests::VerifyReporterEditor(reporter);
  104. }
  105. }