TestEnvironment.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #pragma once
  9. // AZ ...
  10. #include <AzCore/Asset/AssetManagerComponent.h>
  11. #include <AzCore/Component/EntityId.h>
  12. #include <AzCore/IO/Streamer/StreamerComponent.h>
  13. #include <AzCore/Jobs/JobManagerComponent.h>
  14. #include <AzCore/std/smart_ptr/enable_shared_from_this.h>
  15. #include <AzCore/std/smart_ptr/make_shared.h>
  16. #include <AzTest/AzTest.h>
  17. // GraphModel ...
  18. #include <GraphModel/Model/DataType.h>
  19. #include <GraphModel/Model/GraphContext.h>
  20. #include <GraphModel/Model/Graph.h>
  21. #include <GraphModel/Model/Node.h>
  22. #include <GraphModel/Model/Slot.h>
  23. // Mock GraphCanvas buses ...
  24. #include <Tests/MockGraphCanvas.h>
  25. namespace AZ
  26. {
  27. class ComponentApplication;
  28. class ReflectContext;
  29. }
  30. namespace GraphModelIntegrationTest
  31. {
  32. static const GraphCanvas::EditorId NODE_GRAPH_TEST_EDITOR_ID = AZ_CRC_CE("GraphModelIntegrationTestEditor");
  33. static const char* TEST_STRING_INPUT_ID = "inputString";
  34. static const char* TEST_STRING_OUTPUT_ID = "outputString";
  35. static const char* TEST_EVENT_INPUT_ID = "inputEvent";
  36. static const char* TEST_EVENT_OUTPUT_ID = "outputEvent";
  37. enum TestDataTypeEnum : GraphModel::DataType::Enum
  38. {
  39. TestDataTypeEnum_String,
  40. TestDataTypeEnum_EntityId,
  41. TestDataTypeEnum_Count
  42. };
  43. class TestGraphContext : public GraphModel::GraphContext
  44. {
  45. public:
  46. TestGraphContext();
  47. virtual ~TestGraphContext() = default;
  48. };
  49. class TestNode
  50. : public GraphModel::Node
  51. {
  52. public:
  53. AZ_CLASS_ALLOCATOR(TestNode, AZ::SystemAllocator)
  54. AZ_RTTI(TestNode, "{C51A8CE2-229A-4807-9173-96CF730C6C2B}", Node);
  55. using TestNodePtr = AZStd::shared_ptr<TestNode>;
  56. static void Reflect(AZ::ReflectContext* context);
  57. TestNode() = default;
  58. explicit TestNode(GraphModel::GraphPtr graph, AZStd::shared_ptr<TestGraphContext> graphContext);
  59. const char* GetTitle() const override;
  60. protected:
  61. void RegisterSlots() override;
  62. AZStd::shared_ptr<TestGraphContext> m_graphContext = nullptr;
  63. };
  64. class ExtendableSlotsNode
  65. : public GraphModel::Node
  66. {
  67. public:
  68. AZ_CLASS_ALLOCATOR(ExtendableSlotsNode, AZ::SystemAllocator)
  69. AZ_RTTI(ExtendableSlotsNode, "{5670CFB9-EE42-456D-B1AE-CACC55EC0967}", Node);
  70. using ExtendableSlotsNodePtr = AZStd::shared_ptr<ExtendableSlotsNode>;
  71. static void Reflect(AZ::ReflectContext* context);
  72. ExtendableSlotsNode() = default;
  73. explicit ExtendableSlotsNode(GraphModel::GraphPtr graph, AZStd::shared_ptr<TestGraphContext> graphContext);
  74. const char* GetTitle() const override;
  75. protected:
  76. void RegisterSlots() override;
  77. AZStd::shared_ptr<TestGraphContext> m_graphContext = nullptr;
  78. };
  79. class GraphModelTestEnvironment
  80. : public AZ::Test::ITestEnvironment
  81. {
  82. protected:
  83. void SetupEnvironment() override;
  84. void TeardownEnvironment() override;
  85. AZ::ComponentApplication* m_application;
  86. AZ::Entity* m_systemEntity;
  87. };
  88. }