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