123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include <Tests/MockGraphCanvas.h>
- namespace MockGraphCanvasServices
- {
- // MockSlotComponent
- void MockSlotComponent::Reflect(AZ::ReflectContext* context)
- {
- if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
- {
- serializeContext->Class<MockSlotComponent, AZ::Component>()
- ->Version(0)
- ;
- }
- }
- AZ::Entity* MockSlotComponent::CreateCoreSlotEntity()
- {
- AZ::Entity* entity = aznew AZ::Entity("Slot");
- return entity;
- }
- MockSlotComponent::MockSlotComponent(const GraphCanvas::SlotType& slotType)
- : m_slotType(slotType)
- {
- }
- MockSlotComponent::MockSlotComponent(const GraphCanvas::SlotType& slotType, const GraphCanvas::SlotConfiguration& configuration)
- : m_slotType(slotType)
- , m_slotConfiguration(configuration)
- {
- }
- void MockSlotComponent::Activate()
- {
- }
- void MockSlotComponent::Deactivate()
- {
- }
- // MockDataSlotComponent
- void MockDataSlotComponent::Reflect(AZ::ReflectContext* context)
- {
- if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
- {
- serializeContext->Class<MockDataSlotComponent, MockSlotComponent>()
- ->Version(0)
- ;
- }
- }
- AZ::Entity* MockDataSlotComponent::CreateDataSlot(const GraphCanvas::DataSlotConfiguration& dataSlotConfiguration)
- {
- AZ::Entity* entity = MockSlotComponent::CreateCoreSlotEntity();
- MockDataSlotComponent* dataSlot = aznew MockDataSlotComponent(dataSlotConfiguration);
- if (!entity->AddComponent(dataSlot))
- {
- delete dataSlot;
- delete entity;
- return nullptr;
- }
- return entity;
- }
- MockDataSlotComponent::MockDataSlotComponent()
- : MockSlotComponent(GraphCanvas::SlotTypes::DataSlot)
- {
- }
- MockDataSlotComponent::MockDataSlotComponent(const GraphCanvas::DataSlotConfiguration& dataSlotConfiguration)
- : MockSlotComponent(GraphCanvas::SlotTypes::DataSlot, dataSlotConfiguration)
- , m_dataSlotConfiguration(dataSlotConfiguration)
- {
- }
- void MockDataSlotComponent::Activate()
- {
- GraphCanvas::DataSlotRequestBus::Handler::BusConnect(GetEntityId());
- }
- void MockDataSlotComponent::Deactivate()
- {
- GraphCanvas::DataSlotRequestBus::Handler::BusDisconnect();
- }
- bool MockDataSlotComponent::ConvertToReference([[maybe_unused]] bool isNewSlot)
- {
- return false;
- }
- bool MockDataSlotComponent::CanConvertToReference([[maybe_unused]] bool isNewSlot) const
- {
- return false;
- }
- bool MockDataSlotComponent::IsUserSlot() const
- {
- return false;
- }
- bool MockDataSlotComponent::ConvertToValue()
- {
- return false;
- }
- bool MockDataSlotComponent::CanConvertToValue() const
- {
- return false;
- }
- GraphCanvas::DataSlotType MockDataSlotComponent::GetDataSlotType() const
- {
- return m_dataSlotConfiguration.m_dataSlotType;
- }
- GraphCanvas::DataValueType MockDataSlotComponent::GetDataValueType() const
- {
- return m_dataSlotConfiguration.m_dataValueType;
- }
- AZ::Uuid MockDataSlotComponent::GetDataTypeId() const
- {
- return m_dataSlotConfiguration.m_typeId;
- }
- void MockDataSlotComponent::SetDataTypeId(AZ::Uuid typeId)
- {
- m_dataSlotConfiguration.m_typeId = typeId;
- }
- const GraphCanvas::Styling::StyleHelper* MockDataSlotComponent::GetDataColorPalette() const
- {
- return nullptr;
- }
- size_t MockDataSlotComponent::GetContainedTypesCount() const
- {
- return m_dataSlotConfiguration.m_containerTypeIds.size();
- }
- AZ::Uuid MockDataSlotComponent::GetContainedTypeId(size_t index) const
- {
- return m_dataSlotConfiguration.m_containerTypeIds[index];
- }
- const GraphCanvas::Styling::StyleHelper* MockDataSlotComponent::GetContainedTypeColorPalette([[maybe_unused]] size_t index) const
- {
- return nullptr;
- }
- void MockDataSlotComponent::SetDataAndContainedTypeIds(AZ::Uuid typeId, const AZStd::vector<AZ::Uuid>& typeIds, GraphCanvas::DataValueType valueType)
- {
- AZ_UNUSED(typeId);
- AZ_UNUSED(typeIds);
- AZ_UNUSED(valueType);
- }
- // MockExecutionSlotComponent
- void MockExecutionSlotComponent::Reflect(AZ::ReflectContext* context)
- {
- if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
- {
- serializeContext->Class<MockExecutionSlotComponent, MockSlotComponent>()
- ->Version(0)
- ;
- }
- }
- AZ::Entity* MockExecutionSlotComponent::CreateExecutionSlot(const AZ::EntityId& nodeId, const GraphCanvas::SlotConfiguration& slotConfiguration)
- {
- AZ_UNUSED(nodeId);
- AZ::Entity* entity = MockSlotComponent::CreateCoreSlotEntity();
- MockExecutionSlotComponent* executionSlot = aznew MockExecutionSlotComponent(slotConfiguration);
- if (!entity->AddComponent(executionSlot))
- {
- delete executionSlot;
- delete entity;
- return nullptr;
- }
- return entity;
- }
- MockExecutionSlotComponent::MockExecutionSlotComponent()
- : MockSlotComponent(GraphCanvas::SlotTypes::ExecutionSlot)
- {
- }
- MockExecutionSlotComponent::MockExecutionSlotComponent(const GraphCanvas::SlotConfiguration& slotConfiguration)
- : MockSlotComponent(GraphCanvas::SlotTypes::ExecutionSlot, slotConfiguration)
- , m_executionSlotConfiguration(slotConfiguration)
- {
- }
- // MockExtenderSlotComponent
- void MockExtenderSlotComponent::Reflect(AZ::ReflectContext* context)
- {
- if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
- {
- serializeContext->Class<MockExtenderSlotComponent, MockSlotComponent>()
- ->Version(0)
- ;
- }
- }
- AZ::Entity* MockExtenderSlotComponent::CreateExtenderSlot(const AZ::EntityId& nodeId, const GraphCanvas::ExtenderSlotConfiguration& slotConfiguration)
- {
- AZ_UNUSED(nodeId);
- AZ::Entity* entity = MockSlotComponent::CreateCoreSlotEntity();
- MockExtenderSlotComponent* extenderSlot = aznew MockExtenderSlotComponent(slotConfiguration);
- if (!entity->AddComponent(extenderSlot))
- {
- delete extenderSlot;
- delete entity;
- return nullptr;
- }
- return entity;
- }
- MockExtenderSlotComponent::MockExtenderSlotComponent()
- : MockSlotComponent(GraphCanvas::SlotTypes::ExtenderSlot)
- {
- }
- MockExtenderSlotComponent::MockExtenderSlotComponent(const GraphCanvas::ExtenderSlotConfiguration& slotConfiguration)
- : MockSlotComponent(GraphCanvas::SlotTypes::ExtenderSlot, slotConfiguration)
- , m_extenderSlotConfiguration(slotConfiguration)
- {
- }
- void MockExtenderSlotComponent::Activate()
- {
- GraphCanvas::ExtenderSlotRequestBus::Handler::BusConnect(GetEntityId());
- }
- void MockExtenderSlotComponent::Deactivate()
- {
- GraphCanvas::ExtenderSlotRequestBus::Handler::BusDisconnect();
- }
- void MockExtenderSlotComponent::TriggerExtension()
- {
- }
- GraphCanvas::Endpoint MockExtenderSlotComponent::ExtendForConnectionProposal(const GraphCanvas::ConnectionId& connectionId, const GraphCanvas::Endpoint& endpoint)
- {
- AZ_UNUSED(connectionId);
- AZ_UNUSED(endpoint);
- return GraphCanvas::Endpoint();
- }
- // MockNodeComponent
- void MockNodeComponent::Reflect(AZ::ReflectContext* context)
- {
- if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
- {
- serializeContext->Class<MockNodeComponent, AZ::Component>()
- ->Version(0)
- ;
- }
- }
- AZ::Entity* MockNodeComponent::CreateCoreNodeEntity(const GraphCanvas::NodeConfiguration& config)
- {
- // Create this Node's entity.
- AZ::Entity* entity = aznew AZ::Entity();
- entity->CreateComponent<MockNodeComponent>(config);
- return entity;
- }
- MockNodeComponent::MockNodeComponent(const GraphCanvas::NodeConfiguration& config)
- : m_configuration(config)
- {
- }
- void MockNodeComponent::Activate()
- {
- GraphCanvas::NodeRequestBus::Handler::BusConnect(GetEntityId());
- }
- void MockNodeComponent::Deactivate()
- {
- GraphCanvas::NodeRequestBus::Handler::BusDisconnect();
- }
- void MockNodeComponent::SetTooltip(const AZStd::string& tooltip)
- {
- m_configuration.SetTooltip(tooltip);
- }
- const AZStd::string MockNodeComponent::GetTooltip() const
- {
- return m_configuration.GetTooltip();
- }
- void MockNodeComponent::SetShowInOutliner(bool showInOutliner)
- {
- m_configuration.SetShowInOutliner(showInOutliner);
- }
- bool MockNodeComponent::ShowInOutliner() const
- {
- return m_configuration.GetShowInOutliner();
- }
- void MockNodeComponent::AddSlot(const AZ::EntityId& slotId)
- {
- AZ_Assert(slotId.IsValid(), "Slot entity (ID: %s) is not valid!", slotId.ToString().data());
- m_slotIds.emplace_back(slotId);
- }
- void MockNodeComponent::RemoveSlot(const AZ::EntityId& slotId)
- {
- AZ_Assert(slotId.IsValid(), "Slot (ID: %s) is not valid!", slotId.ToString().data());
- auto entry = AZStd::find(m_slotIds.begin(), m_slotIds.end(), slotId);
- AZ_Assert(entry != m_slotIds.end(), "Slot (ID: %s) is unknown", slotId.ToString().data());
- if (entry != m_slotIds.end())
- {
- m_slotIds.erase(entry);
- }
- }
- AZStd::vector<AZ::EntityId> MockNodeComponent::GetSlotIds() const
- {
- return m_slotIds;
- }
- AZStd::vector<GraphCanvas::SlotId> MockNodeComponent::GetVisibleSlotIds() const
- {
- return m_slotIds;
- }
- AZStd::vector<GraphCanvas::SlotId> MockNodeComponent::FindVisibleSlotIdsByType([[maybe_unused]] const GraphCanvas::ConnectionType& connectionType, [[maybe_unused]] const GraphCanvas::SlotType& slotType) const
- {
- AZStd::vector<GraphCanvas::SlotId> empty;
- return empty;
- }
- bool MockNodeComponent::HasConnections() const
- {
- bool hasConnections = false;
- for (auto slotId : m_slotIds)
- {
- GraphCanvas::SlotRequestBus::EventResult(hasConnections, slotId, &GraphCanvas::SlotRequests::HasConnections);
- if (hasConnections)
- {
- break;
- }
- }
- return hasConnections;
- }
- AZStd::any* MockNodeComponent::GetUserData()
- {
- return &m_userData;
- }
- bool MockNodeComponent::IsWrapped() const
- {
- return false;
- }
- void MockNodeComponent::SetWrappingNode([[maybe_unused]] const AZ::EntityId& wrappingNode)
- {
- }
- AZ::EntityId MockNodeComponent::GetWrappingNode() const
- {
- return AZ::EntityId();
- }
- void MockNodeComponent::SignalBatchedConnectionManipulationBegin()
- {
- }
- void MockNodeComponent::SignalBatchedConnectionManipulationEnd()
- {
- }
- GraphCanvas::RootGraphicsItemEnabledState MockNodeComponent::UpdateEnabledState()
- {
- return GraphCanvas::RootGraphicsItemEnabledState::ES_Enabled;
- }
- bool MockNodeComponent::IsHidingUnusedSlots() const
- {
- return false;
- }
- void MockNodeComponent::ShowAllSlots()
- {
- }
- void MockNodeComponent::HideUnusedSlots()
- {
- }
- bool MockNodeComponent::HasHideableSlots() const
- {
- return false;
- }
- void MockNodeComponent::SignalConnectionMoveBegin([[maybe_unused]] const GraphCanvas::ConnectionId& connectionId)
- {
- }
-
- void MockNodeComponent::SignalNodeAboutToBeDeleted()
- {
- }
- // MockGraphCanvasSystemComponent
- void MockGraphCanvasSystemComponent::Reflect(AZ::ReflectContext* context)
- {
- if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
- {
- serializeContext->Class<MockGraphCanvasSystemComponent, AZ::Component>()
- ->Version(0)
- ;
- }
- }
- void MockGraphCanvasSystemComponent::Activate()
- {
- GraphCanvas::GraphCanvasRequestBus::Handler::BusConnect();
- }
- void MockGraphCanvasSystemComponent::Deactivate()
- {
- GraphCanvas::GraphCanvasRequestBus::Handler::BusDisconnect();
- }
- AZ::Entity* MockGraphCanvasSystemComponent::CreateBookmarkAnchor() const
- {
- return nullptr;
- }
- AZ::Entity* MockGraphCanvasSystemComponent::CreateScene() const
- {
- AZ::Entity* entity = aznew AZ::Entity("GraphCanvasScene");
- return entity;
- }
- AZ::Entity* MockGraphCanvasSystemComponent::CreateCoreNode() const
- {
- return nullptr;
- }
- AZ::Entity* MockGraphCanvasSystemComponent::CreateGeneralNode([[maybe_unused]] const char* nodeType) const
- {
- // Create this Node's entity.
- AZ::Entity* entity = MockNodeComponent::CreateCoreNodeEntity();
- return entity;
- }
- AZ::Entity* MockGraphCanvasSystemComponent::CreateCommentNode() const
- {
- return nullptr;
- }
- AZ::Entity* MockGraphCanvasSystemComponent::CreateWrapperNode([[maybe_unused]] const char* nodeType) const
- {
- return nullptr;
- }
- AZ::Entity* MockGraphCanvasSystemComponent::CreateNodeGroup() const
- {
- return nullptr;
- }
- AZ::Entity* MockGraphCanvasSystemComponent::CreateCollapsedNodeGroup([[maybe_unused]] const GraphCanvas::CollapsedNodeGroupConfiguration& groupedNodeConfiguration) const
- {
- return nullptr;
- }
- AZ::Entity* MockGraphCanvasSystemComponent::CreateSlot(const AZ::EntityId& nodeId, const GraphCanvas::SlotConfiguration& slotConfiguration) const
- {
- if (const GraphCanvas::DataSlotConfiguration* dataSlotConfiguration = azrtti_cast<const GraphCanvas::DataSlotConfiguration*>(&slotConfiguration))
- {
- return MockDataSlotComponent::CreateDataSlot((*dataSlotConfiguration));
- }
- else if (const GraphCanvas::ExecutionSlotConfiguration* executionSlotConfiguration = azrtti_cast<const GraphCanvas::ExecutionSlotConfiguration*>(&slotConfiguration))
- {
- return MockExecutionSlotComponent::CreateExecutionSlot(nodeId, (*executionSlotConfiguration));
- }
- else if (const GraphCanvas::ExtenderSlotConfiguration* extenderSlotConfiguration = azrtti_cast<const GraphCanvas::ExtenderSlotConfiguration*>(&slotConfiguration))
- {
- return MockExtenderSlotComponent::CreateExtenderSlot(nodeId, (*extenderSlotConfiguration));
- }
- else
- {
- AZ_Error("GraphCanvas", false, "Trying to create using an unknown Slot Configuration");
- }
- return nullptr;
- }
- GraphCanvas::NodePropertyDisplay* MockGraphCanvasSystemComponent::CreateBooleanNodePropertyDisplay([[maybe_unused]] GraphCanvas::BooleanDataInterface* dataInterface) const
- {
- return nullptr;
- }
- GraphCanvas::NodePropertyDisplay* MockGraphCanvasSystemComponent::CreateNumericNodePropertyDisplay([[maybe_unused]] GraphCanvas::NumericDataInterface* dataInterface) const
- {
- return nullptr;
- }
- GraphCanvas::NodePropertyDisplay* MockGraphCanvasSystemComponent::CreateComboBoxNodePropertyDisplay([[maybe_unused]] GraphCanvas::ComboBoxDataInterface* dataInterface) const
- {
- return nullptr;
- }
- GraphCanvas::NodePropertyDisplay* MockGraphCanvasSystemComponent::CreateEntityIdNodePropertyDisplay([[maybe_unused]] GraphCanvas::EntityIdDataInterface* dataInterface) const
- {
- return nullptr;
- }
- GraphCanvas::NodePropertyDisplay* MockGraphCanvasSystemComponent::CreateReadOnlyNodePropertyDisplay([[maybe_unused]] GraphCanvas::ReadOnlyDataInterface* dataInterface) const
- {
- return nullptr;
- }
- GraphCanvas::NodePropertyDisplay* MockGraphCanvasSystemComponent::CreateStringNodePropertyDisplay([[maybe_unused]] GraphCanvas::StringDataInterface* dataInterface) const
- {
- return nullptr;
- }
- GraphCanvas::NodePropertyDisplay* MockGraphCanvasSystemComponent::CreateVectorNodePropertyDisplay([[maybe_unused]] GraphCanvas::VectorDataInterface* dataInterface) const
- {
- return nullptr;
- }
- GraphCanvas::NodePropertyDisplay* MockGraphCanvasSystemComponent::CreateAssetIdNodePropertyDisplay([[maybe_unused]] GraphCanvas::AssetIdDataInterface* dataInterface) const
- {
- return nullptr;
- }
- AZ::Entity* MockGraphCanvasSystemComponent::CreatePropertySlot([[maybe_unused]] const AZ::EntityId& nodeId, [[maybe_unused]] const AZ::Crc32& propertyId, [[maybe_unused]] const GraphCanvas::SlotConfiguration& slotConfiguration) const
- {
- return nullptr;
- }
- }
|