Integrating latest 47acbe8

This commit is contained in:
alexpete
2021-03-25 13:57:57 -07:00
parent 448c549698
commit 75dc720198
10312 changed files with 2711566 additions and 671451 deletions
+14 -3
View File
@@ -18,10 +18,13 @@ ly_add_target(
NAMESPACE Gem
FILES_CMAKE
scriptcanvastestingeditor_files.cmake
scriptcanvastesting_autogen_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
.
Source
.
PUBLIC
Include
COMPILE_DEFINITIONS
PRIVATE
SCRIPTCANVAS_EDITOR
@@ -38,6 +41,11 @@ ly_add_target(
AZ::AzFramework
AZ::AzToolsFramework
AZ::AssetBuilderSDK
AUTOGEN_RULES
*.ScriptCanvasNode.xml,ScriptCanvasNode_Header.jinja,$path/$fileprefix.generated.h
*.ScriptCanvasNode.xml,ScriptCanvasNode_Source.jinja,$path/$fileprefix.generated.cpp
*.ScriptCanvasNodeable.xml,ScriptCanvasNodeable_Header.jinja,$path/$fileprefix.generated.h
*.ScriptCanvasNodeable.xml,ScriptCanvasNodeable_Source.jinja,$path/$fileprefix.generated.cpp
)
ly_add_target(
@@ -68,10 +76,12 @@ ly_add_target(
################################################################################
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
ly_add_target(
NAME ScriptCanvasTesting.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAME ScriptCanvasTesting.Editor.Tests MODULE
NAMESPACE Gem
FILES_CMAKE
scriptcanvastestingeditor_tests_files.cmake
PLATFORM_INCLUDE_FILES
Platform/Common/${PAL_TRAIT_COMPILER_ID}/scriptcanvastesting_editor_tests_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake
INCLUDE_DIRECTORIES
PRIVATE
.
@@ -91,10 +101,11 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
Gem::ScriptCanvasTesting.Editor.Static
RUNTIME_DEPENDENCIES
Gem::GraphCanvas.Editor
Gem::ScriptCanvasGem.Editor
Gem::ScriptCanvas.Editor
)
ly_add_googletest(
NAME Gem::ScriptCanvasTesting.Editor.Tests
TEST_SUITE smoke
)
endif()
@@ -0,0 +1,10 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
@@ -0,0 +1,32 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
ly_add_source_properties(
SOURCES
Source/Framework/ScriptCanvasTestUtilities.cpp
Tests/ScriptCanvas_Async.cpp
Tests/ScriptCanvas_BehaviorContext.cpp
Tests/ScriptCanvas_ContainerSupport.cpp
Tests/ScriptCanvas_Core.cpp
Tests/ScriptCanvas_EventHandlers.cpp
Tests/ScriptCanvas_Math.cpp
Tests/ScriptCanvas_MethodOverload.cpp
Tests/ScriptCanvas_NodeGenerics.cpp
Tests/ScriptCanvas_Regressions.cpp
Tests/ScriptCanvas_RuntimeInterpreted.cpp
Tests/ScriptCanvas_Slots.cpp
Tests/ScriptCanvas_StringNodes.cpp
Tests/ScriptCanvas_UnitTesting.cpp
Tests/ScriptCanvas_Variables.cpp
Tests/ScriptCanvas_VM.cpp
PROPERTY COMPILE_OPTIONS
VALUES -bigobj
)
@@ -12,29 +12,32 @@
#pragma once
#include "ScriptCanvasTestApplication.h"
#include "ScriptCanvasTestNodes.h"
#include "EntityRefTests.h"
#include "ScriptCanvasTestUtilities.h"
#include <AzCore/Asset/AssetManagerComponent.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Driller/Driller.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/Memory/MemoryComponent.h>
#include <AzCore/Memory/MemoryDriller.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/std/containers/vector.h>
#include <AzFramework/IO/LocalFileIO.h>
#include <AzTest/AzTest.h>
#include <ScriptCanvas/Core/Graph.h>
#include <ScriptCanvas/Core/SlotConfigurationDefaults.h>
#include <AzTest/AzTest.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Driller/Driller.h>
#include <AzCore/Memory/MemoryDriller.h>
#include <ScriptCanvas/ScriptCanvasGem.h>
#include <AzCore/Memory/MemoryComponent.h>
#include <AzCore/Asset/AssetManagerComponent.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <ScriptCanvas/SystemComponent.h>
#include <AzFramework/IO/LocalFileIO.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include "EntityRefTests.h"
#include "ScriptCanvasTestApplication.h"
#include "ScriptCanvasTestBus.h"
#include "ScriptCanvasTestNodes.h"
#include "ScriptCanvasTestUtilities.h"
#include <Nodes/Nodeables/SharedDataSlotExample.h>
#include <Nodes/Nodeables/ValuePointerReferenceExample.h>
#define SC_EXPECT_DOUBLE_EQ(candidate, reference) EXPECT_NEAR(candidate, reference, 0.001)
#define SC_EXPECT_FLOAT_EQ(candidate, reference) EXPECT_NEAR(candidate, reference, 0.001f)
@@ -44,7 +47,7 @@ namespace ScriptCanvasTests
class ScriptCanvasTestFixture
: public ::testing::Test
, protected NodeAccessor
//, protected NodeAccessor
{
public:
static AZStd::atomic_bool s_asyncOperationActive;
@@ -75,6 +78,10 @@ namespace ScriptCanvasTests
descriptor.m_modules.push_back(dynamicModuleDescriptor);
dynamicModuleDescriptor.m_dynamicLibraryPath = "Gem.ScriptCanvasGem.Editor.869a0d0ec11a45c299917d45c81555e6.v0.1.0";
descriptor.m_modules.push_back(dynamicModuleDescriptor);
dynamicModuleDescriptor.m_dynamicLibraryPath = "Gem.ExpressionEvaluation.4c6f9df57ca2468f93c8d860ee6a1167.v0.1.0";
descriptor.m_modules.push_back(dynamicModuleDescriptor);
dynamicModuleDescriptor.m_dynamicLibraryPath = "Gem.ScriptEvents.32d8ba21703e4bbbb08487366e48dd69.v0.1.0";
descriptor.m_modules.push_back(dynamicModuleDescriptor);
s_application->Start(descriptor, appStartup);
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
@@ -99,6 +106,32 @@ namespace ScriptCanvasTests
s_setupSucceeded = fileIO->GetAlias("@engroot@") != nullptr;
AZ::TickBus::AllowFunctionQueuing(true);
auto m_serializeContext = s_application->GetSerializeContext();
auto m_behaviorContext = s_application->GetBehaviorContext();
ScriptCanvasTesting::GlobalBusTraits::Reflect(m_serializeContext);
ScriptCanvasTesting::GlobalBusTraits::Reflect(m_behaviorContext);
ScriptCanvasTesting::LocalBusTraits::Reflect(m_serializeContext);
ScriptCanvasTesting::LocalBusTraits::Reflect(m_behaviorContext);
ScriptCanvasTesting::NativeHandlingOnlyBusTraits::Reflect(m_serializeContext);
ScriptCanvasTesting::NativeHandlingOnlyBusTraits::Reflect(m_behaviorContext);
ScriptCanvasTesting::TestTupleMethods::Reflect(m_behaviorContext);
::Nodes::InputMethodSharedDataSlotExampleNode::Reflect(m_serializeContext);
::Nodes::InputMethodSharedDataSlotExampleNode::Reflect(m_behaviorContext);
::Nodes::BranchMethodSharedDataSlotExampleNode::Reflect(m_serializeContext);
::Nodes::BranchMethodSharedDataSlotExampleNode::Reflect(m_behaviorContext);
::Nodes::ReturnTypeExampleNode::Reflect(m_serializeContext);
::Nodes::ReturnTypeExampleNode::Reflect(m_behaviorContext);
::Nodes::InputTypeExampleNode::Reflect(m_serializeContext);
::Nodes::InputTypeExampleNode::Reflect(m_behaviorContext);
::Nodes::BranchInputTypeExampleNode::Reflect(m_serializeContext);
::Nodes::BranchInputTypeExampleNode::Reflect(m_behaviorContext);
TestNodeableObject::Reflect(m_serializeContext);
TestNodeableObject::Reflect(m_behaviorContext);
ScriptUnitTestEventHandler::Reflect(m_serializeContext);
ScriptUnitTestEventHandler::Reflect(m_behaviorContext);
}
static void TearDownTestCase()
@@ -117,7 +150,7 @@ namespace ScriptCanvasTests
delete s_application;
s_application = nullptr;
}
s_allocatorSetup.TeardownAllocator();
}
@@ -148,33 +181,21 @@ namespace ScriptCanvasTests
m_stringToNumberMapType = ScriptCanvas::Data::Type::BehaviorContextObject(azrtti_typeid<AZStd::unordered_map<ScriptCanvas::Data::StringType, ScriptCanvas::Data::NumberType>>());
m_dataSlotConfigurationType = ScriptCanvas::Data::Type::BehaviorContextObject(azrtti_typeid<ScriptCanvas::DataSlotConfiguration>());
ScriptUnitTestEventHandler::Reflect(m_serializeContext);
ScriptUnitTestEventHandler::Reflect(m_behaviorContext);
}
void TearDown() override
{
delete m_graph;
m_graph = nullptr;
ASSERT_TRUE(s_setupSucceeded) << "ScriptCanvasTestFixture set up failed, unit tests can't work properly";
m_serializeContext->EnableRemoveReflection();
m_behaviorContext->EnableRemoveReflection();
ScriptUnitTestEventHandler::Reflect(m_serializeContext);
ScriptUnitTestEventHandler::Reflect(m_behaviorContext);
m_serializeContext->DisableRemoveReflection();
m_behaviorContext->DisableRemoveReflection();
for (AZ::ComponentDescriptor* componentDescriptor : m_descriptors)
{
GetApplication()->UnregisterComponentDescriptor(componentDescriptor);
}
m_descriptors.clear();
delete m_graph;
m_graph = nullptr;
m_descriptors.clear();
}
ScriptCanvas::Graph* CreateGraph()
@@ -207,13 +228,9 @@ namespace ScriptCanvasTests
void ReportErrors(ScriptCanvas::Graph* graph, bool expectErrors = false, bool expectIrrecoverableErrors = false)
{
EXPECT_EQ(graph->IsInErrorState(), expectErrors);
EXPECT_EQ(graph->IsInIrrecoverableErrorState(), expectIrrecoverableErrors);
if (graph->IsInErrorState())
{
AZ_TracePrintf("UnitTest", "%s\n", AZStd::string(graph->GetLastErrorDescription()).c_str());
}
AZ_UNUSED(graph);
AZ_UNUSED(expectErrors);
AZ_UNUSED(expectIrrecoverableErrors);
}
void TestConnectionBetween(ScriptCanvas::Endpoint sourceEndpoint, ScriptCanvas::Endpoint targetEndpoint, bool isValid = true)
@@ -12,9 +12,12 @@
#include "ScriptCanvasTestNodes.h"
#include <ScriptCanvas/Core/Core.h>
#include <ScriptCanvas/Core/Graph.h>
#include <ScriptCanvas/Core/SlotConfigurationDefaults.h>
#include <ScriptCanvas/Grammar/GrammarContext.h>
#include <ScriptCanvas/Grammar/GrammarContextBus.h>
#include <gtest/gtest.h>
@@ -201,14 +204,10 @@ namespace TestNodes
return addedSlotId;
}
bool AddNodeWithRemoveSlot::RemoveSlot(const ScriptCanvas::SlotId& slotId)
bool AddNodeWithRemoveSlot::RemoveSlot(const ScriptCanvas::SlotId& slotId, bool emitWarning /*= true*/)
{
auto dynamicSlotIt = AZStd::find(m_dynamicSlotIds.begin(), m_dynamicSlotIds.end(), slotId);
if (dynamicSlotIt != m_dynamicSlotIds.end())
{
m_dynamicSlotIds.erase(dynamicSlotIt);
}
return Node::RemoveSlot(slotId);
AZStd::erase_if(m_dynamicSlotIds, [slotId](const ScriptCanvas::SlotId& sId) { return (sId == slotId); });
return Node::RemoveSlot(slotId, true, emitWarning);
}
void AddNodeWithRemoveSlot::OnInputSignal(const ScriptCanvas::SlotId& slotId)
@@ -396,7 +395,7 @@ namespace TestNodes
Node::AddSlot(ScriptCanvas::CommonSlots::GeneralOutSlot());
Node::AddSlot(ScriptCanvas::DataSlotConfiguration(ScriptCanvas::Data::Type::String(), "Result", ScriptCanvas::ConnectionType::Output));
}
/////////////////////////////
// ConfigurableUnitTestNode
/////////////////////////////
@@ -442,11 +441,12 @@ namespace TestNodes
bool ConfigurableUnitTestNode::TestHasConcreteDisplayType(const AZ::Crc32& dynamicGroup) const
{
return HasConcreteDisplayType(dynamicGroup);
return FindConcreteDisplayType(dynamicGroup).IsValid();
}
bool ConfigurableUnitTestNode::TestIsSlotConnectedToConcreteDisplayType(const ScriptCanvas::Slot& slot, ExploredDynamicGroupCache& exploredGroupCache) const
{
return IsSlotConnectedToConcreteDisplayType(slot, exploredGroupCache);
return FindConnectedConcreteDisplayType(slot, exploredGroupCache).IsValid();
}
}
@@ -103,7 +103,7 @@ namespace TestNodes
static void Reflect(AZ::ReflectContext* reflection);
ScriptCanvas::SlotId AddSlot(AZStd::string_view slotName);
bool RemoveSlot(const ScriptCanvas::SlotId& slotId);
bool RemoveSlot(const ScriptCanvas::SlotId& slotId, bool emitWarning = true);
protected:
void OnInputSignal(const ScriptCanvas::SlotId& slotId) override;
@@ -150,7 +150,7 @@ namespace TestNodes
void OnInit() override;
};
//////////////////////////////////////////////////////////////////////////////
class ConfigurableUnitTestNode
: public ScriptCanvas::Node
@@ -172,4 +172,6 @@ namespace TestNodes
protected:
};
}
@@ -10,16 +10,19 @@
*
*/
#include <Editor/Framework/ScriptCanvasTraceUtilities.h>
#include <Framework/ScriptCanvasTestUtilities.h>
#include <Framework/ScriptCanvasTestNodes.h>
#include <Editor/Framework/ScriptCanvasGraphUtilities.h>
#include <ScriptCanvas/Assets/ScriptCanvasAssetHandler.h>
#include <Asset/EditorAssetSystemComponent.h>
#include <AzCore/Asset/AssetManagerBus.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/IOUtils.h>
#include <AzCore/IO/FileIOEventBus.h>
#include <AzCore/UnitTest/UnitTest.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <Editor/Framework/ScriptCanvasGraphUtilities.h>
#include <Editor/Framework/ScriptCanvasTraceUtilities.h>
#include <Framework/ScriptCanvasTestNodes.h>
#include <Framework/ScriptCanvasTestUtilities.h>
#include <ScriptCanvas/Asset/RuntimeAsset.h>
#include <ScriptCanvas/Asset/RuntimeAssetHandler.h>
#include <ScriptCanvas/Execution/RuntimeComponent.h>
@@ -27,14 +30,15 @@
namespace ScriptCanvasTestUtilitiesCPP
{
const char* k_defaultExtension = "scriptcanvas";
const char* k_scriptEventExtension = "scriptevents";
const char* k_unitTestDirPathRelative = "@engroot@/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests";
} // namespace ScriptCanvasTestUtilitiesCPP
}
namespace ScriptCanvasTests
{
using namespace ScriptCanvas;
#define SC_CORE_UNIT_TEST_DIR "@exefolder@/LY_SC_UnitTest_ScriptCanvas_CoreCPP_Temporary"
#define SC_CORE_UNIT_TEST_DIR "@engroot@/LY_SC_UnitTest_ScriptCanvas_CoreCPP_Temporary"
#define SC_CORE_UNIT_TEST_NAME "serializationTest.scriptcanvas_compiled"
const char* k_tempCoreAssetDir = SC_CORE_UNIT_TEST_DIR;
const char* k_tempCoreAssetName = SC_CORE_UNIT_TEST_NAME;
@@ -42,6 +46,47 @@ namespace ScriptCanvasTests
#undef SC_CORE_UNIT_TEST_DIR
#undef SC_CORE_UNIT_TEST_NAME
void ExpectParse(AZStd::string_view graphPath)
{
ExpectParse(graphPath, ScriptCanvasTestUtilitiesCPP::k_defaultExtension);
}
void ExpectParse(AZStd::string_view graphPath, AZStd::string_view extension)
{
AZ_TEST_START_TRACE_SUPPRESSION;
const AZStd::string filePath = AZStd::string::format("%s/%s.%s", ScriptCanvasTestUtilitiesCPP::k_unitTestDirPathRelative, graphPath.data(), extension.data());
ScriptCanvasEditor::RunGraphSpec runGraphSpec;
runGraphSpec.graphPath = filePath;
runGraphSpec.dirPath = ScriptCanvasTestUtilitiesCPP::k_unitTestDirPathRelative;
runGraphSpec.runSpec.processOnly = true;
runGraphSpec.runSpec.execution = ExecutionMode::Interpreted;
auto reporters = ScriptCanvasEditor::RunGraph(runGraphSpec);
ScriptCanvasTests::VerifyReporter(reporters.front());
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
}
void ExpectParseError(AZStd::string_view graphPath)
{
ExpectParseError(graphPath, ScriptCanvasTestUtilitiesCPP::k_defaultExtension);
}
void ExpectParseError(AZStd::string_view graphPath, AZStd::string_view extension)
{
AZ_TEST_START_TRACE_SUPPRESSION;
const AZStd::string filePath = AZStd::string::format("%s/%s.%s", ScriptCanvasTestUtilitiesCPP::k_unitTestDirPathRelative, graphPath.data(), extension.data());
ScriptCanvasEditor::RunGraphSpec runGraphSpec;
runGraphSpec.runSpec.processOnly = true;
runGraphSpec.graphPath = filePath;
runGraphSpec.dirPath = ScriptCanvasTestUtilitiesCPP::k_unitTestDirPathRelative;
runGraphSpec.runSpec.execution = ExecutionMode::Interpreted;
auto reporters = ScriptCanvasEditor::RunGraph(runGraphSpec);
reporters.front().MarkExpectParseError();
ScriptCanvasTests::VerifyReporter(reporters.front());
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
}
AZStd::string_view GetGraphNameFromPath(AZStd::string_view graphPath)
{
graphPath.remove_prefix(AZStd::min(graphPath.find_last_of("\\/") + 1, graphPath.size()));
@@ -50,50 +95,83 @@ namespace ScriptCanvasTests
void VerifyReporter(const ScriptCanvasEditor::Reporter& reporter)
{
if (!reporter.GetScriptCanvasId().IsValid())
if (!reporter.IsGraphLoaded())
{
ADD_FAILURE() << "Graph is not valid";
ADD_FAILURE() << "Graph was not successfully loaded.";
}
else if (reporter.ExpectsParseError())
{
if (!reporter.IsParseAttemptMade())
{
ADD_FAILURE() << "Expected a parse error but the graph never attempted to be parsed";
}
else if (reporter.IsCompiled())
{
ADD_FAILURE() << "Expected a parse error but graph compiled successfully";
}
}
else if (!reporter.IsCompiled())
{
ADD_FAILURE() << "Graph failed to compile";
}
else if (!reporter.GetScriptCanvasId().IsValid())
{
ADD_FAILURE() << "Graph is not valid, wasn't assigned properly to an entity";
}
else if (reporter.IsReportFinished())
{
bool reportCheckpoints = false;
const auto& successes = reporter.GetSuccess();
for (const auto& success : successes)
if (!reporter.IsProcessOnly())
{
SUCCEED() << success.data();
const auto& successes = reporter.GetSuccess();
for (const auto& success : successes)
{
SUCCEED() << success.c_str();
}
if (!reporter.IsActivated())
{
ADD_FAILURE() << "Graph did not activate";
}
if (!reporter.IsDeactivated())
{
ADD_FAILURE() << "Graph did not deactivate";
reportCheckpoints = true;
}
if (!reporter.ExpectsRuntimeFailure())
{
if (!reporter.IsComplete())
{
ADD_FAILURE() << "Graph was not marked complete";
reportCheckpoints = true;
}
if (!reporter.IsErrorFree())
{
ADD_FAILURE() << "Graph execution had errors";
reportCheckpoints = true;
const auto& failures = reporter.GetFailure();
for (const auto& failure : failures)
{
ADD_FAILURE() << failure.c_str();
}
}
}
else
{
if (reporter.IsErrorFree())
{
ADD_FAILURE() << "Graph expected error, but didn't report any";
reportCheckpoints = true;
}
}
}
if (!reporter.IsActivated())
{
ADD_FAILURE() << "Graph did not activate";
}
if (!reporter.IsDeactivated())
{
ADD_FAILURE() << "Graph did not deactivate";
reportCheckpoints = true;
}
if (!reporter.IsErrorFree())
{
ADD_FAILURE() << "Graph had errors";
reportCheckpoints = true;
}
const auto& failures = reporter.GetFailure();
for (const auto& failure : failures)
{
ADD_FAILURE() << failure.data();
}
if (!reporter.IsComplete())
{
ADD_FAILURE() << "Graph was not marked complete";
reportCheckpoints = true;
}
if (reportCheckpoints)
if (reportCheckpoints && !reporter.IsProcessOnly())
{
const auto& checkpoints = reporter.GetCheckpoints();
if (checkpoints.empty())
@@ -107,12 +185,60 @@ namespace ScriptCanvasTests
for (const auto& checkpoint : checkpoints)
{
checkpointPath += AZStd::string::format("%2d: %s\n", ++i, checkpoint.data()).data();
checkpointPath += AZStd::string::format("%2d: %s\n", ++i, checkpoint.c_str()).c_str();
}
ADD_FAILURE() << checkpointPath.data();
ADD_FAILURE() << checkpointPath.c_str();
}
}
else
{
const Execution::PerformanceTrackingReport& performance = reporter.GetPerformanceReport();
if (reporter.GetExecutionMode() == ExecutionMode::Interpreted)
{
std::cerr << "[INTERPRETED] ";
}
else
{
std::cerr << "[ NATIVE] ";
}
std::cerr << AZStd::string::format
(" Parse: %4.2f ms, Translate: %4.2f ms\n"
, reporter.GetParseDuration() / 1000.0
, reporter.GetTranslateDuration() / 1000.0).c_str();
double ready = aznumeric_caster(performance.timing.initializationTime);
double instant = aznumeric_caster(performance.timing.executionTime);
double latent = aznumeric_caster(performance.timing.latentTime);
double total = aznumeric_caster(performance.timing.totalTime);
std::cerr << "[ INITIALIZE] " << AZStd::string::format("%7.3f ms \n", ready / 1000.0).c_str();
std::cerr << "[ EXECUTION] " << AZStd::string::format("%7.3f ms \n", instant / 1000.0).c_str();
std::cerr << "[ LATENT] " << AZStd::string::format("%7.3f ms \n", latent / 1000.0).c_str();
std::cerr << "[ TOTAL] " << AZStd::string::format("%7.3f ms ", total / 1000.0).c_str();
switch (reporter.GetExecutionConfiguration())
{
case ScriptCanvasEditor::ExecutionConfiguration::Debug:
std::cerr << "[ DEBUG] ";
break;
case ScriptCanvasEditor::ExecutionConfiguration::Performance:
std::cerr << "[PERFORM] ";
break;
case ScriptCanvasEditor::ExecutionConfiguration::Release:
std::cerr << "[RELEASE] ";
break;
case ScriptCanvasEditor::ExecutionConfiguration::Traced:
std::cerr << "[ TRACED] ";
break;
}
std::cerr << "\n";
}
}
else
{
@@ -120,34 +246,131 @@ namespace ScriptCanvasTests
}
}
void RunUnitTestGraph(AZStd::string_view graphPath, ExecutionMode execution, const ScriptCanvasEditor::DurationSpec& duration)
void RunUnitTestGraph(AZStd::string_view graphPath)
{
const AZStd::string filePath = AZStd::string::format("%s/%s.%s", ScriptCanvasTestUtilitiesCPP::k_unitTestDirPathRelative, graphPath.data(), ScriptCanvasTestUtilitiesCPP::k_defaultExtension);
const ScriptCanvasEditor::Reporter reporter = ScriptCanvasEditor::RunGraph(filePath, execution, duration);
ScriptCanvasTests::VerifyReporter(reporter);
}
void RunUnitTestGraph(AZStd::string_view graphPath, const ScriptCanvasEditor::DurationSpec& duration)
{
ScriptCanvasTests::RunUnitTestGraph(graphPath, ExecutionMode::Interpreted, duration);
ScriptCanvasTests::RunUnitTestGraph(graphPath, ScriptCanvasEditor::RunSpec());
}
void RunUnitTestGraph(AZStd::string_view graphPath, ExecutionMode execution)
{
ScriptCanvasTests::RunUnitTestGraph(graphPath, execution, ScriptCanvasEditor::DurationSpec());
ScriptCanvasEditor::RunSpec spec;
spec.execution = execution;
ScriptCanvasTests::RunUnitTestGraph(graphPath, spec);
}
void RunUnitTestGraph(AZStd::string_view graphPath)
void RunUnitTestGraph(AZStd::string_view graphPath, ExecutionMode execution, const ScriptCanvasEditor::DurationSpec& duration)
{
ScriptCanvasTests::RunUnitTestGraph(graphPath, ScriptCanvasEditor::DurationSpec());
ScriptCanvasEditor::RunSpec runSpec;
runSpec.execution = execution;
runSpec.duration = duration;
RunUnitTestGraph(graphPath, runSpec);
}
void RunUnitTestGraph(AZStd::string_view graphPath, ExecutionMode execution, AZStd::string_view dependentScriptEvent)
{
AZ::Data::AssetType assetType(azrtti_typeid<ScriptEvents::ScriptEventsAsset>());
if (auto scriptEventAssetHandler = AZ::Data::AssetManager::Instance().GetHandler(assetType))
{
const AZStd::string fullPath = AZStd::string::format("%s/%s.%s", ScriptCanvasTestUtilitiesCPP::k_unitTestDirPathRelative, dependentScriptEvent.data(), ScriptCanvasTestUtilitiesCPP::k_scriptEventExtension);
// Preload dependent scriptevent asset for testing
AZStd::shared_ptr<AZ::Data::AssetDataStream> assetDataStream = AZStd::make_shared<AZ::Data::AssetDataStream>();
// Read in the data from a file to a buffer, then hand ownership of the buffer over to the assetDataStream
{
AZ::IO::FileIOStream stream(fullPath.c_str(), AZ::IO::OpenMode::ModeRead);
if (!AZ::IO::RetryOpenStream(stream))
{
ADD_FAILURE() << AZStd::string::format("CreateJobs for \"%s\" failed because the source file could not be opened.", fullPath.c_str()).data();
return;
}
AZStd::vector<AZ::u8> fileBuffer(stream.GetLength());
size_t bytesRead = stream.Read(fileBuffer.size(), fileBuffer.data());
if (bytesRead != stream.GetLength())
{
ADD_FAILURE() << AZStd::string::format("CreateJobs for \"%s\" failed because the source file could not be read.", fullPath.c_str()).data();
return;
}
assetDataStream->Open(AZStd::move(fileBuffer));
}
AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset;
const AZStd::string hintPath = AZStd::string::format("scriptcanvas/unittests/%s.%s", dependentScriptEvent.data(), ScriptCanvasTestUtilitiesCPP::k_scriptEventExtension);
asset.Create(AZ::Data::AssetId(AZ::Uuid::CreateName(hintPath.data())));
if (scriptEventAssetHandler->LoadAssetDataFromStream(asset, assetDataStream, nullptr) != AZ::Data::AssetHandler::LoadResult::LoadComplete)
{
ADD_FAILURE() << AZStd::string::format("Failed to load ScriptEvent asset: %s", fullPath.data()).data();
return;
}
scriptEventAssetHandler->InitAsset(asset, true, false);
ScriptCanvasEditor::RunSpec spec;
spec.execution = execution;
ScriptCanvasTests::RunUnitTestGraph(graphPath, spec);
}
else
{
ADD_FAILURE() << "ScriptEvent asset handler is missing.";
}
}
void RunUnitTestGraph(AZStd::string_view graphPath, const ScriptCanvasEditor::DurationSpec& duration)
{
ScriptCanvasEditor::RunSpec spec;
spec.duration = duration;
ScriptCanvasTests::RunUnitTestGraph(graphPath, ExecutionMode::Interpreted, duration);
}
void RunUnitTestGraph(AZStd::string_view graphPath, const ScriptCanvasEditor::RunSpec& runSpec)
{
const AZStd::string filePath = AZStd::string::format("%s/%s.%s", ScriptCanvasTestUtilitiesCPP::k_unitTestDirPathRelative, graphPath.data(), ScriptCanvasTestUtilitiesCPP::k_defaultExtension);
ScriptCanvasEditor::RunGraphSpec runGraphSpec;
runGraphSpec.graphPath = filePath;
runGraphSpec.dirPath = ScriptCanvasTestUtilitiesCPP::k_unitTestDirPathRelative;
runGraphSpec.runSpec = runSpec;
AZ_TEST_START_TRACE_SUPPRESSION;
const ScriptCanvasEditor::Reporters reporters = ScriptCanvasEditor::RunGraph(runGraphSpec);
for (const auto& reporter : reporters)
{
ScriptCanvasTests::VerifyReporter(reporter);
}
if (reporters.size() == 2)
{
EXPECT_EQ(reporters.front(), reporters.back());
}
else if (reporters.size() > 2)
{
for (size_t lhs(0), rhs(1); rhs != reporters.size(); ++lhs, ++rhs)
{
EXPECT_EQ(reporters[lhs], reporters[rhs]);
}
}
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
}
void RunUnitTestGraphMixed(AZStd::string_view graphPath, const ScriptCanvasEditor::DurationSpec& duration)
{
const ScriptCanvasEditor::Reporter reporterIterpreted0 = RunGraph(graphPath, ExecutionMode::Interpreted, duration);
const ScriptCanvasEditor::Reporter reporterNative0 = RunGraph(graphPath, ExecutionMode::Native, duration);
const ScriptCanvasEditor::Reporter reporterIterpreted1 = RunGraph(graphPath, ExecutionMode::Interpreted, duration);
const ScriptCanvasEditor::Reporter reporterNative1 = RunGraph(graphPath, ExecutionMode::Native, duration);
AZ_TEST_START_TRACE_SUPPRESSION;
ScriptCanvasEditor::RunGraphSpec runGraphSpec;
runGraphSpec.graphPath = graphPath;
runGraphSpec.dirPath = ScriptCanvasTestUtilitiesCPP::k_unitTestDirPathRelative;
runGraphSpec.runSpec.duration = duration;
runGraphSpec.runSpec.execution = ExecutionMode::Interpreted;
const ScriptCanvasEditor::Reporter reporterIterpreted0 = RunGraph(runGraphSpec).front();
runGraphSpec.runSpec.execution = ExecutionMode::Native;
const ScriptCanvasEditor::Reporter reporterNative0 = RunGraph(runGraphSpec).front();
runGraphSpec.runSpec.execution = ExecutionMode::Interpreted;
const ScriptCanvasEditor::Reporter reporterIterpreted1 = RunGraph(runGraphSpec).front();
runGraphSpec.runSpec.execution = ExecutionMode::Native;
const ScriptCanvasEditor::Reporter reporterNative1 = RunGraph(runGraphSpec).front();
VerifyReporter(reporterIterpreted0);
VerifyReporter(reporterNative0);
@@ -163,24 +386,8 @@ namespace ScriptCanvasTests
EXPECT_EQ(reporterNative0, reporterNative1);
EXPECT_EQ(reporterIterpreted0, reporterIterpreted1);
}
ScriptCanvasEditor::LoadTestGraphResult LoadTestGraph(AZStd::string_view graphPath)
{
const AZStd::string filePath = AZStd::string::format("%s/%s.%s", ScriptCanvasTestUtilitiesCPP::k_unitTestDirPathRelative, graphPath.data(), ScriptCanvasTestUtilitiesCPP::k_defaultExtension);
AZ::Outcome< AZ::Data::Asset<ScriptCanvas::RuntimeAsset>, AZStd::string> assetOutcome = AZ::Failure(AZStd::string("asset creation failed"));
ScriptCanvasEditor::EditorAssetConversionBus::BroadcastResult(assetOutcome, &ScriptCanvasEditor::EditorAssetConversionBusTraits::CreateRuntimeAsset, filePath);
if (assetOutcome.IsSuccess())
{
ScriptCanvasEditor::LoadTestGraphResult result;
result.m_asset = assetOutcome.GetValue();
result.m_graphEntity = AZStd::make_unique<AZ::Entity>("Loaded Graph");
result.m_graph = result.m_graphEntity->CreateComponent<ScriptCanvas::RuntimeComponent>(result.m_asset);
return result;
}
return {};
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
}
void RunUnitTestGraphMixed(AZStd::string_view graphPath)
@@ -291,16 +498,16 @@ namespace ScriptCanvasTests
{
using namespace ScriptCanvas;
ScriptCanvas::Namespaces emptyNamespaces;
ScriptCanvas::NamespacePath emptyNamespaces;
AZ::Entity* splitEntity{ aznew AZ::Entity };
splitEntity->Init();
AZ::EntityId methodNodeID{ splitEntity->GetId() };
SystemRequestBus::Broadcast(&SystemRequests::CreateNodeOnEntity, methodNodeID, scriptCanvasId, Nodes::Core::Method::RTTI_Type());
Nodes::Core::Method* methodNode(nullptr);
SystemRequestBus::BroadcastResult(methodNode, &SystemRequests::GetNode<Nodes::Core::Method>, methodNodeID);
SystemRequestBus::Broadcast(&SystemRequests::CreateNodeOnEntity, methodNodeID, scriptCanvasId, ScriptCanvas::Nodes::Core::Method::RTTI_Type());
ScriptCanvas::Nodes::Core::Method* methodNode(nullptr);
SystemRequestBus::BroadcastResult(methodNode, &SystemRequests::GetNode<ScriptCanvas::Nodes::Core::Method>, methodNodeID);
EXPECT_TRUE(methodNode != nullptr);
methodNode->InitializeClassOrBus(emptyNamespaces, className, methodName);
methodNode->InitializeBehaviorMethod(emptyNamespaces, className, methodName);
return methodNodeID;
}
@@ -313,83 +520,81 @@ namespace ScriptCanvasTests
switch (type.GetType())
{
case Data::eType::AABB:
node = CreateTestNode<Nodes::Math::AABB>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::AABB>(scriptCanvasId, nodeIDout);
break;
case Data::eType::BehaviorContextObject:
{
auto objectNode = CreateTestNode<Nodes::Core::BehaviorContextObjectNode>(scriptCanvasId, nodeIDout);
auto objectNode = CreateTestNode<ScriptCanvas::Nodes::Core::BehaviorContextObjectNode>(scriptCanvasId, nodeIDout);
objectNode->InitializeObject(type);
node = objectNode;
}
break;
case Data::eType::Boolean:
node = CreateTestNode<Nodes::Logic::Boolean>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Logic::Boolean>(scriptCanvasId, nodeIDout);
break;
case Data::eType::Color:
node = CreateTestNode<Nodes::Math::Color>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::Color>(scriptCanvasId, nodeIDout);
break;
case Data::eType::CRC:
node = CreateTestNode<Nodes::Math::CRC>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::CRC>(scriptCanvasId, nodeIDout);
break;
case Data::eType::EntityID:
node = CreateTestNode<Nodes::Entity::EntityRef>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Entity::EntityRef>(scriptCanvasId, nodeIDout);
break;
case Data::eType::Matrix3x3:
node = CreateTestNode<Nodes::Math::Matrix3x3>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::Matrix3x3>(scriptCanvasId, nodeIDout);
break;
case Data::eType::Matrix4x4:
node = CreateTestNode<Nodes::Math::Matrix4x4>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::Matrix4x4>(scriptCanvasId, nodeIDout);
break;
case Data::eType::Number:
node = CreateTestNode<Nodes::Math::Number>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::Number>(scriptCanvasId, nodeIDout);
break;
case Data::eType::OBB:
node = CreateTestNode<Nodes::Math::OBB>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::OBB>(scriptCanvasId, nodeIDout);
break;
case Data::eType::Plane:
node = CreateTestNode<Nodes::Math::Plane>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::Plane>(scriptCanvasId, nodeIDout);
break;
case Data::eType::Quaternion:
node = CreateTestNode<Nodes::Math::Quaternion>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::Quaternion>(scriptCanvasId, nodeIDout);
break;
case Data::eType::String:
node = CreateTestNode<Nodes::Core::String>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Core::String>(scriptCanvasId, nodeIDout);
break;
case Data::eType::Transform:
node = CreateTestNode<Nodes::Math::Transform>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::Transform>(scriptCanvasId, nodeIDout);
break;
case Data::eType::Vector2:
node = CreateTestNode<Nodes::Math::Vector2>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::Vector2>(scriptCanvasId, nodeIDout);
break;
case Data::eType::Vector3:
node = CreateTestNode<Nodes::Math::Vector3>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::Vector3>(scriptCanvasId, nodeIDout);
break;
case Data::eType::Vector4:
node = CreateTestNode<Nodes::Math::Vector4>(scriptCanvasId, nodeIDout);
node = CreateTestNode<ScriptCanvas::Nodes::Math::Vector4>(scriptCanvasId, nodeIDout);
break;
default:
AZ_Error("ScriptCanvas", false, "unsupported data type");
}
node->SetExecutionType(ExecutionType::Runtime);
return node;
}
@@ -465,22 +670,6 @@ namespace ScriptCanvasTests
return false;
}
AZ::Data::Asset<ScriptCanvas::RuntimeAsset> CreateRuntimeAsset(ScriptCanvas::Graph* graph)
{
using namespace ScriptCanvas;
RuntimeAssetHandler runtimeAssetHandler;
AZ::Data::Asset<RuntimeAsset> runtimeAsset;
runtimeAsset.Create(AZ::Uuid::CreateRandom());
AZ::SerializeContext* serializeContext = AZ::EntityUtils::GetApplicationSerializeContext();
serializeContext->CloneObjectInplace(runtimeAsset.Get()->GetData().m_graphData, graph->GetGraphDataConst());
AZStd::unordered_map<AZ::EntityId, AZ::EntityId> graphToAssetEntityIdMap{ { graph->GetScriptCanvasId(), ScriptCanvas::UniqueId } };
AZ::IdUtils::Remapper<AZ::EntityId>::GenerateNewIdsAndFixRefs(&runtimeAsset.Get()->GetData().m_graphData, graphToAssetEntityIdMap, serializeContext);
return runtimeAsset;
}
AZ::Entity* UnitTestEntityContext::CreateEntity(const char* name)
{
auto entity = aznew AZ::Entity(name);
@@ -613,54 +802,54 @@ namespace ScriptCanvasTests
return cloneEntity;
}
AZ::Data::AssetId UnitTestEntityContext::CurrentlyInstantiatingSlice()
{
return AZ::Data::AssetId();
}
//AZ::Data::AssetId UnitTestEntityContext::CurrentlyInstantiatingSlice()
//{
// return AZ::Data::AssetId();
//}
bool UnitTestEntityContext::HandleRootEntityReloadedFromStream(AZ::Entity*, bool, AZ::SliceComponent::EntityIdToEntityIdMap*)
{
return true;
}
//bool UnitTestEntityContext::HandleRootEntityReloadedFromStream(AZ::Entity*, bool, AZ::SliceComponent::EntityIdToEntityIdMap*)
//{
// return true;
//}
AZ::SliceComponent* UnitTestEntityContext::GetRootSlice()
{
return {};
}
//AZ::SliceComponent* UnitTestEntityContext::GetRootSlice()
//{
// return {};
//}
const AZStd::unordered_map<AZ::EntityId, AZ::EntityId>& UnitTestEntityContext::GetLoadedEntityIdMap()
{
return m_unitTestEntityIdMap;
}
//const AZStd::unordered_map<AZ::EntityId, AZ::EntityId>& UnitTestEntityContext::GetLoadedEntityIdMap()
//{
// return m_unitTestEntityIdMap;
//}
AzFramework::SliceInstantiationTicket UnitTestEntityContext::InstantiateSlice(const AZ::Data::Asset<AZ::Data::AssetData>&,
const AZ::IdUtils::Remapper<AZ::EntityId>::IdMapper&, const AZ::Data::AssetFilterCB&)
{
return AzFramework::SliceInstantiationTicket();
}
//AzFramework::SliceInstantiationTicket UnitTestEntityContext::InstantiateSlice(const AZ::Data::Asset<AZ::Data::AssetData>&,
// const AZ::IdUtils::Remapper<AZ::EntityId>::IdMapper&, const AZ::Data::AssetFilterCB&)
//{
// return AzFramework::SliceInstantiationTicket();
//}
AZ::SliceComponent::SliceInstanceAddress UnitTestEntityContext::CloneSliceInstance(
AZ::SliceComponent::SliceInstanceAddress, AZ::SliceComponent::EntityIdToEntityIdMap&)
{
return AZ::SliceComponent::SliceInstanceAddress();
}
//AZ::SliceComponent::SliceInstanceAddress UnitTestEntityContext::CloneSliceInstance(
// AZ::SliceComponent::SliceInstanceAddress, AZ::SliceComponent::EntityIdToEntityIdMap&)
//{
// return AZ::SliceComponent::SliceInstanceAddress();
//}
void UnitTestEntityContext::CancelSliceInstantiation(const AzFramework::SliceInstantiationTicket&)
{
}
//void UnitTestEntityContext::CancelSliceInstantiation(const AzFramework::SliceInstantiationTicket&)
//{
//}
AzFramework::SliceInstantiationTicket UnitTestEntityContext::GenerateSliceInstantiationTicket()
{
return AzFramework::SliceInstantiationTicket();
}
//AzFramework::SliceInstantiationTicket UnitTestEntityContext::GenerateSliceInstantiationTicket()
//{
// return AzFramework::SliceInstantiationTicket();
//}
void UnitTestEntityContext::SetIsDynamic(bool)
{
}
//void UnitTestEntityContext::SetIsDynamic(bool)
//{
//}
const AzFramework::RootSliceAsset& UnitTestEntityContext::GetRootAsset() const
{
return m_unitTestRootAsset;
}
//const AzFramework::RootSliceAsset& UnitTestEntityContext::GetRootAsset() const
//{
// return m_unitTestRootAsset;
//}
} // ScriptCanvasTests
@@ -11,11 +11,15 @@
*/
#pragma once
#include <Editor/Framework/ScriptCanvasTraceUtilities.h>
#include <Editor/Framework/ScriptCanvasReporter.h>
#include <Framework/ScriptCanvasTestNodes.h>
#include <AzTest/AzTest.h>
#include <AzTest/AzTest.h>
#include <Editor/Framework/ScriptCanvasReporter.h>
#include <Editor/Framework/ScriptCanvasTraceUtilities.h>
#include <Framework/ScriptCanvasTestNodes.h>
#include <ScriptCanvas/Core/Nodeable.h>
#include <AzFramework/Entity/SliceEntityOwnershipServiceBus.h>
#include "AzFramework/Slice/SliceInstantiationTicket.h"
namespace ScriptCanvasTests
{
@@ -23,104 +27,33 @@ namespace ScriptCanvasTests
extern const char* k_tempCoreAssetName;
extern const char* k_tempCoreAssetPath;
void ExpectParse(AZStd::string_view graphPath);
void ExpectParse(AZStd::string_view graphPath, AZStd::string_view extension);
void ExpectParseError(AZStd::string_view graphPath);
void ExpectParseError(AZStd::string_view graphPath, AZStd::string_view extension);
AZStd::string_view GetGraphNameFromPath(AZStd::string_view graphPath);
void VerifyReporter(const ScriptCanvasEditor::Reporter& reporter);
void RunUnitTestGraph(AZStd::string_view graphPath, ScriptCanvas::ExecutionMode execution, const ScriptCanvasEditor::DurationSpec& duration);
void RunUnitTestGraph(AZStd::string_view graphPath, const ScriptCanvasEditor::DurationSpec& duration);
void RunUnitTestGraph(AZStd::string_view graphPath);
void RunUnitTestGraph(AZStd::string_view graphPath, ScriptCanvas::ExecutionMode execution);
void RunUnitTestGraph(AZStd::string_view graphPath);
void RunUnitTestGraph(AZStd::string_view graphPath, ScriptCanvas::ExecutionMode execution, const ScriptCanvasEditor::DurationSpec& duration);
void RunUnitTestGraph(AZStd::string_view graphPath, ScriptCanvas::ExecutionMode execution, AZStd::string_view dependentScriptEvent);
void RunUnitTestGraph(AZStd::string_view graphPath, const ScriptCanvasEditor::DurationSpec& duration);
void RunUnitTestGraph(AZStd::string_view graphPath, const ScriptCanvasEditor::RunSpec& runSpec);
void RunUnitTestGraphMixed(AZStd::string_view graphPath, const ScriptCanvasEditor::DurationSpec& duration);
void RunUnitTestGraphMixed(AZStd::string_view graphPath);
class NodeAccessor
{
public:
template<typename t_Value>
static const t_Value* GetInput_UNIT_TEST(ScriptCanvas::Node* node, AZStd::string_view slotName)
{
return GetInput_UNIT_TEST<t_Value>(node, node->GetSlotId(slotName));
}
template<typename t_Value>
static t_Value* ModInput_UNIT_TEST(ScriptCanvas::Node* node, AZStd::string_view slotName)
{
return ModInput_UNIT_TEST<t_Value>(node, node->GetSlotId(slotName));
}
template<typename t_Value>
static const t_Value* GetInput_UNIT_TEST(ScriptCanvas::Node* node, const ScriptCanvas::SlotId& slotId)
{
const ScriptCanvas::Datum* input = node->FindDatum(slotId);
return input ? input->GetAs<t_Value>() : nullptr;
}
template<typename t_Value>
static t_Value* ModInput_UNIT_TEST(ScriptCanvas::Node* node, const ScriptCanvas::SlotId& slotId)
{
auto slotIter = node->m_slotIdIteratorCache.find(slotId);
if (slotIter != node->m_slotIdIteratorCache.end())
{
ScriptCanvas::Slot* slot = &(*slotIter->second.m_slotIterator);
if (slot->IsVariableReference())
{
AZ_Assert(false, "Variable references are not supported in Unit Test methods.");
}
else
{
return slotIter->second.GetDatumIter()->ModAs<t_Value>();
}
}
return nullptr;
}
static const ScriptCanvas::Datum* GetInput_UNIT_TEST(ScriptCanvas::Node* node, AZStd::string_view slotName)
{
return GetInput_UNIT_TEST(node, node->GetSlotId(slotName));
}
static const ScriptCanvas::Datum* GetInput_UNIT_TEST(ScriptCanvas::Node* node, const ScriptCanvas::SlotId& slotId)
{
return node->FindDatum(slotId);
}
// initializes the node input to the value passed in, not a pointer to it
template<typename t_Value>
static void SetInput_UNIT_TEST(ScriptCanvas::Node* node, AZStd::string_view slotName, const t_Value& value)
{
SetInput_UNIT_TEST<t_Value>(node, node->GetSlotId(slotName), value);
}
template<typename t_Value>
static void SetInput_UNIT_TEST(ScriptCanvas::Node* node, const ScriptCanvas::SlotId& slotId, const t_Value& value)
{
node->SetInput(ScriptCanvas::Datum(value), slotId);
}
static void SetInput_UNIT_TEST(ScriptCanvas::Node* node, AZStd::string_view slotName, const ScriptCanvas::Datum& value)
{
SetInput_UNIT_TEST(node, node->GetSlotId(slotName), value);
}
static void SetInput_UNIT_TEST(ScriptCanvas::Node* node, AZStd::string_view slotName, ScriptCanvas::Datum&& value)
{
SetInput_UNIT_TEST(node, node->GetSlotId(slotName), AZStd::move(value));
}
static void SetInput_UNIT_TEST(ScriptCanvas::Node* node, const ScriptCanvas::SlotId& slotId, ScriptCanvas::Datum&& value)
{
node->SetInput(AZStd::move(value), slotId);
}
};
void VerifyReporter(const ScriptCanvasEditor::Reporter& reporter);
template<typename t_NodeType>
t_NodeType* GetTestNode([[maybe_unused]] const ScriptCanvas::ScriptCanvasId& scriptCanvasId, const AZ::EntityId& nodeID)
@@ -129,7 +62,6 @@ namespace ScriptCanvasTests
t_NodeType* node{};
SystemRequestBus::BroadcastResult(node, &SystemRequests::GetNode<t_NodeType>, nodeID);
EXPECT_TRUE(node != nullptr);
node->SetExecutionType(ExecutionType::Runtime);
return node;
}
@@ -158,7 +90,7 @@ namespace ScriptCanvasTests
EXPECT_NE(node, nullptr);
if (node)
{
NodeAccessor::SetInput_UNIT_TEST(node, "Set", value);
node->SetInput_UNIT_TEST("Set", value);
}
return node;
}
@@ -184,8 +116,6 @@ namespace ScriptCanvasTests
void DumpSlots(const ScriptCanvas::Node& node);
bool Connect(ScriptCanvas::Graph& graph, const AZ::EntityId& fromNodeID, const char* fromSlotName, const AZ::EntityId& toNodeID, const char* toSlotName, bool dumpSlotsOnFailure = true);
AZ::Data::Asset<ScriptCanvas::RuntimeAsset> CreateRuntimeAsset(ScriptCanvas::Graph* graph);
class UnitTestEvents
: public AZ::EBusTraits
{
@@ -482,6 +412,7 @@ namespace ScriptCanvasTests
public:
virtual void Event() = 0;
virtual int Number(int number) = 0;
virtual AZStd::tuple<int, int> Numbers(int number) = 0;
virtual AZStd::string String(AZStd::string_view string) = 0;
virtual TestBehaviorContextObject Object(const TestBehaviorContextObject& vector) = 0;
};
@@ -499,6 +430,7 @@ namespace ScriptCanvasTests
, AZ::SystemAllocator
, Event
, Number
, Numbers
, String
, Object);
@@ -531,6 +463,13 @@ namespace ScriptCanvasTests
return output;
}
AZStd::tuple<int, int> Numbers(int number) override
{
AZStd::tuple<int, int> result;
CallResult(result, FN_Numbers, number);
return result;
}
AZStd::string String(AZStd::string_view input) override
{
AZStd::string output;
@@ -589,34 +528,42 @@ namespace ScriptCanvasTests
public:
AZ_CLASS_ALLOCATOR(UnitTestEntityContext, AZ::SystemAllocator, 0);
UnitTestEntityContext()
{
AzFramework::EntityContextRequestBus::Handler::BusConnect(GetOwningContextId());
AzFramework::SliceEntityOwnershipServiceRequestBus::Handler::BusConnect(GetOwningContextId());
}
UnitTestEntityContext() { AzFramework::EntityContextRequestBus::Handler::BusConnect(GetOwningContextId()); }
//// EntityIdContextQueryBus::MultiHandler
// Returns a generate Uuid which represents the UnitTest EntityContext
AzFramework::EntityContextId GetOwningContextId() override { return AzFramework::EntityContextId("{36591268-5CE9-4BC1-8277-0AB9AD528447}"); }
////
//////////////////////////////////////////////////////////////////////////
// SliceEntityOwnershipServiceRequestBus
AZ::Data::AssetId CurrentlyInstantiatingSlice() override;
bool HandleRootEntityReloadedFromStream(AZ::Entity* rootEntity, bool remapIds,
AZ::SliceComponent::EntityIdToEntityIdMap* idRemapTable) override;
AZ::SliceComponent* GetRootSlice() override;
AZ::EntityId FindLoadedEntityIdMapping(const AZ::EntityId& staticId) const;
const AZStd::unordered_map<AZ::EntityId, AZ::EntityId>& GetLoadedEntityIdMap() override;
AzFramework::SliceInstantiationTicket InstantiateSlice(const AZ::Data::Asset<AZ::Data::AssetData>& asset,
const AZ::IdUtils::Remapper<AZ::EntityId>::IdMapper& customIdMapper, const AZ::Data::AssetFilterCB& assetLoadFilter) override;
AZ::SliceComponent::SliceInstanceAddress CloneSliceInstance(AZ::SliceComponent::SliceInstanceAddress sourceInstance,
AZ::SliceComponent::EntityIdToEntityIdMap& sourceToCloneEntityIdMap) override;
void CancelSliceInstantiation(const AzFramework::SliceInstantiationTicket& ticket) override;
AzFramework::SliceInstantiationTicket GenerateSliceInstantiationTicket() override;
void SetIsDynamic(bool isDynamic) override;
const AzFramework::RootSliceAsset& GetRootAsset() const override;
//////////////////////////////////////////////////////////////////////////
//// AzFramework::SliceEntityOwnershipServiceRequests
const AzFramework::RootSliceAsset& GetRootAsset() const override {
static AzFramework::RootSliceAsset invalid;
return invalid;
}
AZ::SliceComponent* GetRootSlice() override { return {}; }
void SetIsDynamic(bool) override {}
void CancelSliceInstantiation(const AzFramework::SliceInstantiationTicket&) override {}
AzFramework::SliceInstantiationTicket GenerateSliceInstantiationTicket() override { return AzFramework::SliceInstantiationTicket(); }
bool HandleRootEntityReloadedFromStream(AZ::Entity*, bool, [[maybe_unused]] AZ::SliceComponent::EntityIdToEntityIdMap* idRemapTable = nullptr) override
{
return false;
}
const AZ::SliceComponent::EntityIdToEntityIdMap& GetLoadedEntityIdMap() override { return m_unitTestEntityIdMap; }
AZ::SliceComponent::SliceInstanceAddress CloneSliceInstance(AZ::SliceComponent::SliceInstanceAddress,
AZ::SliceComponent::EntityIdToEntityIdMap&) override
{
return{};
}
AzFramework::SliceInstantiationTicket InstantiateSlice(const AZ::Data::Asset<AZ::Data::AssetData>&,
[[maybe_unused]] const AZ::IdUtils::Remapper<AZ::EntityId>::IdMapper& customIdMapper = nullptr,
[[maybe_unused]] const AZ::Data::AssetFilterCB& assetLoadFilter = nullptr) override
{
return AzFramework::SliceInstantiationTicket();
}
AZ::Data::AssetId CurrentlyInstantiatingSlice() override {
return AZ::Data::AssetId();
};
AZ::Entity* CreateEntity(const char* name) override;
@@ -628,84 +575,16 @@ namespace ScriptCanvasTests
bool DestroyEntityById(AZ::EntityId entityId) override;
AZ::Entity* CloneEntity(const AZ::Entity& sourceEntity) override;
void ResetContext() override;
AZ::EntityId FindLoadedEntityIdMapping(const AZ::EntityId& staticId) const;
////
void AddEntity(AZ::EntityId entityId);
void RemoveEntity(AZ::EntityId entityId);
bool IsOwnedByThisContext(AZ::EntityId entityId) { return m_unitTestEntityIdMap.count(entityId) != 0; }
AZStd::unordered_map<AZ::EntityId, AZ::EntityId> m_unitTestEntityIdMap;
AzFramework::RootSliceAsset m_unitTestRootAsset;
AZ::SliceComponent::EntityIdToEntityIdMap m_unitTestEntityIdMap;
};
template<typename t_Operator, typename t_Operand, typename t_Value>
void BinaryOpTest(const t_Operand& lhs, const t_Operand& rhs, const t_Value& expectedResult, bool forceGraphError = false)
{
using namespace ScriptCanvas;
using namespace Nodes;
AZ::Entity graphEntity("Graph");
graphEntity.Init();
SystemRequestBus::Broadcast(&SystemRequests::CreateGraphOnEntity, &graphEntity);
auto graph = graphEntity.FindComponent<Graph>();
EXPECT_NE(nullptr, graph);
const AZ::EntityId& graphEntityId = graph->GetEntityId();
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId operatorID;
CreateTestNode<t_Operator>(graphUniqueId, operatorID);
AZ::EntityId lhsID;
CreateDataNode(graphUniqueId, lhs, lhsID);
AZ::EntityId rhsID;
CreateDataNode(graphUniqueId, rhs, rhsID);
AZ::EntityId printID;
auto printNode = CreateTestNode<TestNodes::TestResult>(graphUniqueId, printID);
EXPECT_TRUE(Connect(*graph, lhsID, "Get", operatorID, BinaryOperator::k_lhsName));
if (!forceGraphError)
{
EXPECT_TRUE(Connect(*graph, rhsID, "Get", operatorID, BinaryOperator::k_rhsName));
}
EXPECT_TRUE(Connect(*graph, operatorID, BinaryOperator::k_resultName, printID, "Value"));
EXPECT_TRUE(Connect(*graph, startID, "Out", operatorID, BinaryOperator::k_evaluateName));
bool isArithmetic = AZStd::is_base_of<ScriptCanvas::Nodes::ArithmeticExpression, t_Operator>::value;
if (isArithmetic)
{
EXPECT_TRUE(Connect(*graph, operatorID, BinaryOperator::k_outName, printID, "In"));
}
else
{
EXPECT_TRUE(Connect(*graph, operatorID, BinaryOperator::k_onTrue, printID, "In"));
EXPECT_TRUE(Connect(*graph, operatorID, BinaryOperator::k_onFalse, printID, "In"));
}
{
ScriptCanvasEditor::ScopedOutputSuppression suppressOutput;
graph->GetEntity()->Activate();
EXPECT_EQ(graph->IsInErrorState(), forceGraphError);
}
if (!forceGraphError)
{
if (auto result = NodeAccessor::GetInput_UNIT_TEST<t_Value>(printNode, "Value"))
{
EXPECT_EQ(*result, expectedResult);
}
else
{
ADD_FAILURE();
}
}
graph->GetEntity()->Deactivate();
delete graph;
}
template<typename TBusIdType>
class TemplateEventTest
: public AZ::EBusTraits
@@ -865,5 +744,54 @@ namespace ScriptCanvasTests
AZ::u32 m_slotsAdded = 0;
AZ::u32 m_slotsRemoved = 0;
};
class TestNodeableObject
: public ScriptCanvas::Nodeable
{
public:
AZ_RTTI(TestNodeableObject, "{5FA6967F-AB4D-4077-91C9-1C2CE36733AF}", Nodeable);
AZ_CLASS_ALLOCATOR(Nodeable, AZ::SystemAllocator, 0);
static void Reflect(AZ::ReflectContext* reflectContext)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext))
{
serializeContext->Class<TestNodeableObject, Nodeable>();
if (auto editContext = serializeContext->GetEditContext())
{
editContext->Class<TestNodeableObject>("TestNodeableObject", "")
;
}
}
// reflect API for the node
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(reflectContext))
{
behaviorContext->Class<TestNodeableObject>("TestNodeableObject")
->Method("Branch", &TestNodeableObject::Branch)
;
}
}
void Branch(bool condition)
{
if (condition)
{
ExecutionOut(AZ_CRC("BranchTrue", 0xd49f121c), true, AZStd::string("called the true version!"));
}
else
{
ExecutionOut(AZ_CRC("BranchFalse", 0xaceca8bc), false, AZStd::string("called the false version!"), AZ::Vector3(1, 2, 3));
}
}
bool IsActive() const override
{
return false;
}
};
} // ScriptCanvasTests
@@ -16,52 +16,61 @@ namespace ScriptCanvasTests
{
ScriptCanvasEditor::UnitTestResult VerifyReporterEditor(const ScriptCanvasEditor::Reporter& reporter)
{
ScriptCanvasEditor::UnitTestResult result = ScriptCanvasEditor::UnitTestResult(false, true, "");
ScriptCanvasEditor::UnitTestResult result = ScriptCanvasEditor::UnitTestResult::AssumeFailure();
if (!reporter.GetScriptCanvasId().IsValid())
AZStd::string details;
if (!reporter.IsCompiled())
{
result.m_consoleOutput += "Graph is not valid\n";
details = "Graph did not compile.\n";
}
else if (reporter.IsReportFinished())
{
result.m_compiled = true;
const auto& successes = reporter.GetSuccess();
for (const auto& success : successes)
{
result.m_consoleOutput += "SUCCESS - ";
result.m_consoleOutput += success.data();
result.m_consoleOutput += "\n";
details += "SUCCESS - ";
details += success.data();
details += "\n";
}
if (!reporter.IsActivated())
{
result.m_consoleOutput += "Graph did not activate\n";
details += "Graph did not activate\n";
}
if (!reporter.IsDeactivated())
{
result.m_consoleOutput += "Graph did not deactivate\n";
// \todo track this more aggressively, graphs should deactivate
details += "Graph did not deactivate\n";
}
if (!reporter.IsErrorFree())
{
result.m_consoleOutput += "Graph had errors\n";
details += "Graph had errors\n";
}
const auto& failures = reporter.GetFailure();
for (const auto& failure : failures)
{
result.m_consoleOutput += "FAILURE - ";
result.m_consoleOutput += failure.data();
result.m_consoleOutput += "\n";
details += "FAILURE - ";
details += failure.data();
details += "\n";
}
if (!reporter.IsComplete())
{
result.m_consoleOutput += "Graph was not marked complete\n";
details += "Graph was not marked complete\n";
}
const auto& checkpoints = reporter.GetCheckpoints();
if (!checkpoints.empty())
if (checkpoints.empty())
{
details += "No checkpoints or other unit test nodes found, using them can help parse graph test failures\n";
}
else
{
AZStd::string checkpointPath = "Checkpoint Path:\n";
int i = 0;
@@ -70,28 +79,26 @@ namespace ScriptCanvasTests
{
checkpointPath += AZStd::string::format("%2d: %s\n", ++i, checkpoint.data());
}
result.m_consoleOutput += checkpointPath.data();
details += checkpointPath.data();
}
if (reporter.IsComplete() && failures.empty())
{
result.m_consoleOutput += "COMPLETE!\n";
result.m_success = true;
result.m_completed = true;
result.m_consoleOutput = "SUCCEEDED, COMPLETE!\n";
result.m_consoleOutput += details;
return result;
}
}
else
{
result.m_consoleOutput += "Graph report did not finish\n";
result.m_compiled = true;
details += "Graph report did not finish\n";
}
result.m_consoleOutput += "FAILED!\n";
result.m_success = false;
result.m_consoleOutput = "FAILED!\n";
result.m_consoleOutput += details;
return result;
}
} // namespace ScriptCanvasTests
}
@@ -0,0 +1,59 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "NodeableTestingLibrary.h"
#include "SharedDataSlotExample.h"
#include "ValuePointerReferenceExample.h"
#include <AzCore/Serialization/EditContext.h>
#include "Source/Nodes/Nodeables/SharedDataSlotExample.generated.h"
namespace ScriptCanvasTesting
{
void NodeableTestingLibrary::Reflect(AZ::ReflectContext* reflection)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflection);
if (serializeContext)
{
serializeContext->Class<NodeableTestingLibrary, ScriptCanvas::Library::LibraryDefinition>()
->Version(1);
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<NodeableTestingLibrary>("Nodeable Testing", "");
}
}
}
void NodeableTestingLibrary::InitNodeRegistry(ScriptCanvas::NodeRegistry& nodeRegistry)
{
ScriptCanvas::Library::AddNodeToRegistry<NodeableTestingLibrary, ::Nodes::InputMethodSharedDataSlotExampleNode>(nodeRegistry);
ScriptCanvas::Library::AddNodeToRegistry<NodeableTestingLibrary, ::Nodes::BranchMethodSharedDataSlotExampleNode>(nodeRegistry);
ScriptCanvas::Library::AddNodeToRegistry<NodeableTestingLibrary, ::Nodes::ReturnTypeExampleNode>(nodeRegistry);
ScriptCanvas::Library::AddNodeToRegistry<NodeableTestingLibrary, ::Nodes::InputTypeExampleNode>(nodeRegistry);
ScriptCanvas::Library::AddNodeToRegistry<NodeableTestingLibrary, ::Nodes::BranchInputTypeExampleNode>(nodeRegistry);
}
AZStd::vector<AZ::ComponentDescriptor*> NodeableTestingLibrary::GetComponentDescriptors()
{
return AZStd::vector<AZ::ComponentDescriptor*>({
::Nodes::InputMethodSharedDataSlotExampleNode::CreateDescriptor(),
::Nodes::BranchMethodSharedDataSlotExampleNode::CreateDescriptor(),
::Nodes::ReturnTypeExampleNode::CreateDescriptor(),
::Nodes::InputTypeExampleNode::CreateDescriptor(),
::Nodes::BranchInputTypeExampleNode::CreateDescriptor()
});
}
}
@@ -0,0 +1,28 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <ScriptCanvas/Libraries/Libraries.h>
namespace ScriptCanvasTesting
{
struct NodeableTestingLibrary : public ScriptCanvas::Library::LibraryDefinition
{
AZ_RTTI(NodeableTestingLibrary, "{F48EF27C-EA32-455C-88AB-191A132F093B}", ScriptCanvas::Library::LibraryDefinition);
static void Reflect(AZ::ReflectContext*);
static void InitNodeRegistry(ScriptCanvas::NodeRegistry& nodeRegistry);
static AZStd::vector<AZ::ComponentDescriptor*> GetComponentDescriptors();
~NodeableTestingLibrary() override = default;
};
}
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<ScriptCanvas Include="Source/Nodes/Nodeables/SharedDataSlotExample.h" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Class Name="InputMethodSharedDataSlotExample"
QualifiedName="ScriptCanvasTesting::Nodeables::InputMethodSharedDataSlotExample"
PreferredClassName="InputMethodSharedDataSlotExample"
Base="ScriptCanvas::Nodeable"
Icon="Editor/Icons/ScriptCanvas/Placeholder.png"
Category="Tests"
GeneratePropertyFriend="True"
Namespace="None"
Description="Input Method Shared Data">
<Input Name="Append Hello" Description="" DisplayGroup="InputMethodGroup">
<Parameter Name="str" Type="const ScriptCanvas::Data::StringType&amp;"/>
<Return Name="Output" Type="ScriptCanvas::Data::StringType" Shared="true" DisplayGroup="InputMethodGroup"/>
</Input>
<Input Name="Concatenate Two" Description="" DisplayGroup="Concatenate Two">
<Parameter Name="a" Type="const ScriptCanvas::Data::StringType&amp;"/>
<Parameter Name="b" Type="const ScriptCanvas::Data::StringType&amp;"/>
<Return Name="Output" Type="ScriptCanvas::Data::StringType" Shared="true" DisplayGroup="InputMethodGroup"/>
</Input>
<Input Name="Concatenate Three" Description="" DisplayGroup="Concatenate Three">
<Parameter Name="a" Type="const ScriptCanvas::Data::StringType&amp;"/>
<Parameter Name="b" Type="const ScriptCanvas::Data::StringType&amp;"/>
<Parameter Name="c" Type="const ScriptCanvas::Data::StringType&amp;"/>
<Return Name="Output" Type="ScriptCanvas::Data::StringType" Shared="true" DisplayGroup="InputMethodGroup"/>
</Input>
</Class>
<Class Name="BranchMethodSharedDataSlotExample"
QualifiedName="ScriptCanvasTesting::Nodeables::BranchMethodSharedDataSlotExample"
PreferredClassName="BranchMethodSharedDataSlotExample"
Base="ScriptCanvas::Nodeable"
Icon="Editor/Icons/ScriptCanvas/Placeholder.png"
Category="Tests"
GeneratePropertyFriend="True"
Description="Branch Test">
<Branch Name="String Magicbox" Description="">
<Parameter Name="input" Type="ScriptCanvas::Data::NumberType" DefaultValue="0.0"/>
</Branch>
<Output Name="One String" DisplayGroup="String Magicbox">
<Parameter Name="string" Type="ScriptCanvas::Data::StringType"/>
</Output>
<Output Name="Two Strings" Type="ScriptCanvas::Data::StringType" DisplayGroup="String Magicbox">
<Parameter Name="string1" Type="ScriptCanvas::Data::StringType"/>
<Parameter Name="string2" Type="ScriptCanvas::Data::StringType"/>
</Output>
<Output Name="Three Strings" Type="Data::StringType" DisplayGroup="String Magicbox">
<Parameter Name="string1" Type="ScriptCanvas::Data::StringType"/>
<Parameter Name="string2" Type="ScriptCanvas::Data::StringType"/>
<Parameter Name="string3" Type="ScriptCanvas::Data::StringType"/>
</Output>
<Output Name="Square" Type="ScriptCanvas::Data::StringType"/>
<Output Name="Pants" Type="ScriptCanvas::Data::StringType"/>
<Output Name="Hello" Type="ScriptCanvas::Data::StringType" DisplayGroup="BranchExecutionGroup"/>
</Class>
</ScriptCanvas>
@@ -0,0 +1,50 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "SharedDataSlotExample.h"
namespace ScriptCanvasTesting
{
namespace Nodeables
{
AZStd::string InputMethodSharedDataSlotExample::AppendHello(const ScriptCanvas::Data::StringType& arg)
{
return AZStd::string::format("%sHello", arg.c_str());
}
AZStd::string InputMethodSharedDataSlotExample::ConcatenateTwo(const ScriptCanvas::Data::StringType& arg1, const ScriptCanvas::Data::StringType& arg2)
{
return AZStd::string::format("%s%s", arg1.c_str(), arg2.c_str());
}
AZStd::string InputMethodSharedDataSlotExample::ConcatenateThree(const ScriptCanvas::Data::StringType& arg1, const ScriptCanvas::Data::StringType& arg2, const ScriptCanvas::Data::StringType& arg3)
{
return AZStd::string::format("%s%s%s", arg1.c_str(), arg2.c_str(), arg3.c_str());
}
void BranchMethodSharedDataSlotExample::StringMagicbox(int arg)
{
switch (arg)
{
case 1:
CallOneString("Hello1");
break;
case 2:
CallTwoStrings("Bob", "Hello2");
break;
case 3:
CallThreeStrings("Square", "Pants", "Hello3");
break;
}
}
}
}
@@ -0,0 +1,43 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <ScriptCanvas/Core/Nodeable.h>
#include <ScriptCanvas/Core/NodeableNode.h>
#include <ScriptCanvas/CodeGen/NodeableCodegen.h>
#include <Source/Nodes/Nodeables/SharedDataSlotExample.generated.h>
namespace ScriptCanvasTesting
{
namespace Nodeables
{
class InputMethodSharedDataSlotExample
: public ScriptCanvas::Nodeable
{
SCRIPTCANVAS_NODE(InputMethodSharedDataSlotExample);
public:
};
class BranchMethodSharedDataSlotExample
: public ScriptCanvas::Nodeable
{
SCRIPTCANVAS_NODE(BranchMethodSharedDataSlotExample);
public:
void StringMagicbox(int);
};
}
}
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<ScriptCanvas Include="Source/Nodes/Nodeables/ValuePointerReferenceExample.h" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Class Name="ReturnTypeExample"
QualifiedName="ScriptCanvasTesting::Nodeables::ReturnTypeExample"
PreferredClassName="Return Type Example"
Base="ScriptCanvas::Nodeable"
Icon="Editor/Icons/ScriptCanvas/Placeholder.png"
Category="Tests"
GeneratePropertyFriend="True"
Namespace="None"
Description="Example of returning by value, pointer and reference.">
<Input Name="Return By Value" >
<Return Name="Value" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;" />
</Input>
<Input Name="Return By Pointer" >
<Return Name="Pointer" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;*" />
</Input>
<Input Name="Return By Reference" >
<Return Name="Reference" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;&amp;" />
</Input>
</Class>
<Class Name="BranchInputTypeExample"
QualifiedName="ScriptCanvasTesting::Nodeables::BranchInputTypeExample"
PreferredClassName="Branch Input Type Example"
Base="ScriptCanvas::Nodeable"
Icon="Editor/Icons/ScriptCanvas/Placeholder.png"
Category="Tests"
GeneratePropertyFriend="True"
Namespace="None"
Description="Example of branch passing as input by value, pointer and reference.">
<Input Name="Get Internal Vector" Description="">
<Return Name="Result" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;" />
</Input>
<Input Name="Branches On Input Type" Description="" DisplayGroup="Branches On Input Type">
<Parameter Name="Input Type" Type="AZStd::string" Input="True"/>
<Branch Name="By Value" Description="" DisplayGroup="Branches On Input Type">
<Return Name="Value Input" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;&amp;" DisplayGroup="Branches On Input Type"/>
</Branch>
<Branch Name="By Pointer" Description="" DisplayGroup="Branches On Input Type">
<Return Name="Pointer Input" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;*" DisplayGroup="Branches On Input Type"/>
</Branch>
</Input>
</Class>
<Class Name="InputTypeExample"
QualifiedName="ScriptCanvasTesting::Nodeables::InputTypeExample"
PreferredClassName="Input Type Example"
Base="ScriptCanvas::Nodeable"
Icon="Editor/Icons/ScriptCanvas/Placeholder.png"
Category="Tests"
GeneratePropertyFriend="True"
Namespace="None"
Description="Example of passing as input by value, pointer and reference.">
<Input Name="Clear By Value" Description="">
<Parameter Name="Value Input" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;" Input="True"/>
</Input>
<Input Name="Clear By Pointer" Description="">
<Parameter Name="Pointer Input" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;*" Input="True"/>
</Input>
<Input Name="Clear By Reference" Description="">
<Parameter Name="Reference Input" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;&amp;" Input="True"/>
</Input>
</Class>
</ScriptCanvas>
@@ -0,0 +1,70 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "ValuePointerReferenceExample.h"
namespace ScriptCanvasTesting
{
namespace Nodeables
{
AZStd::vector<ScriptCanvas::Data::NumberType> ReturnTypeExample::ReturnByValue()
{
return m_internalVector;
}
AZStd::vector<ScriptCanvas::Data::NumberType>* ReturnTypeExample::ReturnByPointer()
{
return &m_internalVector;
}
AZStd::vector<ScriptCanvas::Data::NumberType>& ReturnTypeExample::ReturnByReference()
{
return m_internalVector;
}
AZStd::vector<ScriptCanvas::Data::NumberType> BranchInputTypeExample::GetInternalVector()
{
return m_internalVector;
}
void BranchInputTypeExample::BranchesOnInputType(AZStd::string inputType)
{
if (inputType == "Value")
{
CallByValue(m_internalVector);
}
else if (inputType == "Pointer")
{
CallByPointer(&m_internalVector);
}
}
void InputTypeExample::ClearByValue(AZStd::vector<ScriptCanvas::Data::NumberType> input)
{
input.clear();
}
void InputTypeExample::ClearByPointer(AZStd::vector<ScriptCanvas::Data::NumberType>* input)
{
if (input)
{
input->clear();
}
}
void InputTypeExample::ClearByReference(AZStd::vector<ScriptCanvas::Data::NumberType>& input)
{
input.clear();
}
}
}
@@ -0,0 +1,52 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <ScriptCanvas/Core/Nodeable.h>
#include <ScriptCanvas/Core/NodeableNode.h>
#include <ScriptCanvas/CodeGen/NodeableCodegen.h>
#include <AzCore/std/containers/vector.h>
#include <Source/Nodes/Nodeables/ValuePointerReferenceExample.generated.h>
namespace ScriptCanvasTesting
{
namespace Nodeables
{
class ReturnTypeExample
: public ScriptCanvas::Nodeable
{
SCRIPTCANVAS_NODE(ReturnTypeExample);
private:
AZStd::vector<ScriptCanvas::Data::NumberType> m_internalVector{ 1.0, 2.0, 3.0 };
};
class BranchInputTypeExample
: public ScriptCanvas::Nodeable
{
SCRIPTCANVAS_NODE(BranchInputTypeExample);
private:
AZStd::vector<ScriptCanvas::Data::NumberType> m_internalVector{ 1.0, 2.0, 3.0 };
};
class InputTypeExample
: public ScriptCanvas::Nodeable
{
SCRIPTCANVAS_NODE(InputTypeExample);
};
}
}
@@ -0,0 +1,180 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "ScriptCanvasTestBus.h"
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <ScriptCanvas/Core/Attributes.h>
namespace ScriptCanvasTesting
{
class GlobalEBusHandler
: public GlobalEBus::Handler
, public AZ::BehaviorEBusHandler
{
public:
AZ_EBUS_BEHAVIOR_BINDER(
GlobalEBusHandler, "{CF167F12-0685-4347-A2DE-8D40186E7332}", AZ::SystemAllocator, AppendSweet, Increment, Not, Sum, Void,
GetZeroParamEvent, GetByReferenceEvent, GetByValueEvent);
AZStd::string AppendSweet(AZStd::string_view value) override
{
AZStd::string result;
CallResult(result, FN_AppendSweet, value);
return result;
}
int Increment(int value) override
{
int result;
CallResult(result, FN_Increment, value);
return result;
}
bool Not(bool value) override
{
bool result;
CallResult(result, FN_Not, value);
return result;
}
int Sum(int numberA, int numberB) override
{
int result(0);
CallResult(result, FN_Sum, numberA, numberB);
return result;
}
void Void(AZStd::string_view value) override
{
Call(FN_Void, value);
}
AZ::Event<>* GetZeroParamEvent() override
{
AZ::Event<>* azEvent = nullptr;
CallResult(azEvent, FN_GetZeroParamEvent);
return azEvent;
}
AZ::Event<AZStd::vector<AZStd::string>&>* GetByReferenceEvent() override
{
AZ::Event<AZStd::vector<AZStd::string>&>* azEvent = nullptr;
CallResult(azEvent, FN_GetByReferenceEvent);
return azEvent;
}
AZ::Event<int, bool, AZStd::string>* GetByValueEvent() override
{
AZ::Event<int, bool, AZStd::string>* azEvent = nullptr;
CallResult(azEvent, FN_GetByValueEvent);
return azEvent;
}
};
void GlobalBusTraits::Reflect(AZ::ReflectContext* context)
{
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
AZ::BehaviorAzEventDescription modObjectDesc, modValueDesc, modVoidDesc;
modObjectDesc.m_eventName = "OnEvent-Reference";
modObjectDesc.m_parameterNames = {"Object List"};
modValueDesc.m_eventName = "OnEvent-Value";
modValueDesc.m_parameterNames = {"A", "BB", "CCC"};
modVoidDesc.m_eventName = "OnEvent-ZeroParam";
behaviorContext->EBus<GlobalEBus>("GlobalEBus")
->Handler<GlobalEBusHandler>()
->Event("AppendSweet", &GlobalEBus::Events::AppendSweet)
->Event("Increment", &GlobalEBus::Events::Increment)
->Event("Not", &GlobalEBus::Events::Not)
->Event("Sum", &GlobalEBus::Events::Sum)
->Event("Void", &GlobalEBus::Events::Void)
->Event("GetZeroParamEvent", &GlobalEBus::Events::GetZeroParamEvent)
->Attribute(AZ::Script::Attributes::AzEventDescription, modVoidDesc)
->Event("GetByReferenceEvent", &GlobalEBus::Events::GetByReferenceEvent)
->Attribute(AZ::Script::Attributes::AzEventDescription, modObjectDesc)
->Event("GetByValueEvent", &GlobalEBus::Events::GetByValueEvent)
->Attribute(AZ::Script::Attributes::AzEventDescription, modValueDesc);
}
}
class LocalEBusHandler
: public LocalEBus::Handler
, public AZ::BehaviorEBusHandler
{
public:
AZ_EBUS_BEHAVIOR_BINDER(
LocalEBusHandler, "{308650EE-061D-4090-A7FB-471885C8B6A5}", AZ::SystemAllocator, AppendSweet, Increment, Not, Void);
AZStd::string AppendSweet(AZStd::string_view value) override
{
AZStd::string result;
CallResult(result, FN_AppendSweet, value);
return result;
}
int Increment(int value) override
{
int result;
CallResult(result, FN_Increment, value);
return result;
}
bool Not(bool value) override
{
bool result;
CallResult(result, FN_Not, value);
return result;
}
void Void(AZStd::string_view value)
{
Call(FN_Void, value);
}
};
void LocalBusTraits::Reflect(AZ::ReflectContext* context)
{
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<LocalEBus>("LocalEBus")
->Handler<LocalEBusHandler>()
->Event("AppendSweet", &LocalEBus::Events::AppendSweet)
->Event("Increment", &LocalEBus::Events::Increment)
->Event("Not", &LocalEBus::Events::Not)
->Event("Void", &LocalEBus::Events::Void);
}
}
void NativeHandlingOnlyBusTraits::Reflect(AZ::ReflectContext* context)
{
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<NativeHandlingOnlyEBus>("NativeHandlingOnlyEBus")
->Event("AppendSweet", &NativeHandlingOnlyEBus::Events::AppendSweet)
->Event("Increment", &NativeHandlingOnlyEBus::Events::Increment)
->Event("Not", &NativeHandlingOnlyEBus::Events::Not)
->Event("TwistTypeEntityId", &NativeHandlingOnlyEBus::Events::TwistTypeEntityId)
->Event("TwistTypeVector3", &NativeHandlingOnlyEBus::Events::TwistTypeVector3)
->Event("TwistTupleEntityId", &NativeHandlingOnlyEBus::Events::TwistTupleEntityId)
->Event("TwistTupleVector3", &NativeHandlingOnlyEBus::Events::TwistTupleVector3)
->Event("Void", &NativeHandlingOnlyEBus::Events::Void);
}
}
}
@@ -0,0 +1,107 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/string/string_view.h>
#include <ScriptCanvas/Data/Data.h>
namespace AZ
{
class ReflectContext;
}
namespace ScriptCanvasTesting
{
class GlobalBusTraits : public AZ::EBusTraits
{
public:
AZ_TYPE_INFO(GlobalBusTraits, "{DED849D7-CF17-408B-8D87-E31FC7D3CEC4}");
static void Reflect(AZ::ReflectContext* context);
virtual AZStd::string AppendSweet(AZStd::string_view) = 0;
virtual int Increment(int value) = 0;
virtual bool Not(bool value) = 0;
virtual int Sum(int numberA, int numberB) = 0;
virtual void Void(AZStd::string_view) = 0;
virtual AZ::Event<>* GetZeroParamEvent() = 0;
virtual AZ::Event<AZStd::vector<AZStd::string>&>* GetByReferenceEvent() = 0;
virtual AZ::Event<int, bool, AZStd::string>* GetByValueEvent() = 0;
};
using GlobalEBus = AZ::EBus<GlobalBusTraits>;
class LocalBusTraits : public AZ::EBusTraits
{
public:
AZ_TYPE_INFO(LocalBusTraits, "{749B6949-CBBB-44D9-A57D-9973DC88E639}");
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = double;
static void Reflect(AZ::ReflectContext* context);
virtual AZStd::string AppendSweet(AZStd::string_view) = 0;
virtual int Increment(int value) = 0;
virtual bool Not(bool value) = 0;
virtual void Void(AZStd::string_view) = 0;
};
using LocalEBus = AZ::EBus<LocalBusTraits>;
class NativeHandlingOnlyBusTraits : public AZ::EBusTraits
{
public:
AZ_TYPE_INFO(NativeHandlingOnlyBusTraits, "{5AED48A7-3E16-41F6-B1C0-4E1FBBA84F83}");
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = AZ::EntityId;
static void Reflect(AZ::ReflectContext* context);
virtual AZStd::string AppendSweet(AZStd::string_view) = 0;
virtual int Increment(int value) = 0;
virtual AZ::EntityId TwistTypeEntityId() = 0;
virtual AZ::Vector3 TwistTypeVector3() = 0;
virtual AZStd::tuple<AZ::EntityId, bool> TwistTupleEntityId() = 0;
virtual AZStd::tuple<AZ::Vector3, bool> TwistTupleVector3() = 0;
virtual bool Not(bool value) = 0;
virtual void Void(AZStd::string_view) = 0;
};
using NativeHandlingOnlyEBus = AZ::EBus<NativeHandlingOnlyBusTraits>;
class TestTupleMethods
{
public:
AZ_TYPE_INFO(TestTupleMethods, "{E794CE93-7AC6-476E-BF10-B107A2E4D807}");
static AZStd::tuple<ScriptCanvas::Data::Vector3Type, ScriptCanvas::Data::StringType, ScriptCanvas::Data::BooleanType> Three(
const ScriptCanvas::Data::Vector3Type& v, const ScriptCanvas::Data::StringType& s, const ScriptCanvas::Data::BooleanType& b)
{
return AZStd::make_tuple(v, s, b);
}
static void Reflect(AZ::ReflectContext* context)
{
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<TestTupleMethods>("TestTupleMethods")->Method("Three", &TestTupleMethods::Three);
}
}
};
}
@@ -15,6 +15,7 @@
#include <AzCore/Module/Module.h>
#include <ScriptCanvasTestingSystemComponent.h>
#include <Editor/Framework/ScriptCanvasTraceUtilities.h>
#include <Source/Nodes/Nodeables/NodeableTestingLibrary.h>
namespace ScriptCanvasTesting
{
@@ -33,6 +34,9 @@ namespace ScriptCanvasTesting
ScriptCanvasTestingSystemComponent::CreateDescriptor(),
TraceMessageComponent::CreateDescriptor(),
});
AZStd::vector<AZ::ComponentDescriptor*> componentDescriptors(NodeableTestingLibrary::GetComponentDescriptors());
m_descriptors.insert(m_descriptors.end(), componentDescriptors.begin(), componentDescriptors.end());
}
/**
@@ -12,11 +12,13 @@
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <Framework/ScriptCanvasTestVerify.h>
#include "ScriptCanvasTestingSystemComponent.h"
#include "ScriptCanvasTestBus.h"
#include "Framework/ScriptCanvasTestVerify.h"
#include "Nodes/BehaviorContextObjectTestNode.h"
#include <Nodes/BehaviorContextObjectTestNode.h>
#include <Source/Nodes/Nodeables/NodeableTestingLibrary.h>
namespace ScriptCanvasTesting
{
@@ -38,7 +40,13 @@ namespace ScriptCanvasTesting
}
}
NodeableTestingLibrary::Reflect(context);
ScriptCanvasTestingNodes::BehaviorContextObjectTest::Reflect(context);
ScriptCanvasTesting::GlobalBusTraits::Reflect(context);
ScriptCanvasTesting::LocalBusTraits::Reflect(context);
ScriptCanvasTesting::NativeHandlingOnlyBusTraits::Reflect(context);
ScriptCanvasTesting::TestTupleMethods::Reflect(context);
}
void ScriptCanvasTestingSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
@@ -63,6 +71,7 @@ namespace ScriptCanvasTesting
void ScriptCanvasTestingSystemComponent::Init()
{
NodeableTestingLibrary::InitNodeRegistry(ScriptCanvas::GetNodeRegistry().Get());
}
void ScriptCanvasTestingSystemComponent::Activate()
@@ -37,7 +37,7 @@ namespace ScriptCanvasTesting
protected:
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
// AZ::Component...
void Init() override;
void Activate() override;
void Deactivate() override;
@@ -157,7 +157,7 @@ TEST_F(ScriptCanvasTestFixture, Asynchronous_Behaviors)
RegisterComponentDescriptor<AsyncNode>();
// Make the graph.
Graph* graph = nullptr;
ScriptCanvas::Graph* graph =nullptr;
SystemRequestBus::BroadcastResult(graph, &SystemRequests::MakeGraph);
ASSERT_TRUE(graph != nullptr);
@@ -171,7 +171,7 @@ TEST_F(ScriptCanvasTestFixture, Asynchronous_Behaviors)
startEntity->Init();
AZ::EntityId startNodeId;
Nodes::Core::Start* startNode = CreateTestNode<Nodes::Core::Start>(graphUniqueId, startNodeId);
ScriptCanvas::Nodes::Core::Start* startNode = CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startNodeId);
AZ::EntityId asyncNodeId;
AsyncNode* asyncNode = CreateTestNode<AsyncNode>(graphUniqueId, asyncNodeId);
@@ -288,7 +288,7 @@ TEST_F(ScriptCanvasTestFixture, ComputeFibonacciAsyncGraphTest)
RegisterComponentDescriptor<AsyncFibonacciComputeNode>();
// Make the graph.
Graph* graph = nullptr;
ScriptCanvas::Graph* graph =nullptr;
SystemRequestBus::BroadcastResult(graph, &SystemRequests::MakeGraph);
ASSERT_NE(graph, nullptr);
@@ -299,7 +299,7 @@ TEST_F(ScriptCanvasTestFixture, ComputeFibonacciAsyncGraphTest)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startNodeId;
Nodes::Core::Start* startNode = CreateTestNode<Nodes::Core::Start>(graphUniqueId, startNodeId);
ScriptCanvas::Nodes::Core::Start* startNode = CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startNodeId);
AZ::EntityId asyncNodeId;
AsyncFibonacciComputeNode* asyncNode = CreateTestNode<AsyncFibonacciComputeNode>(graphUniqueId, asyncNodeId);
File diff suppressed because it is too large Load Diff
@@ -12,62 +12,26 @@
#include <Source/Framework/ScriptCanvasTestFixture.h>
#include <Source/Framework/ScriptCanvasTestUtilities.h>
#include <AzCore/ScriptCanvas/ScriptCanvasAttributes.h>
#include <AzCore/RTTI/AttributeReader.h>
using namespace ScriptCanvasTests;
using namespace ScriptCanvas;
TEST_F(ScriptCanvasTestFixture, FillWithOrdinals)
{
RunUnitTestGraph("LY_SC_UnitTest_FillWithOrdinals");
}
TEST_F(ScriptCanvasTestFixture, AZStdArray)
{
// Enable when BE2.0 goes to main
//RunUnitTestGraph("LY_SC_UnitTest_AZStdArray");
RunUnitTestGraph("LY_SC_UnitTest_AZStdArray", ExecutionMode::Interpreted);
}
/*
TEST_F(ScriptCanvasTestFixture, ForEachNested)
{
RunUnitTestGraph("LY_SC_UnitTest_ForEachNested");
}
TEST_F(ScriptCanvasTestFixture, ForEachNestedBreak)
{
RunUnitTestGraph("LY_SC_UnitTest_ForEachNestedBreak");
}
*/
TEST_F(ScriptCanvasTestFixture, ForEachNode)
{
// Enable when BE2.0 goes to main
// RunUnitTestGraph("LY_SC_UnitTest_ForEachNode");
RunUnitTestGraph("LY_SC_UnitTest_ForEachNode", ExecutionMode::Interpreted);
}
/*
TEST_F(ScriptCanvasTestFixture, ForEachBreak)
{
RunUnitTestGraph("LY_SC_UnitTest_ForEachBreak");
}
*/
// TODO: needs to be recreated with new operator nodes
//TEST_F(ScriptCanvasTestFixture, VectorContainerVector3)
//{
// RunUnitTestGraph("LY_SC_UnitTest_VectorContainerVector3");
//}
TEST_F(ScriptCanvasTestFixture, MapContainerStringVec3)
{
// Enable when BE2.0 goes to main
//RunUnitTestGraph("LY_SC_UnitTest_MapContainerStringVec3");
RunUnitTestGraph("LY_SC_UnitTest_MapContainerStringVec3", ExecutionMode::Interpreted);
}
TEST_F(ScriptCanvasTestFixture, SetContainerNum)
TEST_F(ScriptCanvasTestFixture, VectorContainerVector3)
{
// Enable when BE2.0 goes to main
//RunUnitTestGraph("LY_SC_UnitTest_SetContainerNum");
RunUnitTestGraph("LY_SC_UnitTest_VectorContainerVector3", ExecutionMode::Interpreted);
}
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
/*
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
@@ -11,30 +11,32 @@
*/
#include <Source/Framework/ScriptCanvasTestFixture.h>
#include <Source/Framework/ScriptCanvasTestUtilities.h>
using namespace ScriptCanvasTests;
using namespace ScriptCanvas;
TEST_F(ScriptCanvasTestFixture, StringMethodCStyle2CStyle)
{
RunUnitTestGraph("LY_SC_UnitTest_StringMethodCStyle2CStyle");
RunUnitTestGraph("LY_SC_UnitTest_StringMethodCStyle2CStyle", ExecutionMode::Interpreted);
}
TEST_F(ScriptCanvasTestFixture, EBusStringResultCStyle2CStyle)
{
RunUnitTestGraph("LY_SC_UnitTest_EBusStringResultCStyle2CStyle");
RunUnitTestGraph("LY_SC_UnitTest_EBusStringResultCStyle2CStyle", ExecutionMode::Interpreted);
}
TEST_F(ScriptCanvasTestFixture, EBusStringResultCStyle2String)
{
RunUnitTestGraph("LY_SC_UnitTest_EBusStringResultCStyle2String");
RunUnitTestGraph("LY_SC_UnitTest_EBusStringResultCStyle2String", ExecutionMode::Interpreted);
}
TEST_F(ScriptCanvasTestFixture, EBusStringResultCStyle2StringView)
{
RunUnitTestGraph("LY_SC_UnitTest_EBusStringResultCStyle2StringView");
RunUnitTestGraph("LY_SC_UnitTest_EBusStringResultCStyle2StringView", ExecutionMode::Interpreted);
}
TEST_F(ScriptCanvasTestFixture, EBusResultNested)
{
RunUnitTestGraph("LY_SC_UnitTest_EBusResultNested");
}
RunUnitTestGraph("LY_SC_UnitTest_EBusResultNested", ExecutionMode::Interpreted);
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,547 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright EntityRef license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/PlatformDef.h>
#include <AzCore/RTTI/RTTI.h>
#include <Source/Framework/ScriptCanvasTestFixture.h>
#include <Source/Framework/ScriptCanvasTestUtilities.h>
#include <Source/Framework/ScriptCanvasTestNodes.h>
#include <ScriptCanvas/Core/NodeableNodeOverloaded.h>
#include <ScriptCanvas/Core/Nodeable.h>
#include <ScriptCanvas/Core/SlotConfigurationDefaults.h>
using namespace ScriptCanvasTests;
template<typename Type>
class SingleTypeNodeable
: public ScriptCanvas::Nodeable
{
private:
using ClassName = SingleTypeNodeable<Type>;
public:
AZ_RTTI(((SingleTypeNodeable<Type>), "{62F173B5-596B-4872-B88B-E03DFCD5D059}", Type), ScriptCanvas::Nodeable);
AZ_CLASS_ALLOCATOR(SingleTypeNodeable<Type>, AZ::SystemAllocator, 0);
static void Reflect(AZ::ReflectContext* reflectContext)
{
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext))
{
serializeContext->Class<SingleTypeNodeable, Nodeable>()
;
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<SingleTypeNodeable>("Single Type Nodeable", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(reflectContext))
{
behaviorContext->Class<ClassName>()
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::List)
->Method("MethodOne", &ClassName::MethodOne)
->Method("MethodTwo", &ClassName::MethodTwo)
;
}
}
void MethodOne(Type paramOne)
{
AZ_UNUSED(paramOne);
}
void MethodTwo(Type paramOne, Type paramTwo)
{
AZ_UNUSED(paramOne);
AZ_UNUSED(paramTwo);
}
};
class SingleTypeNodeableNode
: public ScriptCanvas::Nodes::NodeableNodeOverloaded
{
public:
AZ_COMPONENT(SingleTypeNodeableNode, "{CDB445D4-A129-4E40-90E7-332DF825CC5E}", ScriptCanvas::Nodes::NodeableNodeOverloaded);
static void Reflect(AZ::ReflectContext* reflectContext)
{
SingleTypeNodeable<ScriptCanvas::Data::NumberType>::Reflect(reflectContext);
SingleTypeNodeable<ScriptCanvas::Data::Vector2Type>::Reflect(reflectContext);
SingleTypeNodeable<ScriptCanvas::Data::Vector3Type>::Reflect(reflectContext);
SingleTypeNodeable<ScriptCanvas::Data::Vector4Type>::Reflect(reflectContext);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext))
{
serializeContext->Class<SingleTypeNodeableNode, ScriptCanvas::Nodes::NodeableNodeOverloaded>()
;
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<SingleTypeNodeableNode>("Lerp Between", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Math")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
}
void ConfigureSlots()
{
ScriptCanvas::SlotExecution::Ins ins;
{
{
ScriptCanvas::SlotExecution::In methodOne;
ScriptCanvas::ExecutionSlotConfiguration inSlotConfiguration;
inSlotConfiguration.m_name = "MethodOne";
inSlotConfiguration.m_displayGroup = "In";
inSlotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Input);
inSlotConfiguration.m_isLatent = false;
ScriptCanvas::SlotId inSlotId = AddSlot(inSlotConfiguration);
AZ_Assert(inSlotId.IsValid(), "In slot is not created successfully.");
methodOne.slotId = inSlotId;
{
ScriptCanvas::DynamicDataSlotConfiguration dataSlotConfiguration;
dataSlotConfiguration.m_name = "Param";
dataSlotConfiguration.m_displayGroup = "In";
dataSlotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Input);
dataSlotConfiguration.m_dynamicDataType = ScriptCanvas::DynamicDataType::Value;
// Since this contract will check in with the underlying overload to enforce
// the typing, we don't need to have one of these contracts on each slot, as each
// group assignment will trigger this contract to confirm the typing.
dataSlotConfiguration.m_contractDescs = AZStd::vector<ScriptCanvas::ContractDescriptor>
{
{ []() { return aznew ScriptCanvas::OverloadContract(); } }
};
ScriptCanvas::SlotId slotId = AddSlot(dataSlotConfiguration);
AZ_Assert(slotId.IsValid(), "Data slot is not created successfully.");
methodOne.inputs.push_back(slotId);
}
ins.push_back(methodOne);
}
{
ScriptCanvas::SlotExecution::In methodTwo;
ScriptCanvas::ExecutionSlotConfiguration inSlotConfiguration;
inSlotConfiguration.m_name = "Cancel";
inSlotConfiguration.m_displayGroup = "Cancel";
inSlotConfiguration.m_toolTip = "Stops the lerp action immediately.";
inSlotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Input);
inSlotConfiguration.m_isLatent = false;
ScriptCanvas::SlotId inSlotId = AddSlot(inSlotConfiguration);
AZ_Assert(inSlotId.IsValid(), "Cancel slot is not created successfully.");
methodTwo.slotId = inSlotId;
{
ScriptCanvas::DynamicDataSlotConfiguration dataSlotConfiguration;
dataSlotConfiguration.m_name = "ParamOne";
dataSlotConfiguration.m_displayGroup = "In";
dataSlotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Input);
dataSlotConfiguration.m_dynamicDataType = ScriptCanvas::DynamicDataType::Value;
// Since this contract will check in with the underlying overload to enforce
// the typing, we don't need to have one of these contracts on each slot, as each
// group assignment will trigger this contract to confirm the typing.
dataSlotConfiguration.m_contractDescs = AZStd::vector<ScriptCanvas::ContractDescriptor>
{
{ []() { return aznew ScriptCanvas::OverloadContract(); } }
};
ScriptCanvas::SlotId slotId = AddSlot(dataSlotConfiguration);
AZ_Assert(slotId.IsValid(), "Data slot is not created successfully.");
methodTwo.inputs.push_back(slotId);
}
{
ScriptCanvas::DynamicDataSlotConfiguration dataSlotConfiguration;
dataSlotConfiguration.m_name = "ParamTwo";
dataSlotConfiguration.m_displayGroup = "In";
dataSlotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Input);
dataSlotConfiguration.m_dynamicDataType = ScriptCanvas::DynamicDataType::Value;
// Since this contract will check in with the underlying overload to enforce
// the typing, we don't need to have one of these contracts on each slot, as each
// group assignment will trigger this contract to confirm the typing.
dataSlotConfiguration.m_contractDescs = AZStd::vector<ScriptCanvas::ContractDescriptor>
{
{ []() { return aznew ScriptCanvas::OverloadContract(); } }
};
ScriptCanvas::SlotId slotId = AddSlot(dataSlotConfiguration);
AZ_Assert(slotId.IsValid(), "Data slot is not created successfully.");
methodTwo.inputs.push_back(slotId);
}
ins.push_back(methodTwo);
}
}
SetSlotExecutionMap(AZStd::move(ScriptCanvas::SlotExecution::Map(AZStd::move(ins), {})));
}
AZStd::vector<AZStd::unique_ptr<ScriptCanvas::Nodeable>> GetInitializationNodeables() const override
{
AZStd::vector<AZStd::unique_ptr<ScriptCanvas::Nodeable>> nodeables;
nodeables.push_back(AZStd::make_unique<SingleTypeNodeable<ScriptCanvas::Data::NumberType>>());
nodeables.push_back(AZStd::make_unique<SingleTypeNodeable<ScriptCanvas::Data::Vector2Type>>());
nodeables.push_back(AZStd::make_unique<SingleTypeNodeable<ScriptCanvas::Data::Vector3Type>>());
nodeables.push_back(AZStd::make_unique<SingleTypeNodeable<ScriptCanvas::Data::Vector4Type>>());
return nodeables;
}
};
TEST_F(ScriptCanvasTestFixture, Overload_NodeableNode_TypeCheck)
{
RegisterComponentDescriptor<SingleTypeNodeableNode>();
ScriptCanvas::Graph* graph = CreateGraph();
const ScriptCanvas::ScriptCanvasId& scriptCanvasId = graph->GetScriptCanvasId();
AZ::EntityId nodeableNodeId;
SingleTypeNodeableNode* nodeableNode = CreateTestNode<SingleTypeNodeableNode>(scriptCanvasId, nodeableNodeId);
nodeableNode->PostActivate();
ScriptCanvas::SlotId paramId = nodeableNode->GetSlotByName("Param")->GetId();
ScriptCanvas::SlotId paramOneId = nodeableNode->GetSlotByName("ParamOne")->GetId();
ScriptCanvas::SlotId paramTwoId = nodeableNode->GetSlotByName("ParamTwo")->GetId();
AZStd::vector< ScriptCanvas::SlotId > slotIds = {
paramId,
paramOneId,
paramTwoId
};
AZStd::vector< ScriptCanvas::Data::Type > acceptedTypes = {
ScriptCanvas::Data::Type::Number(),
ScriptCanvas::Data::Type::Vector2(),
ScriptCanvas::Data::Type::Vector3(),
ScriptCanvas::Data::Type::Vector4()
};
AZStd::vector< ScriptCanvas::Data::Type > invalidTypes = {
ScriptCanvas::Data::Type::EntityID(),
ScriptCanvas::Data::Type::Color(),
ScriptCanvas::Data::Type::Transform()
};
for (ScriptCanvas::Data::Type acceptedType : acceptedTypes)
{
for (ScriptCanvas::SlotId slotId : slotIds)
{
AZ::Outcome<void, AZStd::string> validTypeSlot = nodeableNode->IsValidTypeForSlot(slotId, acceptedType);
EXPECT_TRUE(validTypeSlot.IsSuccess());
}
}
for (ScriptCanvas::Data::Type invalidType : invalidTypes)
{
for (ScriptCanvas::SlotId slotId : slotIds)
{
AZ::Outcome<void, AZStd::string> invalidTypeSlot = nodeableNode->IsValidTypeForSlot(slotId, invalidType);
EXPECT_FALSE(invalidTypeSlot.IsSuccess());
}
}
}
TEST_F(ScriptCanvasTestFixture, Overload_NodeableNode_ConnectionCheck)
{
RegisterComponentDescriptor<SingleTypeNodeableNode>();
ScriptCanvas::Graph* graph = CreateGraph();
const ScriptCanvas::ScriptCanvasId& scriptCanvasId = graph->GetScriptCanvasId();
AZ::EntityId nodeableNodeId;
SingleTypeNodeableNode* nodeableNode = CreateTestNode<SingleTypeNodeableNode>(scriptCanvasId, nodeableNodeId);
nodeableNode->PostActivate();
TestNodes::ConfigurableUnitTestNode* unitTestNode = CreateConfigurableNode("ConfigurableNode");
ScriptCanvas::SlotId paramId = nodeableNode->GetSlotByName("Param")->GetId();
ScriptCanvas::SlotId paramOneId = nodeableNode->GetSlotByName("ParamOne")->GetId();
ScriptCanvas::SlotId paramTwoId = nodeableNode->GetSlotByName("ParamTwo")->GetId();
AZStd::vector< ScriptCanvas::SlotId > slotIds = {
paramId,
paramOneId,
paramTwoId
};
AZStd::vector< ScriptCanvas::Data::Type > acceptedTypes = {
ScriptCanvas::Data::Type::Number(),
ScriptCanvas::Data::Type::Vector2(),
ScriptCanvas::Data::Type::Vector3(),
ScriptCanvas::Data::Type::Vector4()
};
AZStd::vector< ScriptCanvas::Data::Type > invalidTypes = {
ScriptCanvas::Data::Type::EntityID(),
ScriptCanvas::Data::Type::Color(),
ScriptCanvas::Data::Type::Transform()
};
for (ScriptCanvas::Data::Type acceptedType : acceptedTypes)
{
ScriptCanvas::Slot* validSlot = nullptr;
{
ScriptCanvas::DataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetType(acceptedType);
slotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Output);
validSlot = unitTestNode->AddTestingSlot(slotConfiguration);
}
ScriptCanvas::Endpoint validStartEndpoint = validSlot->GetEndpoint();
for (ScriptCanvas::SlotId slotId : slotIds)
{
ScriptCanvas::Endpoint paramEndpoint = { nodeableNode->GetEntityId(), slotId };
const bool isValid = true;
TestIsConnectionPossible(validStartEndpoint, paramEndpoint, isValid);
}
}
for (ScriptCanvas::Data::Type invalidType : invalidTypes)
{
ScriptCanvas::Slot* invalidSlot = nullptr;
{
ScriptCanvas::DataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetType(invalidType);
slotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Output);
invalidSlot = unitTestNode->AddTestingSlot(slotConfiguration);
}
ScriptCanvas::Endpoint invalidStartEndpoint = invalidSlot->GetEndpoint();
for (ScriptCanvas::SlotId slotId : slotIds)
{
ScriptCanvas::Endpoint paramEndpoint = { nodeableNode->GetEntityId(), slotId };
const bool isValid = false;
TestIsConnectionPossible(invalidStartEndpoint, paramEndpoint, isValid);
}
}
}
TEST_F(ScriptCanvasTestFixture, Overload_NodeableNode_NumberConnection)
{
RegisterComponentDescriptor<SingleTypeNodeableNode>();
ScriptCanvas::Graph* graph = CreateGraph();
const ScriptCanvas::ScriptCanvasId& scriptCanvasId = graph->GetScriptCanvasId();
AZ::EntityId nodeableNodeId;
SingleTypeNodeableNode* nodeableNode = CreateTestNode<SingleTypeNodeableNode>(scriptCanvasId, nodeableNodeId);
nodeableNode->PostActivate();
TestNodes::ConfigurableUnitTestNode* unitTestNode = CreateConfigurableNode("ConfigurableNode");
ScriptCanvas::SlotId paramId = nodeableNode->GetSlotByName("Param")->GetId();
ScriptCanvas::SlotId paramOneId = nodeableNode->GetSlotByName("ParamOne")->GetId();
ScriptCanvas::SlotId paramTwoId = nodeableNode->GetSlotByName("ParamTwo")->GetId();
AZStd::vector< ScriptCanvas::SlotId > slotIds = {
paramId,
paramOneId,
paramTwoId
};
AZStd::vector< ScriptCanvas::Data::Type > invalidTypes = {
ScriptCanvas::Data::Type::Vector2(),
ScriptCanvas::Data::Type::Vector3(),
ScriptCanvas::Data::Type::Vector4(),
ScriptCanvas::Data::Type::EntityID(),
ScriptCanvas::Data::Type::Color(),
ScriptCanvas::Data::Type::Transform()
};
ScriptCanvas::Slot* validSlot = nullptr;
{
ScriptCanvas::DataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetType(ScriptCanvas::Data::Type::Number());
slotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Output);
validSlot = unitTestNode->AddTestingSlot(slotConfiguration);
}
ScriptCanvas::Slot* paramOneSlot = nodeableNode->GetSlot(paramOneId);
ScriptCanvas::Slot* paramTwoSlot = nodeableNode->GetSlot(paramTwoId);
EXPECT_FALSE(paramOneSlot->HasDisplayType());
EXPECT_FALSE(paramTwoSlot->HasDisplayType());
ScriptCanvas::Endpoint validStartEndpoint = validSlot->GetEndpoint();
ScriptCanvas::Endpoint paramEndpoint = { nodeableNode->GetEntityId(), paramId };
TestConnectionBetween(validStartEndpoint, paramEndpoint);
EXPECT_TRUE(paramOneSlot->HasDisplayType());
EXPECT_EQ(paramOneSlot->GetDisplayType(), ScriptCanvas::Data::Type::Number());
EXPECT_TRUE(paramTwoSlot->HasDisplayType());
EXPECT_EQ(paramTwoSlot->GetDisplayType(), ScriptCanvas::Data::Type::Number());
for (ScriptCanvas::Data::Type invalidType : invalidTypes)
{
ScriptCanvas::Slot* invalidSlot = nullptr;
{
ScriptCanvas::DataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetType(invalidType);
slotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Output);
invalidSlot = unitTestNode->AddTestingSlot(slotConfiguration);
}
ScriptCanvas::Endpoint invalidStartEndpoint = invalidSlot->GetEndpoint();
for (ScriptCanvas::SlotId slotId : slotIds)
{
ScriptCanvas::Endpoint paramEndpoint2 = { nodeableNode->GetEntityId(), slotId };
const bool isValid = false;
TestIsConnectionPossible(invalidStartEndpoint, paramEndpoint2, isValid);
}
}
}
TEST_F(ScriptCanvasTestFixture, Overload_NodeableNode_Vector3Connection)
{
RegisterComponentDescriptor<SingleTypeNodeableNode>();
ScriptCanvas::Graph* graph = CreateGraph();
const ScriptCanvas::ScriptCanvasId& scriptCanvasId = graph->GetScriptCanvasId();
AZ::EntityId nodeableNodeId;
SingleTypeNodeableNode* nodeableNode = CreateTestNode<SingleTypeNodeableNode>(scriptCanvasId, nodeableNodeId);
nodeableNode->PostActivate();
TestNodes::ConfigurableUnitTestNode* unitTestNode = CreateConfigurableNode("ConfigurableNode");
ScriptCanvas::SlotId paramId = nodeableNode->GetSlotByName("Param")->GetId();
ScriptCanvas::SlotId paramOneId = nodeableNode->GetSlotByName("ParamOne")->GetId();
ScriptCanvas::SlotId paramTwoId = nodeableNode->GetSlotByName("ParamTwo")->GetId();
AZStd::vector< ScriptCanvas::SlotId > slotIds = {
paramId,
paramOneId,
paramTwoId
};
AZStd::vector< ScriptCanvas::Data::Type > invalidTypes = {
ScriptCanvas::Data::Type::Number(),
ScriptCanvas::Data::Type::Vector2(),
ScriptCanvas::Data::Type::Vector4(),
ScriptCanvas::Data::Type::EntityID(),
ScriptCanvas::Data::Type::Color(),
ScriptCanvas::Data::Type::Transform()
};
ScriptCanvas::Slot* validSlot = nullptr;
{
ScriptCanvas::DataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetType(ScriptCanvas::Data::Type::Vector3());
slotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Output);
validSlot = unitTestNode->AddTestingSlot(slotConfiguration);
}
ScriptCanvas::Slot* paramOneSlot = nodeableNode->GetSlot(paramOneId);
ScriptCanvas::Slot* paramTwoSlot = nodeableNode->GetSlot(paramTwoId);
EXPECT_FALSE(paramOneSlot->HasDisplayType());
EXPECT_FALSE(paramTwoSlot->HasDisplayType());
ScriptCanvas::Endpoint validStartEndpoint = validSlot->GetEndpoint();
ScriptCanvas::Endpoint paramEndpoint = { nodeableNode->GetEntityId(), paramId };
TestConnectionBetween(validStartEndpoint, paramEndpoint);
EXPECT_TRUE(paramOneSlot->HasDisplayType());
EXPECT_EQ(paramOneSlot->GetDisplayType(), ScriptCanvas::Data::Type::Vector3());
EXPECT_TRUE(paramTwoSlot->HasDisplayType());
EXPECT_EQ(paramTwoSlot->GetDisplayType(), ScriptCanvas::Data::Type::Vector3());
for (ScriptCanvas::Data::Type invalidType : invalidTypes)
{
ScriptCanvas::Slot* invalidSlot = nullptr;
{
ScriptCanvas::DataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetType(invalidType);
slotConfiguration.SetConnectionType(ScriptCanvas::ConnectionType::Output);
invalidSlot = unitTestNode->AddTestingSlot(slotConfiguration);
}
ScriptCanvas::Endpoint invalidStartEndpoint = invalidSlot->GetEndpoint();
for (ScriptCanvas::SlotId slotId : slotIds)
{
ScriptCanvas::Endpoint paramEndpoint2 = { nodeableNode->GetEntityId(), slotId };
const bool isValid = false;
TestIsConnectionPossible(invalidStartEndpoint, paramEndpoint2, isValid);
}
}
}
@@ -17,9 +17,12 @@
#include <ScriptCanvas/Core/NodeFunctionGeneric.h>
#pragma warning( push )
#pragma warning( disable : 5046) //'function' : Symbol involving type with internal linkage not defined
using namespace ScriptCanvasTests;
namespace ScriptCanvasTests
namespace
{
AZ_INLINE void ArgsNoReturn(float)
@@ -111,14 +114,14 @@ namespace ScriptCanvas
AZ_INLINE AZ::Vector3 NormalizeWithDefault(const AZ::Vector3& source, const Data::NumberType tolerance, [[maybe_unused]] const Data::BooleanType fakeValueForTestingDefault)
{
AZ_TracePrintf("SC", "The fake value for testing default is %s\n", fakeValueForTestingDefault ? "True" : "False");
return source.GetNormalizedSafe(aznumeric_cast<float>(tolerance));
return source.GetNormalizedSafe(tolerance);
}
void NormalizeWithDefaultInputOverrides(Node& node) { SetDefaultValuesByIndex< 1, 2 >::_(node, 3.3, true); }
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE_WITH_DEFAULTS(NormalizeWithDefault, NormalizeWithDefaultInputOverrides, "Math/Vector3", "{1A56B08E-7E48-4240-878A-397A912519B6}", "description placeholder", "Vector", "Tolerance", "Fake Testing Default Value");
}
TEST_F(ScriptCanvasTestFixture, NodeGenerics)
TEST_F(ScriptCanvasTestFixture, DISABLED_NodeGenerics)
{
using namespace ScriptCanvasEditor;
@@ -133,7 +136,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenerics)
UnitTestEventsHandler unitTestHandler;
unitTestHandler.BusConnect();
Graph* graph = nullptr;
ScriptCanvas::Graph* graph = nullptr;
SystemRequestBus::BroadcastResult(graph, &SystemRequests::MakeGraph);
EXPECT_TRUE(graph != nullptr);
graph->GetEntity()->Init();
@@ -142,7 +145,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenerics)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId noArgsNoReturnNodeID;
CreateTestNode<NoArgsNoReturnNode>(graphUniqueId, noArgsNoReturnNodeID);
@@ -167,9 +170,8 @@ TEST_F(ScriptCanvasTestFixture, NodeGenerics)
TraceSuppressionBus::Broadcast(&TraceSuppressionRequests::SuppressPrintf, true);
graph->GetEntity()->Activate();
TraceSuppressionBus::Broadcast(&TraceSuppressionRequests::SuppressPrintf, false);
EXPECT_FALSE(graph->IsInErrorState());
if (auto tolerance = GetInput_UNIT_TEST<Data::NumberType>(normalizeWithDefaultNode,"Number: Tolerance"))
if (auto tolerance = normalizeWithDefaultNode->GetInput_UNIT_TEST<Data::NumberType>("Number: Tolerance"))
{
EXPECT_EQ(3.3, *tolerance);
}
@@ -178,7 +180,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenerics)
ADD_FAILURE();
}
if (auto fakeDefault = GetInput_UNIT_TEST<Data::BooleanType>(normalizeWithDefaultNode,"Boolean: Fake Testing Default Value"))
if (auto fakeDefault = normalizeWithDefaultNode->GetInput_UNIT_TEST<Data::BooleanType>("Boolean: Fake Testing Default Value"))
{
EXPECT_TRUE(*fakeDefault);
}
@@ -192,7 +194,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenerics)
EXPECT_EQ(unitTestHandler.SideEffectCount(), 3);
}
TEST_F(ScriptCanvasTestFixture, NodeGenericsByValue)
TEST_F(ScriptCanvasTestFixture, DISABLED_NodeGenericsByValue)
{
@@ -218,7 +220,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValue)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId maxByValueID;
CreateTestNode<MaxReturnByValueNode>(graphUniqueId, maxByValueID);
@@ -227,34 +229,34 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValue)
Core::BehaviorContextObjectNode* valueNode1 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID1);
valueNode1->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->SetValue(1);
EXPECT_EQ(1, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->GetValue());
valueNode1->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(1);
EXPECT_EQ(1, valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode2 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID2);
valueNode2->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->SetValue(2);
EXPECT_EQ(2, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->GetValue());
valueNode2->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(2);
EXPECT_EQ(2, valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode3 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID3);
valueNode3->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->SetValue(3);
EXPECT_EQ(3, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->GetValue());
valueNode3->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(3);
EXPECT_EQ(3, valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode4 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID4);
valueNode4->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->SetValue(4);
EXPECT_EQ(4, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->GetValue());
valueNode4->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(4);
EXPECT_EQ(4, valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode5 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID5);
valueNode5->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->SetValue(5);
EXPECT_EQ(5, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->GetValue());
valueNode5->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(5);
EXPECT_EQ(5, valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
auto value1 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set");
auto value2 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set");
auto value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
auto value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
auto value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
auto value1 = valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value2 = valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
EXPECT_NE(value1, value2);
EXPECT_NE(value1, value3);
@@ -278,11 +280,11 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValue)
EXPECT_TRUE(Connect(*graph, startID, "Out", maxByValueID, "In"));
graph->GetEntity()->Activate();
EXPECT_FALSE(graph->IsInErrorState());
value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
if (value3 && value4 && value5)
{
@@ -307,7 +309,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValue)
m_behaviorContext->DisableRemoveReflection();
}
TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointer)
TEST_F(ScriptCanvasTestFixture, DISABLED_NodeGenericsByPointer)
{
using namespace ScriptCanvas;
using namespace ScriptCanvas::Nodes;
@@ -331,7 +333,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointer)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId maxByValueID;
CreateTestNode<MaxReturnByPointerNode>(graphUniqueId, maxByValueID);
@@ -340,34 +342,34 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointer)
Core::BehaviorContextObjectNode* valueNode1 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID1);
valueNode1->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->SetValue(1);
EXPECT_EQ(1, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->GetValue());
valueNode1->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(1);
EXPECT_EQ(1, valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode2 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID2);
valueNode2->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->SetValue(2);
EXPECT_EQ(2, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->GetValue());
valueNode2->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(2);
EXPECT_EQ(2, valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode3 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID3);
valueNode3->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->SetValue(3);
EXPECT_EQ(3, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->GetValue());
valueNode3->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(3);
EXPECT_EQ(3, valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode4 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID4);
valueNode4->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->SetValue(4);
EXPECT_EQ(4, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->GetValue());
valueNode4->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(4);
EXPECT_EQ(4, valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode5 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID5);
valueNode5->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->SetValue(5);
EXPECT_EQ(5, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->GetValue());
valueNode5->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(5);
EXPECT_EQ(5, valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
auto value1 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set");
auto value2 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set");
auto value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
auto value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
auto value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
auto value1 = valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value2 = valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
EXPECT_NE(value1, value2);
EXPECT_NE(value1, value3);
@@ -391,11 +393,10 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointer)
EXPECT_TRUE(Connect(*graph, startID, "Out", maxByValueID, "In"));
graph->GetEntity()->Activate();
EXPECT_FALSE(graph->IsInErrorState());
value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
if (value3 && value4 && value5)
{
@@ -420,7 +421,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointer)
m_behaviorContext->DisableRemoveReflection();
}
TEST_F(ScriptCanvasTestFixture, NodeGenericsByReference)
TEST_F(ScriptCanvasTestFixture, DISABLED_NodeGenericsByReference)
{
using namespace ScriptCanvas;
using namespace ScriptCanvas::Nodes;
@@ -444,7 +445,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReference)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId maxByValueID;
CreateTestNode<MaxReturnByReferenceNode>(graphUniqueId, maxByValueID);
@@ -453,34 +454,34 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReference)
Core::BehaviorContextObjectNode* valueNode1 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID1);
valueNode1->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->SetValue(1);
EXPECT_EQ(1, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->GetValue());
valueNode1->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(1);
EXPECT_EQ(1, valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode2 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID2);
valueNode2->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->SetValue(2);
EXPECT_EQ(2, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->GetValue());
valueNode2->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(2);
EXPECT_EQ(2, valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode3 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID3);
valueNode3->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->SetValue(3);
EXPECT_EQ(3, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->GetValue());
valueNode3->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(3);
EXPECT_EQ(3, valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode4 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID4);
valueNode4->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->SetValue(4);
EXPECT_EQ(4, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->GetValue());
valueNode4->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(4);
EXPECT_EQ(4, valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode5 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID5);
valueNode5->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->SetValue(5);
EXPECT_EQ(5, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->GetValue());
valueNode5->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(5);
EXPECT_EQ(5, valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
auto value1 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set");
auto value2 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set");
auto value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
auto value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
auto value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
auto value1 = valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value2 = valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
EXPECT_NE(value1, value2);
EXPECT_NE(value1, value3);
@@ -504,11 +505,10 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReference)
EXPECT_TRUE(Connect(*graph, startID, "Out", maxByValueID, "In"));
graph->GetEntity()->Activate();
EXPECT_FALSE(graph->IsInErrorState());
value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
if (value3 && value4 && value5)
{
@@ -533,7 +533,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReference)
m_behaviorContext->DisableRemoveReflection();
}
TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueInteger)
TEST_F(ScriptCanvasTestFixture, DISABLED_NodeGenericsByValueInteger)
{
using namespace ScriptCanvas;
using namespace ScriptCanvas::Nodes;
@@ -557,7 +557,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueInteger)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId maxByValueID;
CreateTestNode<MaxReturnByValueIntegerNode>(graphUniqueId, maxByValueID);
@@ -565,25 +565,25 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueInteger)
AZ::EntityId valueID1, valueID2, valueID3, valueID4, valueID5;
Node* valueNode1 = CreateDataNode<Data::NumberType>(graphUniqueId, 1, valueID1);
EXPECT_EQ(1, *GetInput_UNIT_TEST<Data::NumberType>(valueNode1,"Set"));
EXPECT_EQ(1, *valueNode1->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode2 = CreateDataNode<Data::NumberType>(graphUniqueId, 2, valueID2);
EXPECT_EQ(2, *GetInput_UNIT_TEST<Data::NumberType>(valueNode2,"Set"));
EXPECT_EQ(2, *valueNode2->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode3 = CreateDataNode<Data::NumberType>(graphUniqueId, 3, valueID3);
EXPECT_EQ(3, *GetInput_UNIT_TEST<Data::NumberType>(valueNode3,"Set"));
EXPECT_EQ(3, *valueNode3->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode4 = CreateDataNode<Data::NumberType>(graphUniqueId, 4, valueID4);
EXPECT_EQ(4, *GetInput_UNIT_TEST<Data::NumberType>(valueNode4,"Set"));
EXPECT_EQ(4, *valueNode4->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode5 = CreateDataNode<Data::NumberType>(graphUniqueId, 5, valueID5);
EXPECT_EQ(5, *GetInput_UNIT_TEST<Data::NumberType>(valueNode5,"Set"));
EXPECT_EQ(5, *valueNode5->GetInput_UNIT_TEST<Data::NumberType>("Set"));
auto value1 = GetInput_UNIT_TEST<Data::NumberType>(valueNode1,"Set");
auto value2 = GetInput_UNIT_TEST<Data::NumberType>(valueNode2,"Set");
auto value3 = GetInput_UNIT_TEST<Data::NumberType>(valueNode3,"Set");
auto value4 = GetInput_UNIT_TEST<Data::NumberType>(valueNode4,"Set");
auto value5 = GetInput_UNIT_TEST<Data::NumberType>(valueNode5,"Set");
auto value1 = valueNode1->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value2 = valueNode2->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value3 = valueNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value4 = valueNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value5 = valueNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
EXPECT_NE(value1, value2);
EXPECT_NE(value1, value3);
@@ -607,11 +607,10 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueInteger)
EXPECT_TRUE(Connect(*graph, startID, "Out", maxByValueID, "In"));
graph->GetEntity()->Activate();
EXPECT_FALSE(graph->IsInErrorState());
value3 = GetInput_UNIT_TEST<Data::NumberType>(valueNode3,"Set");
value4 = GetInput_UNIT_TEST<Data::NumberType>(valueNode4,"Set");
value5 = GetInput_UNIT_TEST<Data::NumberType>(valueNode5,"Set");
value3 = valueNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
value4 = valueNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
value5 = valueNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
if (value3 && value4 && value5)
{
@@ -638,7 +637,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueInteger)
m_behaviorContext->DisableRemoveReflection();
}
TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerInteger)
TEST_F(ScriptCanvasTestFixture, DISABLED_NodeGenericsByPointerInteger)
{
@@ -664,7 +663,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerInteger)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId maxByValueID;
CreateTestNode<MaxReturnByPointerIntegerNode>(graphUniqueId, maxByValueID);
@@ -672,25 +671,25 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerInteger)
AZ::EntityId valueID1, valueID2, valueID3, valueID4, valueID5;
Node* valueNode1 = CreateDataNode<Data::NumberType>(graphUniqueId, 1, valueID1);
EXPECT_EQ(1, *GetInput_UNIT_TEST<Data::NumberType>(valueNode1,"Set"));
EXPECT_EQ(1, *valueNode1->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode2 = CreateDataNode<Data::NumberType>(graphUniqueId, 2, valueID2);
EXPECT_EQ(2, *GetInput_UNIT_TEST<Data::NumberType>(valueNode2,"Set"));
EXPECT_EQ(2, *valueNode2->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode3 = CreateDataNode<Data::NumberType>(graphUniqueId, 3, valueID3);
EXPECT_EQ(3, *GetInput_UNIT_TEST<Data::NumberType>(valueNode3,"Set"));
EXPECT_EQ(3, *valueNode3->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode4 = CreateDataNode<Data::NumberType>(graphUniqueId, 4, valueID4);
EXPECT_EQ(4, *GetInput_UNIT_TEST<Data::NumberType>(valueNode4,"Set"));
EXPECT_EQ(4, *valueNode4->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode5 = CreateDataNode<Data::NumberType>(graphUniqueId, 5, valueID5);
EXPECT_EQ(5, *GetInput_UNIT_TEST<Data::NumberType>(valueNode5,"Set"));
EXPECT_EQ(5, *valueNode5->GetInput_UNIT_TEST<Data::NumberType>("Set"));
auto value1 = GetInput_UNIT_TEST<Data::NumberType>(valueNode1,"Set");
auto value2 = GetInput_UNIT_TEST<Data::NumberType>(valueNode2,"Set");
auto value3 = GetInput_UNIT_TEST<Data::NumberType>(valueNode3,"Set");
auto value4 = GetInput_UNIT_TEST<Data::NumberType>(valueNode4,"Set");
auto value5 = GetInput_UNIT_TEST<Data::NumberType>(valueNode5,"Set");
auto value1 = valueNode1->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value2 = valueNode2->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value3 = valueNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value4 = valueNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value5 = valueNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
EXPECT_NE(value1, value2);
EXPECT_NE(value1, value3);
@@ -714,11 +713,10 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerInteger)
EXPECT_TRUE(Connect(*graph, startID, "Out", maxByValueID, "In"));
graph->GetEntity()->Activate();
EXPECT_FALSE(graph->IsInErrorState());
value3 = GetInput_UNIT_TEST<Data::NumberType>(valueNode3,"Set");
value4 = GetInput_UNIT_TEST<Data::NumberType>(valueNode4,"Set");
value5 = GetInput_UNIT_TEST<Data::NumberType>(valueNode5,"Set");
value3 = valueNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
value4 = valueNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
value5 = valueNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
if (value3 && value4 && value5)
{
@@ -745,7 +743,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerInteger)
m_behaviorContext->DisableRemoveReflection();
}
TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceInteger)
TEST_F(ScriptCanvasTestFixture, DISABLED_NodeGenericsByReferenceInteger)
{
using namespace ScriptCanvas;
using namespace ScriptCanvas::Nodes;
@@ -769,7 +767,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceInteger)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId maxByValueID;
CreateTestNode<MaxReturnByReferenceIntegerNode>(graphUniqueId, maxByValueID);
@@ -777,25 +775,25 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceInteger)
AZ::EntityId valueID1, valueID2, valueID3, valueID4, valueID5;
Node* valueNode1 = CreateDataNode<Data::NumberType>(graphUniqueId, 1, valueID1);
EXPECT_EQ(1, *GetInput_UNIT_TEST<Data::NumberType>(valueNode1,"Set"));
EXPECT_EQ(1, *valueNode1->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode2 = CreateDataNode<Data::NumberType>(graphUniqueId, 2, valueID2);
EXPECT_EQ(2, *GetInput_UNIT_TEST<Data::NumberType>(valueNode2,"Set"));
EXPECT_EQ(2, *valueNode2->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode3 = CreateDataNode<Data::NumberType>(graphUniqueId, 3, valueID3);
EXPECT_EQ(3, *GetInput_UNIT_TEST<Data::NumberType>(valueNode3,"Set"));
EXPECT_EQ(3, *valueNode3->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode4 = CreateDataNode<Data::NumberType>(graphUniqueId, 4, valueID4);
EXPECT_EQ(4, *GetInput_UNIT_TEST<Data::NumberType>(valueNode4,"Set"));
EXPECT_EQ(4, *valueNode4->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueNode5 = CreateDataNode<Data::NumberType>(graphUniqueId, 5, valueID5);
EXPECT_EQ(5, *GetInput_UNIT_TEST<Data::NumberType>(valueNode5,"Set"));
EXPECT_EQ(5, *valueNode5->GetInput_UNIT_TEST<Data::NumberType>("Set"));
auto value1 = GetInput_UNIT_TEST<Data::NumberType>(valueNode1,"Set");
auto value2 = GetInput_UNIT_TEST<Data::NumberType>(valueNode2,"Set");
auto value3 = GetInput_UNIT_TEST<Data::NumberType>(valueNode3,"Set");
auto value4 = GetInput_UNIT_TEST<Data::NumberType>(valueNode4,"Set");
auto value5 = GetInput_UNIT_TEST<Data::NumberType>(valueNode5,"Set");
auto value1 = valueNode1->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value2 = valueNode2->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value3 = valueNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value4 = valueNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto value5 = valueNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
EXPECT_NE(value1, value2);
EXPECT_NE(value1, value3);
@@ -819,11 +817,10 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceInteger)
EXPECT_TRUE(Connect(*graph, startID, "Out", maxByValueID, "In"));
graph->GetEntity()->Activate();
EXPECT_FALSE(graph->IsInErrorState());
value3 = GetInput_UNIT_TEST<Data::NumberType>(valueNode3,"Set");
value4 = GetInput_UNIT_TEST<Data::NumberType>(valueNode4,"Set");
value5 = GetInput_UNIT_TEST<Data::NumberType>(valueNode5,"Set");
value3 = valueNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
value4 = valueNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
value5 = valueNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
if (value3 && value4 && value5)
{
@@ -850,7 +847,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceInteger)
m_behaviorContext->DisableRemoveReflection();
}
TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueMulti)
TEST_F(ScriptCanvasTestFixture, DISABLED_NodeGenericsByValueMulti)
{
using namespace ScriptCanvas;
using namespace ScriptCanvas::Nodes;
@@ -874,7 +871,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueMulti)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId maxByValueID;
CreateTestNode<MaxReturnByValueMultiNode>(graphUniqueId, maxByValueID);
@@ -882,34 +879,34 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueMulti)
Core::BehaviorContextObjectNode* valueNode1 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID1);
valueNode1->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->SetValue(1);
EXPECT_EQ(1, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->GetValue());
valueNode1->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(1);
EXPECT_EQ(1, valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode2 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID2);
valueNode2->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->SetValue(2);
EXPECT_EQ(2, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->GetValue());
valueNode2->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(2);
EXPECT_EQ(2, valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode3 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID3);
valueNode3->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->SetValue(3);
EXPECT_EQ(3, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->GetValue());
valueNode3->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(3);
EXPECT_EQ(3, valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode4 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID4);
valueNode4->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->SetValue(4);
EXPECT_EQ(4, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->GetValue());
valueNode4->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(4);
EXPECT_EQ(4, valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode5 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID5);
valueNode5->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->SetValue(5);
EXPECT_EQ(5, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->GetValue());
valueNode5->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(5);
EXPECT_EQ(5, valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
auto value1 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set");
auto value2 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set");
auto value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
auto value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
auto value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
auto value1 = valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value2 = valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
EXPECT_NE(value1, value2);
EXPECT_NE(value1, value3);
@@ -925,25 +922,25 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueMulti)
AZ::EntityId valueIntegerID1, valueIntegerID2, valueIntegerID3, valueIntegerID4, valueIntegerID5;
Node* valueIntegerNode1 = CreateDataNode<Data::NumberType>(graphUniqueId, 1, valueIntegerID1);
EXPECT_EQ(1, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode1,"Set"));
EXPECT_EQ(1, *valueIntegerNode1->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode2 = CreateDataNode<Data::NumberType>(graphUniqueId, 2, valueIntegerID2);
EXPECT_EQ(2, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode2,"Set"));
EXPECT_EQ(2, *valueIntegerNode2->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode3 = CreateDataNode<Data::NumberType>(graphUniqueId, 3, valueIntegerID3);
EXPECT_EQ(3, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode3,"Set"));
EXPECT_EQ(3, *valueIntegerNode3->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode4 = CreateDataNode<Data::NumberType>(graphUniqueId, 4, valueIntegerID4);
EXPECT_EQ(4, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode4,"Set"));
EXPECT_EQ(4, *valueIntegerNode4->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode5 = CreateDataNode<Data::NumberType>(graphUniqueId, 5, valueIntegerID5);
EXPECT_EQ(5, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode5,"Set"));
EXPECT_EQ(5, *valueIntegerNode5->GetInput_UNIT_TEST<Data::NumberType>("Set"));
auto valueInteger1 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode1,"Set");
auto valueInteger2 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode2,"Set");
auto valueInteger3 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode3,"Set");
auto valueInteger4 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode4,"Set");
auto valueInteger5 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode5,"Set");
auto valueInteger1 = valueIntegerNode1->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger2 = valueIntegerNode2->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger3 = valueIntegerNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger4 = valueIntegerNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger5 = valueIntegerNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
EXPECT_NE(valueInteger1, valueInteger2);
EXPECT_NE(valueInteger1, valueInteger3);
@@ -973,11 +970,10 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueMulti)
EXPECT_TRUE(Connect(*graph, startID, "Out", maxByValueID, "In"));
graph->GetEntity()->Activate();
EXPECT_FALSE(graph->IsInErrorState());
valueInteger3 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode3,"Set");
valueInteger4 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode4,"Set");
valueInteger5 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode5,"Set");
valueInteger3 = valueIntegerNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
valueInteger4 = valueIntegerNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
valueInteger5 = valueIntegerNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
if (valueInteger3 && valueInteger4 && valueInteger5)
{
@@ -994,9 +990,9 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueMulti)
ADD_FAILURE() << "Values were nullptr";
}
value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
if (value3 && value4 && value5)
{
@@ -1021,7 +1017,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByValueMulti)
m_behaviorContext->DisableRemoveReflection();
}
TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceMulti)
TEST_F(ScriptCanvasTestFixture, DISABLED_NodeGenericsByReferenceMulti)
{
using namespace ScriptCanvas;
using namespace ScriptCanvas::Nodes;
@@ -1045,7 +1041,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceMulti)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId maxByReferenceID;
CreateTestNode<MaxReturnByReferenceMultiNode>(graphUniqueId, maxByReferenceID);
@@ -1053,34 +1049,34 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceMulti)
Core::BehaviorContextObjectNode* valueNode1 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID1);
valueNode1->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->SetValue(1);
EXPECT_EQ(1, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->GetValue());
valueNode1->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(1);
EXPECT_EQ(1, valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode2 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID2);
valueNode2->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->SetValue(2);
EXPECT_EQ(2, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->GetValue());
valueNode2->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(2);
EXPECT_EQ(2, valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode3 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID3);
valueNode3->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->SetValue(3);
EXPECT_EQ(3, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->GetValue());
valueNode3->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(3);
EXPECT_EQ(3, valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode4 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID4);
valueNode4->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->SetValue(4);
EXPECT_EQ(4, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->GetValue());
valueNode4->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(4);
EXPECT_EQ(4, valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode5 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID5);
valueNode5->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->SetValue(5);
EXPECT_EQ(5, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->GetValue());
valueNode5->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(5);
EXPECT_EQ(5, valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
auto value1 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set");
auto value2 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set");
auto value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
auto value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
auto value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
auto value1 = valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value2 = valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
EXPECT_NE(value1, value2);
EXPECT_NE(value1, value3);
@@ -1096,25 +1092,25 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceMulti)
AZ::EntityId valueIntegerID1, valueIntegerID2, valueIntegerID3, valueIntegerID4, valueIntegerID5;
Node* valueIntegerNode1 = CreateDataNode<Data::NumberType>(graphUniqueId, 1, valueIntegerID1);
EXPECT_EQ(1, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode1,"Set"));
EXPECT_EQ(1, *valueIntegerNode1->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode2 = CreateDataNode<Data::NumberType>(graphUniqueId, 2, valueIntegerID2);
EXPECT_EQ(2, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode2,"Set"));
EXPECT_EQ(2, *valueIntegerNode2->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode3 = CreateDataNode<Data::NumberType>(graphUniqueId, 3, valueIntegerID3);
EXPECT_EQ(3, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode3,"Set"));
EXPECT_EQ(3, *valueIntegerNode3->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode4 = CreateDataNode<Data::NumberType>(graphUniqueId, 4, valueIntegerID4);
EXPECT_EQ(4, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode4,"Set"));
EXPECT_EQ(4, *valueIntegerNode4->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode5 = CreateDataNode<Data::NumberType>(graphUniqueId, 5, valueIntegerID5);
EXPECT_EQ(5, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode5,"Set"));
EXPECT_EQ(5, *valueIntegerNode5->GetInput_UNIT_TEST<Data::NumberType>("Set"));
auto valueInteger1 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode1,"Set");
auto valueInteger2 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode2,"Set");
auto valueInteger3 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode3,"Set");
auto valueInteger4 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode4,"Set");
auto valueInteger5 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode5,"Set");
auto valueInteger1 = valueIntegerNode1->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger2 = valueIntegerNode2->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger3 = valueIntegerNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger4 = valueIntegerNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger5 = valueIntegerNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
EXPECT_NE(valueInteger1, valueInteger2);
EXPECT_NE(valueInteger1, valueInteger3);
@@ -1144,11 +1140,10 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceMulti)
EXPECT_TRUE(Connect(*graph, startID, "Out", maxByReferenceID, "In"));
graph->GetEntity()->Activate();
EXPECT_FALSE(graph->IsInErrorState());
valueInteger3 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode3,"Set");
valueInteger4 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode4,"Set");
valueInteger5 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode5,"Set");
valueInteger3 = valueIntegerNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
valueInteger4 = valueIntegerNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
valueInteger5 = valueIntegerNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
if (valueInteger3 && valueInteger4 && valueInteger5)
{
@@ -1165,9 +1160,9 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceMulti)
ADD_FAILURE() << "Values were nullptr";
}
value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
if (value3 && value4 && value5)
{
@@ -1192,7 +1187,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByReferenceMulti)
m_behaviorContext->DisableRemoveReflection();
}
TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerMulti)
TEST_F(ScriptCanvasTestFixture, DISABLED_NodeGenericsByPointerMulti)
{
using namespace ScriptCanvas;
using namespace ScriptCanvas::Nodes;
@@ -1216,7 +1211,7 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerMulti)
const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
AZ::EntityId startID;
CreateTestNode<Nodes::Core::Start>(graphUniqueId, startID);
CreateTestNode<ScriptCanvas::Nodes::Core::Start>(graphUniqueId, startID);
AZ::EntityId maxByPointerID;
CreateTestNode<MaxReturnByPointerMultiNode>(graphUniqueId, maxByPointerID);
@@ -1224,34 +1219,34 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerMulti)
Core::BehaviorContextObjectNode* valueNode1 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID1);
valueNode1->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->SetValue(1);
EXPECT_EQ(1, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set")->GetValue());
valueNode1->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(1);
EXPECT_EQ(1, valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode2 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID2);
valueNode2->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->SetValue(2);
EXPECT_EQ(2, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set")->GetValue());
valueNode2->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(2);
EXPECT_EQ(2, valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode3 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID3);
valueNode3->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->SetValue(3);
EXPECT_EQ(3, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set")->GetValue());
valueNode3->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(3);
EXPECT_EQ(3, valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode4 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID4);
valueNode4->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->SetValue(4);
EXPECT_EQ(4, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set")->GetValue());
valueNode4->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(4);
EXPECT_EQ(4, valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
Core::BehaviorContextObjectNode* valueNode5 = CreateTestNode<Core::BehaviorContextObjectNode>(graphUniqueId, valueID5);
valueNode5->InitializeObject(azrtti_typeid<TestBehaviorContextObject>());
ModInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->SetValue(5);
EXPECT_EQ(5, GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set")->GetValue());
valueNode5->ModInput_UNIT_TEST<TestBehaviorContextObject>("Set")->SetValue(5);
EXPECT_EQ(5, valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set")->GetValue());
auto value1 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode1,"Set");
auto value2 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode2,"Set");
auto value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
auto value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
auto value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
auto value1 = valueNode1->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value2 = valueNode2->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
auto value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
EXPECT_NE(value1, value2);
EXPECT_NE(value1, value3);
@@ -1267,25 +1262,25 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerMulti)
AZ::EntityId valueIntegerID1, valueIntegerID2, valueIntegerID3, valueIntegerID4, valueIntegerID5;
Node* valueIntegerNode1 = CreateDataNode<Data::NumberType>(graphUniqueId, 1, valueIntegerID1);
EXPECT_EQ(1, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode1,"Set"));
EXPECT_EQ(1, *valueIntegerNode1->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode2 = CreateDataNode<Data::NumberType>(graphUniqueId, 2, valueIntegerID2);
EXPECT_EQ(2, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode2,"Set"));
EXPECT_EQ(2, *valueIntegerNode2->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode3 = CreateDataNode<Data::NumberType>(graphUniqueId, 3, valueIntegerID3);
EXPECT_EQ(3, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode3,"Set"));
EXPECT_EQ(3, *valueIntegerNode3->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode4 = CreateDataNode<Data::NumberType>(graphUniqueId, 4, valueIntegerID4);
EXPECT_EQ(4, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode4,"Set"));
EXPECT_EQ(4, *valueIntegerNode4->GetInput_UNIT_TEST<Data::NumberType>("Set"));
Node* valueIntegerNode5 = CreateDataNode<Data::NumberType>(graphUniqueId, 5, valueIntegerID5);
EXPECT_EQ(5, *GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode5,"Set"));
EXPECT_EQ(5, *valueIntegerNode5->GetInput_UNIT_TEST<Data::NumberType>("Set"));
auto valueInteger1 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode1,"Set");
auto valueInteger2 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode2,"Set");
auto valueInteger3 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode3,"Set");
auto valueInteger4 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode4,"Set");
auto valueInteger5 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode5,"Set");
auto valueInteger1 = valueIntegerNode1->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger2 = valueIntegerNode2->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger3 = valueIntegerNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger4 = valueIntegerNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
auto valueInteger5 = valueIntegerNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
EXPECT_NE(valueInteger1, valueInteger2);
EXPECT_NE(valueInteger1, valueInteger3);
@@ -1315,11 +1310,10 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerMulti)
EXPECT_TRUE(Connect(*graph, startID, "Out", maxByPointerID, "In"));
graph->GetEntity()->Activate();
EXPECT_FALSE(graph->IsInErrorState());
valueInteger3 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode3,"Set");
valueInteger4 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode4,"Set");
valueInteger5 = GetInput_UNIT_TEST<Data::NumberType>(valueIntegerNode5,"Set");
valueInteger3 = valueIntegerNode3->GetInput_UNIT_TEST<Data::NumberType>("Set");
valueInteger4 = valueIntegerNode4->GetInput_UNIT_TEST<Data::NumberType>("Set");
valueInteger5 = valueIntegerNode5->GetInput_UNIT_TEST<Data::NumberType>("Set");
if (valueInteger3 && valueInteger4 && valueInteger5)
{
@@ -1336,9 +1330,9 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerMulti)
ADD_FAILURE() << "Values were nullptr";
}
value3 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode3,"Set");
value4 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode4,"Set");
value5 = GetInput_UNIT_TEST<TestBehaviorContextObject>(valueNode5,"Set");
value3 = valueNode3->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value4 = valueNode4->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
value5 = valueNode5->GetInput_UNIT_TEST<TestBehaviorContextObject>("Set");
if (value3 && value4 && value5)
{
@@ -1363,3 +1357,4 @@ TEST_F(ScriptCanvasTestFixture, NodeGenericsByPointerMulti)
m_behaviorContext->DisableRemoveReflection();
}
#pragma warning( pop )
@@ -1,57 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affililates or
* its licensors.
*
* For complete copyright EntityRef license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <Source/Framework/ScriptCanvasTestFixture.h>
#include <Source/Framework/ScriptCanvasTestUtilities.h>
using namespace ScriptCanvasTests;
using namespace ScriptCanvas;
TEST_F(ScriptCanvasTestFixture, OutcomeFailureVE)
{
RunUnitTestGraph("LY_SC_UnitTest_OutcomeFailureVE");
}
TEST_F(ScriptCanvasTestFixture, OutcomeFailureV)
{
RunUnitTestGraph("LY_SC_UnitTest_OutcomeFailureV");
}
TEST_F(ScriptCanvasTestFixture, OutcomeFailureE)
{
RunUnitTestGraph("LY_SC_UnitTest_OutcomeFailureE");
}
TEST_F(ScriptCanvasTestFixture, OutcomeFailure)
{
RunUnitTestGraph("LY_SC_UnitTest_OutcomeFailure");
}
TEST_F(ScriptCanvasTestFixture, OutcomeSuccessVE)
{
RunUnitTestGraph("LY_SC_UnitTest_OutcomeSuccessVE");
}
TEST_F(ScriptCanvasTestFixture, OutcomeSuccessV)
{
RunUnitTestGraph("LY_SC_UnitTest_OutcomeSuccessV");
}
TEST_F(ScriptCanvasTestFixture, OutcomeSuccessE)
{
RunUnitTestGraph("LY_SC_UnitTest_OutcomeSuccessE");
}
TEST_F(ScriptCanvasTestFixture, OutcomeSuccess)
{
RunUnitTestGraph("LY_SC_UnitTest_OutcomeSuccess");
}
@@ -15,8 +15,3 @@
using namespace ScriptCanvasTests;
TEST_F(ScriptCanvasTestFixture, Regression_LY_79396)
{
// Enable when BE2.0 goes to main
//RunUnitTestGraph("LY_SC_UnitTest_LY_79396");
}
File diff suppressed because it is too large Load Diff
@@ -278,7 +278,7 @@ TEST_F(ScriptCanvasTestFixture, SlotConnecting_ExecutionBasic)
{
using namespace ScriptCanvas;
Graph* graph = CreateGraph();
ScriptCanvas::Graph* graph = CreateGraph();
ConfigurableUnitTestNode* inputNode = CreateConfigurableNode();
ConfigurableUnitTestNode* outputNode = CreateConfigurableNode();
@@ -298,7 +298,7 @@ TEST_F(ScriptCanvasTestFixture, SlotConnecting_ExecutionFailure)
const bool invalidConnection = false;
Graph* graph = CreateGraph();
ScriptCanvas::Graph* graph = CreateGraph();
ConfigurableUnitTestNode* inputNode = CreateConfigurableNode();
ConfigurableUnitTestNode* outputNode = CreateConfigurableNode();
@@ -424,7 +424,7 @@ TEST_F(ScriptCanvasTestFixture, SlotConnecting_DataBasic)
{
using namespace ScriptCanvas;
Graph* graph = CreateGraph();
ScriptCanvas::Graph* graph = CreateGraph();
ConfigurableUnitTestNode* inputNode = CreateConfigurableNode();
ConfigurableUnitTestNode* outputNode = CreateConfigurableNode();
@@ -460,148 +460,152 @@ TEST_F(ScriptCanvasTestFixture, SlotConnecting_DataBasic)
}
// Exhaustive Data Connection Test(attempts to connect every data type to every other data type, in both input and output)
TEST_F(ScriptCanvasTestFixture, SlotConnecting_DataExhaustive)
{
using namespace ScriptCanvas;
Graph* graph = CreateGraph();
ConfigurableUnitTestNode* inputNode = CreateConfigurableNode();
ConfigurableUnitTestNode* outputNode = CreateConfigurableNode();
//
// TEST_F(ScriptCanvasTestFixture, SlotConnecting_DataExhaustive)
// {
// using namespace ScriptCanvas;
//
// ScriptCanvas::Graph* graph = CreateGraph();
// ConfigurableUnitTestNode* inputNode = CreateConfigurableNode();
// ConfigurableUnitTestNode* outputNode = CreateConfigurableNode();
//
// Endpoint dynamicAnyInEndpoint;
// Endpoint dynamicAnyOutEndpoint;
//
// Endpoint dynamicContainerInEndpoint;
// Endpoint dynamicContainerOutEndpoint;
//
// Endpoint dynamicValueInEndpoint;
// Endpoint dynamicValueOutEndpoint;
//
// AZStd::unordered_map< Data::Type, ScriptCanvas::Endpoint > inputTypeMapping;
//
// {
// DynamicDataSlotConfiguration slotConfiguration;
//
// slotConfiguration.m_name = GenerateSlotName();
// slotConfiguration.SetConnectionType(ConnectionType::Input);
// slotConfiguration.m_dynamicDataType = DynamicDataType::Any;
//
// Slot* dynamicAnyInSlot = inputNode->AddTestingSlot(slotConfiguration);
//
// dynamicAnyInEndpoint = Endpoint(inputNode->GetEntityId(), dynamicAnyInSlot->GetId());
// }
//
// {
// DynamicDataSlotConfiguration slotConfiguration;
//
// slotConfiguration.m_name = GenerateSlotName();
// slotConfiguration.SetConnectionType(ConnectionType::Output);
// slotConfiguration.m_dynamicDataType = DynamicDataType::Any;
//
// Slot* dynamicAnyOutSlot = outputNode->AddTestingSlot(slotConfiguration);
//
// dynamicAnyOutEndpoint = Endpoint(outputNode->GetEntityId(), dynamicAnyOutSlot->GetId());
// }
//
// {
// DynamicDataSlotConfiguration slotConfiguration;
//
// slotConfiguration.m_name = GenerateSlotName();
// slotConfiguration.SetConnectionType(ConnectionType::Input);
// slotConfiguration.m_dynamicDataType = DynamicDataType::Container;
//
// Slot* dynamicContainerInSlot = inputNode->AddTestingSlot(slotConfiguration);
//
// dynamicContainerInEndpoint = Endpoint(inputNode->GetEntityId(), dynamicContainerInSlot->GetId());
// }
//
// {
// DynamicDataSlotConfiguration slotConfiguration;
//
// slotConfiguration.m_name = GenerateSlotName();
// slotConfiguration.SetConnectionType(ConnectionType::Output);
// slotConfiguration.m_dynamicDataType = DynamicDataType::Container;
//
// Slot* dynamicContainerOutSlot = outputNode->AddTestingSlot(slotConfiguration);
//
// dynamicContainerOutEndpoint = Endpoint(outputNode->GetEntityId(), dynamicContainerOutSlot->GetId());
// }
//
// {
// DynamicDataSlotConfiguration slotConfiguration;
//
// slotConfiguration.m_name = GenerateSlotName();
// slotConfiguration.SetConnectionType(ConnectionType::Input);
// slotConfiguration.m_dynamicDataType = DynamicDataType::Value;
//
// Slot* dynamicValueInSlot = inputNode->AddTestingSlot(slotConfiguration);
//
// dynamicValueInEndpoint = Endpoint(inputNode->GetEntityId(), dynamicValueInSlot->GetId());
// }
//
// {
// DynamicDataSlotConfiguration slotConfiguration;
//
// slotConfiguration.m_name = GenerateSlotName();
// slotConfiguration.SetConnectionType(ConnectionType::Output);
// slotConfiguration.m_dynamicDataType = DynamicDataType::Value;
//
// Slot* dynamicValueOutSlot = outputNode->AddTestingSlot(slotConfiguration);
//
// dynamicValueOutEndpoint = Endpoint(outputNode->GetEntityId(), dynamicValueOutSlot->GetId());
// }
//
// for (auto type : GetTypes())
// {
// DataSlotConfiguration slotConfiguration;
//
// slotConfiguration.m_name = GenerateSlotName();
// slotConfiguration.SetType(type);
// slotConfiguration.SetConnectionType(ConnectionType::Input);
//
// Slot* newSlot = inputNode->AddTestingSlot(slotConfiguration);
//
// Endpoint inputEndpoint = Endpoint(inputNode->GetEntityId(), newSlot->GetId());
// inputTypeMapping[type] = inputEndpoint;
//
// const bool validConnection = true;
// TestIsConnectionPossible(dynamicAnyOutEndpoint, inputEndpoint, validConnection);
//
// bool isContainerType = Data::IsContainerType(type);
//
// TestIsConnectionPossible(dynamicContainerOutEndpoint, inputEndpoint, isContainerType);
// TestIsConnectionPossible(dynamicValueOutEndpoint, inputEndpoint, !isContainerType);
// }
//
// for (auto type : GetTypes())
// {
// DataSlotConfiguration slotConfiguration;
//
// slotConfiguration.m_name = GenerateSlotName();
// slotConfiguration.SetType(type);
// slotConfiguration.SetConnectionType(ConnectionType::Output);
//
// Slot* outputSlot = outputNode->AddTestingSlot(slotConfiguration);
//
// ScriptCanvas::Endpoint outputEndpoint(outputNode->GetEntityId(), outputSlot->GetId());
//
// const bool validConnection = true;
// TestIsConnectionPossible(outputEndpoint, dynamicAnyInEndpoint, validConnection);
//
// bool isContainerType = Data::IsContainerType(type);
//
// TestIsConnectionPossible(outputEndpoint, dynamicContainerInEndpoint, isContainerType);
// TestIsConnectionPossible(outputEndpoint, dynamicValueInEndpoint, !isContainerType);
//
// for (auto slotPair : inputTypeMapping)
// {
// bool isSameType = slotPair.first == type;
//
// TestIsConnectionPossible(outputEndpoint, slotPair.second, isSameType);
// }
// }
// }
Endpoint dynamicAnyInEndpoint;
Endpoint dynamicAnyOutEndpoint;
Endpoint dynamicContainerInEndpoint;
Endpoint dynamicContainerOutEndpoint;
Endpoint dynamicValueInEndpoint;
Endpoint dynamicValueOutEndpoint;
AZStd::unordered_map< Data::Type, ScriptCanvas::Endpoint > inputTypeMapping;
{
DynamicDataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetConnectionType(ConnectionType::Input);
slotConfiguration.m_dynamicDataType = DynamicDataType::Any;
Slot* dynamicAnyInSlot = inputNode->AddTestingSlot(slotConfiguration);
dynamicAnyInEndpoint = Endpoint(inputNode->GetEntityId(), dynamicAnyInSlot->GetId());
}
{
DynamicDataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetConnectionType(ConnectionType::Output);
slotConfiguration.m_dynamicDataType = DynamicDataType::Any;
Slot* dynamicAnyOutSlot = outputNode->AddTestingSlot(slotConfiguration);
dynamicAnyOutEndpoint = Endpoint(outputNode->GetEntityId(), dynamicAnyOutSlot->GetId());
}
{
DynamicDataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetConnectionType(ConnectionType::Input);
slotConfiguration.m_dynamicDataType = DynamicDataType::Container;
Slot* dynamicContainerInSlot = inputNode->AddTestingSlot(slotConfiguration);
dynamicContainerInEndpoint = Endpoint(inputNode->GetEntityId(), dynamicContainerInSlot->GetId());
}
{
DynamicDataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetConnectionType(ConnectionType::Output);
slotConfiguration.m_dynamicDataType = DynamicDataType::Container;
Slot* dynamicContainerOutSlot = outputNode->AddTestingSlot(slotConfiguration);
dynamicContainerOutEndpoint = Endpoint(outputNode->GetEntityId(), dynamicContainerOutSlot->GetId());
}
{
DynamicDataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetConnectionType(ConnectionType::Input);
slotConfiguration.m_dynamicDataType = DynamicDataType::Value;
Slot* dynamicValueInSlot = inputNode->AddTestingSlot(slotConfiguration);
dynamicValueInEndpoint = Endpoint(inputNode->GetEntityId(), dynamicValueInSlot->GetId());
}
{
DynamicDataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetConnectionType(ConnectionType::Output);
slotConfiguration.m_dynamicDataType = DynamicDataType::Value;
Slot* dynamicValueOutSlot = outputNode->AddTestingSlot(slotConfiguration);
dynamicValueOutEndpoint = Endpoint(outputNode->GetEntityId(), dynamicValueOutSlot->GetId());
}
for (auto type : GetTypes())
{
DataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetType(type);
slotConfiguration.SetConnectionType(ConnectionType::Input);
Slot* newSlot = inputNode->AddTestingSlot(slotConfiguration);
Endpoint inputEndpoint = Endpoint(inputNode->GetEntityId(), newSlot->GetId());
inputTypeMapping[type] = inputEndpoint;
const bool validConnection = true;
TestIsConnectionPossible(dynamicAnyOutEndpoint, inputEndpoint, validConnection);
bool isContainerType = Data::IsContainerType(type);
TestIsConnectionPossible(dynamicContainerOutEndpoint, inputEndpoint, isContainerType);
TestIsConnectionPossible(dynamicValueOutEndpoint, inputEndpoint, !isContainerType);
}
for (auto type : GetTypes())
{
DataSlotConfiguration slotConfiguration;
slotConfiguration.m_name = GenerateSlotName();
slotConfiguration.SetType(type);
slotConfiguration.SetConnectionType(ConnectionType::Output);
Slot* outputSlot = outputNode->AddTestingSlot(slotConfiguration);
ScriptCanvas::Endpoint outputEndpoint(outputNode->GetEntityId(), outputSlot->GetId());
const bool validConnection = true;
TestIsConnectionPossible(outputEndpoint, dynamicAnyInEndpoint, validConnection);
bool isContainerType = Data::IsContainerType(type);
TestIsConnectionPossible(outputEndpoint, dynamicContainerInEndpoint, isContainerType);
TestIsConnectionPossible(outputEndpoint, dynamicValueInEndpoint, !isContainerType);
for (auto slotPair : inputTypeMapping)
{
bool isSameType = slotPair.first == type;
TestIsConnectionPossible(outputEndpoint, slotPair.second, isSameType);
}
}
}
/*
TEST_F(ScriptCanvasTestFixture, TypeMatching_NumericType)
{
using namespace ScriptCanvas;
@@ -1924,7 +1928,7 @@ TEST_F(ScriptCanvasTestFixture, SlotGrouping_BasicFunctionalitySanityTest)
{
using namespace ScriptCanvas;
Graph* graph = CreateGraph();
ScriptCanvas::Graph* graph = CreateGraph();
ConfigurableUnitTestNode* inputNode = CreateConfigurableNode();
Slot* dynamicInputSlot = nullptr;
@@ -1978,7 +1982,7 @@ TEST_F(ScriptCanvasTestFixture, SlotGrouping_SingleGroupDisplayTypeConnection)
{
using namespace ScriptCanvas;
Graph* graph = CreateGraph();
ScriptCanvas::Graph* graph = CreateGraph();
ConfigurableUnitTestNode* groupedNode = CreateConfigurableNode();
Slot* dynamicInputSlot = nullptr;
@@ -2097,7 +2101,7 @@ TEST_F(ScriptCanvasTestFixture, SlotGrouping_SingleGroupDisplayTypeConnection)
TEST_F(ScriptCanvasTestFixture, SlotGrouping_MultiGroupDisplayTypeConnection)
{
using namespace ScriptCanvas;
Graph* graph = CreateGraph();
ScriptCanvas::Graph* graph = CreateGraph();
ConfigurableUnitTestNode* groupedNode = CreateConfigurableNode();
Slot* dynamicInputSlot = nullptr;
@@ -2268,7 +2272,7 @@ TEST_F(ScriptCanvasTestFixture, SlotGrouping_SingleGroupDisplayTypeRestriction)
{
using namespace ScriptCanvas;
Graph* graph = CreateGraph();
ScriptCanvas::Graph* graph = CreateGraph();
ConfigurableUnitTestNode* groupedNode = CreateConfigurableNode();
Slot* restrictedInputSlot = nullptr;
@@ -2332,7 +2336,7 @@ TEST_F(ScriptCanvasTestFixture, SlotGrouping_SingleGroupDisplayTypeRestrictionCo
{
using namespace ScriptCanvas;
Graph* graph = CreateGraph();
ScriptCanvas::Graph* graph = CreateGraph();
ConfigurableUnitTestNode* groupedNode = CreateConfigurableNode();
Slot* restrictedInputSlot = nullptr;
@@ -2436,7 +2440,7 @@ TEST_F(ScriptCanvasTestFixture, SlotGrouping_MultiGroupDisplayTypeRestrictionCon
AZ::Crc32 firstGroupName = AZ::Crc32("FirstGroupName");
AZ::Crc32 secondGroupName = AZ::Crc32("SecondGroupName");
Graph* graph = CreateGraph();
ScriptCanvas::Graph* graph = CreateGraph();
ConfigurableUnitTestNode* groupedUnrestrictedNode = CreateConfigurableNode();
@@ -2596,3 +2600,4 @@ TEST_F(ScriptCanvasTestFixture, DynamicSlot_DisplayTypeDatum)
EXPECT_EQ(dataType == randomType, sourceDatum->IS_A(dataType));
}
}
*/
@@ -10,18 +10,13 @@
*
*/
#include <Source/Framework/ScriptCanvasTestFixture.h>
#include <Source/Framework/ScriptCanvasTestUtilities.h>
#include <AzCore/ScriptCanvas/ScriptCanvasAttributes.h>
#include <AzCore/RTTI/AttributeReader.h>
using namespace ScriptCanvasTests;
using namespace ScriptCanvas;
TEST_F(ScriptCanvasTestFixture, StringNodes)
{
// Disabled until BE2.0 goes into main
//RunUnitTestGraph("LY_SC_UnitTest_StringNodes");
RunUnitTestGraph("LY_SC_UnitTest_StringNodes", ExecutionMode::Interpreted);
}
@@ -10,8 +10,6 @@
*
*/
#include <AzCore/Serialization/IdUtils.h>
#include <ScriptCanvas/Asset/RuntimeAsset.h>
#include <ScriptCanvas/Asset/RuntimeAssetHandler.h>
@@ -22,6 +20,10 @@
#include <Source/Framework/ScriptCanvasTestUtilities.h>
#include <Editor/Framework/ScriptCanvasReporter.h>
#if 0
using namespace ScriptCanvasEditor;
#define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_EQ(LHS, RHS)\
@@ -60,6 +62,19 @@ using namespace ScriptCanvasEditor;
else\
++m_countLEFailed;
#define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_GT(LHS, RHS)\
if((LHS.IsGreaterThan(RHS))) ++m_countGTSucceeded; else ++m_countGTFailed;
#define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_GE(LHS, RHS)\
if((LHS.IsGreaterEqualThan(RHS))) ++m_countGESucceeded; else ++m_countGEFailed;
#define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_LT(LHS, RHS)\
if((LHS.IsLessThan(RHS))) ++m_countLTSucceeded; else ++m_countLTFailed;
#define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_LE(LHS, RHS)\
if((LHS.IsLessEqualThan(RHS))) ++m_countLTSucceeded; else ++m_countLTFailed;
namespace ScriptCanvas_UnitTestingCPP
{
const double k_tolerance = 0.01;
@@ -152,7 +167,7 @@ bool MetaReporter::operator==(const MetaReporter& other) const
}
// Handler
void MetaReporter::ExpectFalse(const bool value, [[maybe_unused]] const Report& report)
void MetaReporter::ExpectFalse(const bool value, const Report&)
{
if (!value)
++m_countFalseSucceeded;
@@ -160,7 +175,7 @@ void MetaReporter::ExpectFalse(const bool value, [[maybe_unused]] const Report&
++m_countFalseFailed;
}
void MetaReporter::ExpectTrue(const bool value, [[maybe_unused]] const Report& report)
void MetaReporter::ExpectTrue(const bool value, const Report&)
{
if (value)
++m_countTrueSucceeded;
@@ -168,7 +183,7 @@ void MetaReporter::ExpectTrue(const bool value, [[maybe_unused]] const Report& r
++m_countTrueFailed;
}
void MetaReporter::ExpectEqualNumber(const Data::NumberType lhs, const Data::NumberType rhs, [[maybe_unused]] const Report& report)
void MetaReporter::ExpectEqual(const Data::NumberType lhs, const Data::NumberType rhs, const Report&)
{
if (AZ::IsClose(lhs, rhs, ScriptCanvas_UnitTestingCPP::k_tolerance))
++m_countEQSucceeded;
@@ -176,7 +191,7 @@ void MetaReporter::ExpectEqualNumber(const Data::NumberType lhs, const Data::Num
++m_countEQFailed;
}
void MetaReporter::ExpectNotEqualNumber(const Data::NumberType lhs, const Data::NumberType rhs, [[maybe_unused]] const Report& report)
void MetaReporter::ExpectNotEqual(const Data::NumberType lhs, const Data::NumberType rhs, const Report&)
{
if (!AZ::IsClose(lhs, rhs, ScriptCanvas_UnitTestingCPP::k_tolerance))
++m_countNESucceeded;
@@ -196,19 +211,22 @@ SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectLes
SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectLessThanEqual, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_LE)
// Vector Implementations
SCRIPT_CANVAS_UNIT_TEST_VECTOR_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectGreaterThan, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_GT)
SCRIPT_CANVAS_UNIT_TEST_VECTOR_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectGreaterThanEqual, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_GE)
SCRIPT_CANVAS_UNIT_TEST_VECTOR_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectLessThan, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_LT)
SCRIPT_CANVAS_UNIT_TEST_VECTOR_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectLessThanEqual, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_LE)
MetaReporter MetaRunUnitTestGraph(AZStd::string_view path)
{
const DurationSpec duration;
MetaReporter interpretedReporter;
const AZStd::string filePath = AZStd::string::format("%s/%s.%s", ScriptCanvas_UnitTestingCPP::k_unitTestDirPathRelative, path.data(), ScriptCanvas_UnitTestingCPP::k_defaultExtension);
ScriptCanvasEditor::RunGraph(filePath, ExecutionMode::Interpreted, duration, interpretedReporter);
/*
MetaReporter nativeReporter;
RunGraph(path, ExecutionMode::Native, duration, nativeReporter);
EXPECT_EQ(nativeReporter, interpretedReporter);
*/
RunGraphSpec runGraphSpec;
runGraphSpec.graphPath = filePath;
runGraphSpec.dirPath = ScriptCanvas_UnitTestingCPP::k_unitTestDirPathRelative;
runGraphSpec.runSpec.execution = ExecutionMode::Interpreted;
ScriptCanvasEditor::RunGraphImplementation(runGraphSpec, interpretedReporter);
EXPECT_TRUE(interpretedReporter.IsReportFinished());
return interpretedReporter;
}
@@ -247,7 +265,7 @@ TEST_F(ScriptCanvasTestFixture, AddFailure)
EXPECT_TRUE(reporter.IsComplete());
EXPECT_TRUE(reporter.IsDeactivated());
EXPECT_TRUE(reporter.IsErrorFree());
EXPECT_FALSE(reporter.IsErrorFree());
}
TEST_F(ScriptCanvasTestFixture, AddSuccess)
@@ -472,7 +490,7 @@ TEST_F(ScriptCanvasTestFixture, ExpectGreaterThanEqualSucceed)
EXPECT_TRUE(reporter.IsErrorFree());
}
TEST_F(ScriptCanvasTestFixture, ExpectLessThanFail)
TEST_F(ScriptCanvasTestFixture, ExpectLessThanFail)
{
MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectLessThanFail");
@@ -538,4 +556,8 @@ TEST_F(ScriptCanvasTestFixture, ExpectLessThanEqualSucceed)
EXPECT_TRUE(reporter.IsComplete());
EXPECT_TRUE(reporter.IsDeactivated());
EXPECT_TRUE(reporter.IsErrorFree());
}
}
#endif
@@ -10,15 +10,452 @@
*
*/
#include <AzCore/EBus/EBus.h>
#include <AzCore/Math/MathReflection.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <ScriptCanvas/Core/EBusHandler.h>
#include <ScriptCanvas/Core/SubgraphInterfaceUtility.h>
#include <ScriptCanvas/Core/Nodeable.h>
#include <ScriptCanvas/Execution/Interpreted/ExecutionInterpretedAPI.h>
#include <ScriptCanvas/Execution/NodeableOut/NodeableOutNative.h>
#include <ScriptCanvas/Grammar/GrammarContext.h>
#include <ScriptCanvas/Grammar/GrammarContextBus.h>
#include <Source/Framework/ScriptCanvasTestFixture.h>
#include <Source/Framework/ScriptCanvasTestNodes.h>
#include <Source/Framework/ScriptCanvasTestUtilities.h>
#include <Source/ScriptCanvasTestBus.h>
using namespace ScriptCanvasTests;
using namespace ScriptCanvas;
using namespace ScriptCanvasTests;
using namespace TestNodes;
using namespace ScriptCanvas::Execution;
TEST_F(ScriptCanvasTestFixture, HelloWorldInterpreted)
// TODO: This fails to compile on Linux only
//ScriptCanvas::Grammar::SubgraphInterface* CreateExecutionMap(AZ::BehaviorContext& behaviorContext)
//{
// using namespace ScriptCanvas;
// using namespace ScriptCanvas::Grammar;
//
// auto ins = CreateInsFromBehaviorContextMethods("TestNodeableObject", behaviorContext, { "Branch" } );
// auto branchOutVoidTrue = CreateOut<Data::BooleanType, const Data::StringType&>("BranchTrue", { "condition", "message" });
// auto branchOutVoidFalse = CreateOut<Data::BooleanType, const Data::StringType&, const Data::Vector3Type&>("BranchFalse", { "condition", "message", "vector" });
//
// auto branchOut = FindInByName("Branch", ins);
//
// EXPECT_NE(branchOut, nullptr);
// if (branchOut)
// {
// branchOut->outs.emplace_back(AZStd::move(branchOutVoidTrue));
// branchOut->outs.emplace_back(AZStd::move(branchOutVoidFalse));
// }
//
// return aznew SubgraphInterface(AZStd::move(ins));
//}
TEST_F(ScriptCanvasTestFixture, TestLuaObjectOrientation)
{
RunUnitTestGraph("LY_SC_UnitTest_HelloWorld");
}
using namespace ScriptCanvas;
using namespace ScriptCanvas::Grammar;
AZ::ScriptContext sc;
sc.BindTo(m_behaviorContext);
RegisterAPI(sc.NativeContext());
EXPECT_TRUE(sc.Execute(
R"LUA(
assert(Nodeable ~= nil, 'Nodeable was nill')
assert(Nodeable.__call ~= nil, 'Nodeable.__call was nil')
assert(type(Nodeable.__call) == 'function', 'Nodeable.__call was not a function')
local nodeable = Nodeable()
assert(nodeable ~= nil, 'nodeable was nil')
assert(type(nodeable) == "userdata", 'nodeable not userdata')
local SubGraph = {}
SubGraph.s_name = "SubGraphery"
SubGraph.s_createdCount = 0
function SubGraph:IncrementCreated()
SubGraph.s_createdCount = 1 + SubGraph.s_createdCount
end
setmetatable(SubGraph, { __index = Nodeable }) -- exposed through BehaviorContext
local SubGraphInstanceMetatable = { __index = SubGraph }
assert(getmetatable(SubGraph).__index == Nodeable, 'getmetatable(SubGraph).__index = Nodeable')
assert(type(getmetatable(SubGraph).__index) == 'table', "type(getmetatable(SubGraph).__index) ~= 'table'")
function SubGraph.new() -- Add executionState input here and to Nodeable()
-- now individual instance values can be initialized
local instance = OverrideNodeableMetatable(Nodeable(), SubGraphInstanceMetatable)
assert(type(instance.s_createdCount) == 'number', 'subgraph.s_createdCount was not a number')
instance:IncrementCreated()
instance.name = 'SubGraph '..tostring(instance.s_createdCount)
return instance
end
function SubGraph.newTable() -- Add executionState input here and to Nodeable()
-- now individual instance values can be initialized
local instance = setmetatable({}, SubGraphInstanceMetatable)
-- assert(getmetatable(instance) == SubGraphInstanceMetatable, "subgraphT")
assert(type(instance.s_createdCount) == 'number', 'subgraphT.s_createdCount was not a number')
instance:IncrementCreated()
instance.name = 'SubGraph '..tostring(instance.s_createdCount)
return instance
end
function SubGraph:Foo()
return "I, " .. tostring(self.name) .. ", am a user function"
end
local subgraphT = SubGraph.newTable()
assert(subgraphT ~= nil, "subgraphT was nil")
assert(type(subgraphT) == 'table', 'subgraphT was not a table')
assert(type(subgraphT.IsActive)== 'function', "subgraphT IsActive was not a function")
assert(type(subgraphT.Foo) == 'function', 'subgraphT was not a function')
local subgraphTResult = subgraphT:Foo()
assert(subgraphTResult == "I, SubGraph 1, am a user function", 'subgraphT did not return the right results:' .. tostring(subgraphTResult))
assert(subgraphT.s_createdCount == 1, "subgraphT created count was not one: ".. tostring(subgraphT.s_createdCount))
subgraphT = SubGraph.newTable()
assert(subgraphT.s_createdCount == 2, "subgraphT created count was not two: ".. tostring(subgraphT.s_createdCount))
local subgraph = SubGraph.new()
assert(subgraph ~= nil, "subgraph was nil")
assert(type(subgraph) == 'userdata', 'was not userdata')
assert(type(subgraph.IsActive)== 'function', "IsActive was not a function")
assert(not subgraph.IsActive(subgraph), "did not inherit properly")
assert(not subgraph:IsActive(), "did not inherit properly")
assert(type(subgraph.Foo) == 'function', 'was not a function')
local subgraphResult = subgraph:Foo()
assert(subgraphResult == "I, SubGraph 3, am a user function", 'subgraph:Foo() did not return the right results: ' .. tostring(subgraphResult))
assert(subgraph.s_createdCount == 3, "created count was not three: "..tostring(subgraph.s_createdCount))
local subgraph2 = SubGraph.new()
assert(subgraph2 ~= nil, "subgraph2 was nil")
assert(type(subgraph2) == 'userdata', 'subgraph2 was not userdata')
assert(type(subgraph2.IsActive)== 'function', "subgraph2 IsActive was not a function")
assert(not subgraph2.IsActive(subgraph2), "subgraph2 did not inherit properly")
assert(not subgraph2:IsActive(), "subgraph2 did not inherit properly")
assert(type(subgraph2.Foo) == 'function', 'subgraph2 was not a function')
local subgraph2Result = subgraph2:Foo()
assert(subgraph2Result == "I, SubGraph 4, am a user function", 'subgraph2:Foo() did not return the right results: ' .. tostring(subgraph2Result))
assert(subgraph2.s_createdCount == 4, "created count was not three: "..tostring(subgraph2.s_createdCount))
return SubGraph
)LUA"
));
}
//
// TEST_F(ScriptCanvasTestFixture, NativeNodeableStack)
// {
// TestNodeableObject nodeable;
// nodeable.Initialize();
//
// bool wasTrueCalled = false;
// bool wasFalseCalled = false;
//
// nodeable.SetExecutionOut
// ( AZ_CRC("BranchTrue", 0xd49f121c)
// , CreateOut
// ([&wasTrueCalled](ExecutionState&, Data::BooleanType condition, const Data::StringType& message)
// {
// EXPECT_TRUE(condition);
// EXPECT_EQ(message, AZStd::string("called the true version!"));
// wasTrueCalled = true;
// }
// , StackAllocatorType{}));
//
// nodeable.SetExecutionOut
// ( AZ_CRC("BranchFalse", 0xaceca8bc)
// , CreateOut
// ([&wasFalseCalled](ExecutionState&, Data::BooleanType condition, const Data::StringType& message, const Data::Vector3Type& vector)
// {
// EXPECT_FALSE(condition);
// EXPECT_EQ(message, AZStd::string("called the false version!"));
// EXPECT_EQ(vector, AZ::Vector3(1, 2, 3));
// wasFalseCalled = true;
// }
// , StackAllocatorType{}));
//
// nodeable.Branch(true);
// nodeable.Branch(false);
//
// EXPECT_TRUE(wasTrueCalled);
// EXPECT_TRUE(wasFalseCalled);
// }
//
// TEST_F(ScriptCanvasTestFixture, NativeNodeableHeap)
// {
// TestNodeableObject nodeable;
// nodeable.Initialize();
//
// AZStd::string routedArg("XYZ");
// AZStd::array<int, 2048> bigArray;
// std::fill(bigArray.begin(), bigArray.end(), 0);
//
// bigArray[0] = 7;
// bigArray[2047] = 7;
//
// EXPECT_EQ(bigArray[0], 7);
// EXPECT_EQ(bigArray[2047], 7);
//
// bool isHeapCalled = false;
//
// nodeable.SetExecutionOut
// ( AZ_CRC("BranchTrue", 0xd49f121c)
// , CreateOut
// ([routedArg, &isHeapCalled, bigArray](ExecutionState&, Data::BooleanType condition, const Data::StringType& message) mutable
// {
// EXPECT_EQ(message, AZStd::string("called the true version!"));
// routedArg = message;
// isHeapCalled = true;
// EXPECT_EQ(bigArray[0], 7);
// EXPECT_EQ(bigArray[2047], 7);
// bigArray[0] = 9;
// bigArray[2047] = 9;
// EXPECT_EQ(bigArray[0], 9);
// EXPECT_EQ(bigArray[2047], 9);
// }
// , HeapAllocatorType{}));
//
//
// bigArray[0] = 8;
// bigArray[2047] = 8;
// EXPECT_EQ(bigArray[0], 8);
// EXPECT_EQ(bigArray[2047], 8);
//
// nodeable.Branch(true);
// EXPECT_TRUE(isHeapCalled);
//
// // just making sure no crash occurs on unconnected outs
// nodeable.Branch(false);
// }
class Grandparent
{
public:
AZ_RTTI(Grandparent, "{76EF13EE-7F5E-41C8-A789-A86836D66D10}");
AZ_CLASS_ALLOCATOR(Grandparent, AZ::SystemAllocator, 0);
virtual ~Grandparent() = default;
static void Reflect(AZ::ReflectContext* reflectContext)
{
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext))
{
serializeContext->Class<Grandparent>();
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(reflectContext))
{
behaviorContext->Class<Grandparent>("Grandparent")
->Method("GetGeneration", &Grandparent::GetGeneration);
;
}
}
virtual int GetGeneration() const
{
return 1;
}
};
class Parent
: public Grandparent
{
public:
AZ_RTTI(Parent, "{2ABA91B7-24F7-495A-ACC6-4F93DE47B507}", Grandparent);
AZ_CLASS_ALLOCATOR(Parent, AZ::SystemAllocator, 0);
~Parent() override = default;
static void Reflect(AZ::ReflectContext* reflectContext)
{
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext))
{
serializeContext->Class<Parent, Grandparent>();
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(reflectContext))
{
behaviorContext->Class<Parent>("Parent")
;
}
}
int GetGeneration() const override
{
return 2;
}
};
class Child
: public Parent
{
public:
AZ_RTTI(Child, "{826DB77C-11B7-42C4-8F3F-3438AFE5B29B}", Parent);
AZ_CLASS_ALLOCATOR(Parent, AZ::SystemAllocator, 0);
~Child() override = default;
static void Reflect(AZ::ReflectContext* reflectContext)
{
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext))
{
serializeContext->Class<Child, Parent>();
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(reflectContext))
{
behaviorContext->Class<Child>("Child")
;
}
}
int GetGeneration() const override
{
return 3;
}
};
// TEST_F(ScriptCanvasTestFixture, CreateUuidsFast)
// {
// using namespace ScriptCanvas::Execution;
//
// ScriptCanvasEditor::ScopedOutputSuppression outputSuppression;
//
// AZ::Uuid candidate;
// AZ::Uuid reference;
// AZStd::string candidateString;
// AZStd::string referenceString;
//
// candidateString = /**************/ "0123ABCD4567EFAB0123ABCD4567EFAB";
// candidate = CreateIdFromStringFast(candidateString.data());
// reference = AZ::Uuid::CreateString("0123abcd4567efab0123abcd4567efab");
// EXPECT_EQ(candidate, reference);
// referenceString = CreateStringFastFromId(candidate);
// EXPECT_EQ(candidateString, referenceString);
//
// candidateString = /**************/ "12345678909876543345676524676553";
// candidate = CreateIdFromStringFast(candidateString.data());
// reference = AZ::Uuid::CreateString("12345678909876543345676524676553");
// EXPECT_EQ(candidate, reference);
// referenceString = CreateStringFastFromId(candidate);
// EXPECT_EQ(candidateString, referenceString);
//
// candidateString = /**************/ "ABCDEFABCDEFABCDEFABCDEFABCDEFAB";
// candidate = CreateIdFromStringFast(candidateString.data());
// reference = AZ::Uuid::CreateString("abcdefabcdefabcdefabcdefabcdefab");
// EXPECT_EQ(candidate, reference);
// referenceString = CreateStringFastFromId(candidate);
// EXPECT_EQ(candidateString, referenceString);
//
// candidateString = /**************/ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
// candidate = CreateIdFromStringFast(candidateString.data());
// reference = AZ::Uuid::CreateString("ffffffffffffffffffffffffffffffff");
// EXPECT_EQ(candidate, reference);
// referenceString = CreateStringFastFromId(candidate);
// EXPECT_EQ(candidateString, referenceString);
//
// candidateString = /**************/ "00000000000000000000000000000000";
// candidate = CreateIdFromStringFast(candidateString.data());
// reference = AZ::Uuid::CreateString("00000000000000000000000000000000");
// EXPECT_EQ(candidate, reference);
// referenceString = CreateStringFastFromId(candidate);
// EXPECT_EQ(candidateString, referenceString);
//
// candidateString = /**************/ "00000000000000000000000000000001";
// candidate = CreateIdFromStringFast(candidateString.data());
// reference = AZ::Uuid::CreateString("00000000000000000000000000000001");
// EXPECT_EQ(candidate, reference);
// referenceString = CreateStringFastFromId(candidate);
// EXPECT_EQ(candidateString, referenceString);
//
// candidateString = /**************/ "80000000000000000000000000000000";
// candidate = CreateIdFromStringFast(candidateString.data());
// reference = AZ::Uuid::CreateString("80000000000000000000000000000000");
// EXPECT_EQ(candidate, reference);
// referenceString = CreateStringFastFromId(candidate);
// EXPECT_EQ(candidateString, referenceString);
//
// // ................................."0123ABCD4567EFAB0123ABCD4567EFAB"
// EXPECT_DEATH(CreateIdFromStringFast("0123ABCD4567EFAB0123ABCD4567EFA"), "");
// EXPECT_DEATH(CreateIdFromStringFast("0123ABCD4567EFA"), "");
// EXPECT_DEATH(CreateIdFromStringFast("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"), "");
// EXPECT_DEATH(CreateIdFromStringFast("0123ABCD4567EFAB0123ABCD4567EFAB0"), "");
// }
TEST_F(ScriptCanvasTestFixture, TypeInheritance)
{
using namespace ScriptCanvas;
using namespace ScriptCanvas::Grammar;
// \todo make a version of this to test in the editor for node connections
// \todo make a version of this using events to check the methods results using self and table explicit calls
Grandparent::Reflect(m_serializeContext);
Grandparent::Reflect(m_behaviorContext);
Parent::Reflect(m_serializeContext);
Parent::Reflect(m_behaviorContext);
Child::Reflect(m_serializeContext);
Child::Reflect(m_behaviorContext);
Data::Type grandparentType = Data::Type::BehaviorContextObject(azrtti_typeid<Grandparent>());
Data::Type grandparentType2 = Data::Type::BehaviorContextObject(azrtti_typeid<Grandparent>());
Data::Type parentType = Data::Type::BehaviorContextObject(azrtti_typeid<Parent>());
Data::Type parentType2 = Data::Type::BehaviorContextObject(azrtti_typeid<Parent>());
Data::Type childType = Data::Type::BehaviorContextObject(azrtti_typeid<Child>());
Data::Type childType2 = Data::Type::BehaviorContextObject(azrtti_typeid<Child>());
EXPECT_TRUE(grandparentType.IS_A(grandparentType2));
EXPECT_TRUE(grandparentType.IS_EXACTLY_A(grandparentType2));
EXPECT_FALSE(grandparentType.IS_A(parentType));
EXPECT_FALSE(grandparentType.IS_EXACTLY_A(parentType));
EXPECT_FALSE(grandparentType.IS_A(childType));
EXPECT_FALSE(grandparentType.IS_EXACTLY_A(childType));
EXPECT_TRUE(parentType.IS_A(grandparentType));
EXPECT_FALSE(parentType.IS_EXACTLY_A(grandparentType));
EXPECT_TRUE(parentType.IS_A(parentType2));
EXPECT_TRUE(parentType.IS_EXACTLY_A(parentType2));
EXPECT_FALSE(parentType.IS_A(childType));
EXPECT_FALSE(parentType.IS_EXACTLY_A(childType));
EXPECT_TRUE(childType.IS_A(grandparentType));
EXPECT_FALSE(childType.IS_EXACTLY_A(grandparentType));
EXPECT_TRUE(childType.IS_A(parentType));
EXPECT_FALSE(childType.IS_EXACTLY_A(parentType));
EXPECT_TRUE(childType.IS_A(childType2));
EXPECT_TRUE(childType.IS_EXACTLY_A(childType2));
}
// \todo turn this into a unit test nodeable that adds a unit test failure on destruction if it was never triggered (or triggered the required number of times)
class Marker
{
public:
AZ_TYPE_INFO(Marker, "{BEEB4BF4-81B8-45A0-AD3F-D1875703315B}");
AZ_CLASS_ALLOCATOR(Marker, AZ::SystemAllocator, 0);
static AZStd::vector<int> s_markedPositions;
static void MarkPosition(int mark)
{
s_markedPositions.push_back(mark);
}
static void Reflect(AZ::ReflectContext* reflectContext)
{
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(reflectContext))
{
behaviorContext->Class<Marker>("Marker")->Method("MarkPosition", &MarkPosition);
}
}
};
AZStd::vector<int> Marker::s_markedPositions;
@@ -85,7 +85,6 @@ TEST_F(ScriptCanvasTestFixture, CreateVariableTest)
TestBehaviorContextObject::Reflect(m_behaviorContext);
{
using namespace ScriptCanvas;
using namespace Nodes;
ScriptCanvas::ScriptCanvasId scriptCanvasId = AZ::Entity::MakeId();
@@ -155,10 +154,7 @@ TEST_F(ScriptCanvasTestFixture, CreateVariableTest)
TEST_F(ScriptCanvasTestFixture, AddVariableFailTest)
{
using namespace ScriptCanvas;
using namespace Nodes;
ScriptCanvasId scriptCanvasId = AZ::Entity::MakeId();
@@ -186,17 +182,13 @@ TEST_F(ScriptCanvasTestFixture, AddVariableFailTest)
TEST_F(ScriptCanvasTestFixture, RemoveVariableTest)
{
StringArray::Reflect(m_serializeContext);
StringArray::Reflect(m_behaviorContext);
TestBehaviorContextObject::Reflect(m_serializeContext);
TestBehaviorContextObject::Reflect(m_behaviorContext);
{
using namespace ScriptCanvas;
using namespace Nodes;
ScriptCanvasId scriptCanvasId = AZ::Entity::MakeId();
@@ -313,6 +305,7 @@ TEST_F(ScriptCanvasTestFixture, RemoveVariableTest)
propertyEntity.reset();
}
m_serializeContext->EnableRemoveReflection();
m_behaviorContext->EnableRemoveReflection();
StringArray::Reflect(m_serializeContext);
@@ -325,10 +318,7 @@ TEST_F(ScriptCanvasTestFixture, RemoveVariableTest)
TEST_F(ScriptCanvasTestFixture, FindVariableTest)
{
using namespace ScriptCanvas;
using namespace Nodes;
ScriptCanvasId scriptCanvasId = AZ::Entity::MakeId();
@@ -387,10 +377,7 @@ TEST_F(ScriptCanvasTestFixture, FindVariableTest)
TEST_F(ScriptCanvasTestFixture, ModifyVariableTest)
{
using namespace ScriptCanvas;
using namespace Nodes;
ScriptCanvasId scriptCanvasId = AZ::Entity::MakeId();
@@ -445,13 +432,11 @@ TEST_F(ScriptCanvasTestFixture, ModifyVariableTest)
TEST_F(ScriptCanvasTestFixture, SerializationTest)
{
StringArray::Reflect(m_serializeContext);
StringArray::Reflect(m_behaviorContext);
using namespace ScriptCanvas;
using namespace Nodes;
{
ScriptCanvasId scriptCanvasId = AZ::Entity::MakeId();
@@ -529,216 +514,17 @@ TEST_F(ScriptCanvasTestFixture, SerializationTest)
m_behaviorContext->DisableRemoveReflection();
}
TEST_F(ScriptCanvasTestFixture, GetVariableNodeTest)
{
using namespace ScriptCanvas;
using namespace Nodes;
using namespace TestNodes;
AZStd::unique_ptr<AZ::Entity> graphEntity = AZStd::make_unique<AZ::Entity>("VariableGraph");
SystemRequestBus::Broadcast(&SystemRequests::CreateEngineComponentsOnEntity, graphEntity.get());
Graph* graph = AZ::EntityUtils::FindFirstDerivedComponent<Graph>(graphEntity.get());
ASSERT_NE(nullptr, graph);
AZ::EntityId graphEntityId = graphEntity->GetId();
ScriptCanvasId graphUniqueId = graph->GetScriptCanvasId();
graphEntity->Init();
Datum planeDatum(Data::PlaneType::CreateFromCoefficients(3.0f, -1.0f, 2.0f, 0.0f));
// Add in Plane Variable to Variable Component
AZStd::string_view variableName = "TestPlane";
AZ::Outcome<VariableId, AZStd::string> addVariableOutcome(AZ::Failure(AZStd::string("Uninitialized")));
GraphVariableManagerRequestBus::EventResult(addVariableOutcome, graphUniqueId, &GraphVariableManagerRequests::AddVariable, variableName, planeDatum);
EXPECT_TRUE(addVariableOutcome);
EXPECT_TRUE(addVariableOutcome.GetValue().IsValid());
const VariableId planeVariableId = addVariableOutcome.GetValue();
// Create Get Variable Node
AZ::EntityId outID;
auto startNode = CreateTestNode<Nodes::Core::Start>(graphUniqueId, outID);
auto getVariableNode = CreateTestNode<Nodes::Core::GetVariableNode>(graphUniqueId, outID);
auto getNormalNode = CreateTestNode<PlaneNodes::GetNormalNode>(graphUniqueId, outID);
auto vector3ResultNode = CreateDataNode(graphUniqueId, Data::Vector3Type::CreateZero(), outID);
auto printNode = CreateTestNode<TestResult>(graphUniqueId, outID);
auto normalResultTestResultNode = CreateTestNode<TestResult>(graphUniqueId, outID);
auto planeDistanceTestResultNode = CreateTestNode<TestResult>(graphUniqueId, outID);
// data
// This should fail to connect until the variableNode has a valid Variable associated with it
{
ScopedOutputSuppression supressOutput;
EXPECT_FALSE(graph->Connect(getVariableNode->GetEntityId(), getVariableNode->GetDataOutSlotId(), getNormalNode->GetEntityId(), getNormalNode->GetSlotId("Plane: Source")));
}
EXPECT_FALSE(getVariableNode->GetId().IsValid());
EXPECT_FALSE(getVariableNode->GetDataOutSlotId().IsValid());
getVariableNode->SetId(planeVariableId); // This associates the variable with the node and adds the input slot
auto variableDataOutSlotId = getVariableNode->GetDataOutSlotId();
EXPECT_TRUE(graph->Connect(getVariableNode->GetEntityId(), variableDataOutSlotId, getNormalNode->GetEntityId(), getNormalNode->GetSlotId("Plane: Source")));
EXPECT_TRUE(graph->Connect(getVariableNode->GetEntityId(), variableDataOutSlotId, printNode->GetEntityId(), printNode->GetSlotId("Value")));
// Connects Get Variable Node(normal: Vector3) data output slot to the TestResult Node(Set) data input slot
// Connects Get Variable Node(distance: Vector3) data output slot to the TestResult Node(Set) data input slot
auto normalDataOutSlotId = getVariableNode->GetSlotId("normal: Vector3");
EXPECT_TRUE(graph->Connect(getVariableNode->GetEntityId(), normalDataOutSlotId, normalResultTestResultNode->GetEntityId(), normalResultTestResultNode->GetSlotId("Value")));
auto distanceDataOutSlotId = getVariableNode->GetSlotId("distance: Number");
EXPECT_TRUE(graph->Connect(getVariableNode->GetEntityId(), distanceDataOutSlotId, planeDistanceTestResultNode->GetEntityId(), planeDistanceTestResultNode->GetSlotId("Value")));
EXPECT_TRUE(Connect(*graph, getNormalNode->GetEntityId(), "Result: Vector3", vector3ResultNode->GetEntityId(), "Set"));
// logic
EXPECT_TRUE(Connect(*graph, startNode->GetEntityId(), "Out", getVariableNode->GetEntityId(), "In"));
EXPECT_TRUE(Connect(*graph, getVariableNode->GetEntityId(), "Out", getNormalNode->GetEntityId(), "In"));
EXPECT_TRUE(Connect(*graph, getVariableNode->GetEntityId(), "Out", printNode->GetEntityId(), "In"));
EXPECT_TRUE(Connect(*graph, getVariableNode->GetEntityId(), "Out", normalResultTestResultNode->GetEntityId(), "In"));
EXPECT_TRUE(Connect(*graph, getVariableNode->GetEntityId(), "Out", planeDistanceTestResultNode->GetEntityId(), "In"));
// execute
{
ScopedOutputSuppression suppressOutput;
graphEntity->Activate();
}
EXPECT_FALSE(graph->IsInErrorState());
graphEntity->Deactivate();
GraphVariable* graphVariable = nullptr;
GraphVariableManagerRequestBus::EventResult(graphVariable, graphUniqueId, &GraphVariableManagerRequests::FindVariable, variableName);
ASSERT_NE(nullptr, graphVariable);
auto variablePlane = graphVariable->GetDatum()->GetAs<Data::PlaneType>();
ASSERT_NE(nullptr, variablePlane);
auto getResultPlane = GetInput_UNIT_TEST<Data::PlaneType>(printNode, "Value");
ASSERT_NE(nullptr, getResultPlane);
EXPECT_EQ(*variablePlane, *getResultPlane);
auto resultNormal = GetInput_UNIT_TEST<Data::Vector3Type>(vector3ResultNode, "Set");
ASSERT_NE(nullptr, resultNormal);
auto expectedNormal = variablePlane->GetNormal();
EXPECT_EQ(expectedNormal, *resultNormal);
auto planeNormalPropertyVector3 = GetInput_UNIT_TEST<Data::Vector3Type>(normalResultTestResultNode, "Value");
ASSERT_NE(nullptr, planeNormalPropertyVector3);
EXPECT_EQ(Data::Vector3Type(3.0f, -1.0f, 2.0f), *planeNormalPropertyVector3);
auto planeDistancePropertyNumber = GetInput_UNIT_TEST<Data::NumberType>(planeDistanceTestResultNode, "Value");
ASSERT_NE(nullptr, planeDistancePropertyNumber);
EXPECT_EQ(0.0f, *planeDistancePropertyNumber);
AZ::Entity* connectionEntity{};
EXPECT_TRUE(graph->FindConnection(connectionEntity, { getVariableNode->GetEntityId(), variableDataOutSlotId }, { getNormalNode->GetEntityId(), getNormalNode->GetSlotId("Plane: Source") }));
getVariableNode->SetId({});
EXPECT_FALSE(graph->FindConnection(connectionEntity, { getVariableNode->GetEntityId(), variableDataOutSlotId }, { getNormalNode->GetEntityId(), getNormalNode->GetSlotId("Plane: Source") }));
EXPECT_FALSE(getVariableNode->GetId().IsValid());
EXPECT_FALSE(getVariableNode->GetDataOutSlotId().IsValid());
}
TEST_F(ScriptCanvasTestFixture, SetVariableNodeTest)
{
using namespace ScriptCanvas;
using namespace Nodes;
AZStd::unique_ptr<AZ::Entity> graphEntity = AZStd::make_unique<AZ::Entity>("VariableGraph");
SystemRequestBus::Broadcast(&SystemRequests::CreateEngineComponentsOnEntity, graphEntity.get());
Graph* graph = AZ::EntityUtils::FindFirstDerivedComponent<Graph>(graphEntity.get());
ASSERT_NE(nullptr, graph);
AZ::EntityId graphEntityId = graphEntity->GetId();
ScriptCanvasId graphUniqueId = graph->GetScriptCanvasId();
graphEntity->Init();
Datum planeDatum(Data::PlaneType::CreateFromCoefficients(0.0f, 0.0f, 0.0f, 0.0f));
// Add in Plane Variable to Variable Component
AZStd::string_view varName = "TestPlane";
AZ::Outcome<VariableId, AZStd::string> addVariableOutcome(AZ::Failure(AZStd::string("Uninitialized")));
GraphVariableManagerRequestBus::EventResult(addVariableOutcome, graphUniqueId, &GraphVariableManagerRequests::AddVariable, varName, planeDatum);
EXPECT_TRUE(addVariableOutcome);
EXPECT_TRUE(addVariableOutcome.GetValue().IsValid());
const VariableId planeVariableId = addVariableOutcome.GetValue();
// Create Set Variable Node
AZ::EntityId outID;
auto startNode = CreateTestNode<Nodes::Core::Start>(graphUniqueId, outID);
auto setVariableNode = CreateTestNode<Nodes::Core::SetVariableNode>(graphUniqueId, outID);
auto fromNormalAndPointNode = CreateTestNode<PlaneNodes::FromNormalAndPointNode>(graphUniqueId, outID);
auto testPlane = Data::PlaneType::CreateFromNormalAndPoint(Data::Vector3Type(3.0f, -1.0f, 2.0f), Data::Vector3Type::CreateZero());
auto vector3NormalNode = CreateDataNode(graphUniqueId, testPlane.GetNormal(), outID);
auto vector3PointNode = CreateDataNode(graphUniqueId, Data::Vector3Type::CreateZero(), outID);
auto planeResultNode = CreateDataNode(graphUniqueId, Data::PlaneType::CreateFromNormalAndPoint(Data::Vector3Type(3.0f, -1.0f, 2.0f), Data::Vector3Type::CreateZero()), outID);
// data
EXPECT_TRUE(Connect(*graph, vector3NormalNode->GetEntityId(), "Get", fromNormalAndPointNode->GetEntityId(), "Vector3: Normal"));
EXPECT_TRUE(Connect(*graph, vector3PointNode->GetEntityId(), "Get", fromNormalAndPointNode->GetEntityId(), "Vector3: Point"));
// This should fail to connect until the SetVariableNode has a valid Variable associated with it
{
ScopedOutputSuppression suppressOutput;
EXPECT_FALSE(graph->Connect(fromNormalAndPointNode->GetEntityId(), fromNormalAndPointNode->GetSlotId("Plane: Result"), setVariableNode->GetEntityId(), setVariableNode->GetDataInSlotId()));
}
EXPECT_FALSE(setVariableNode->GetId().IsValid());
EXPECT_FALSE(setVariableNode->GetDataInSlotId().IsValid());
setVariableNode->SetId(planeVariableId); // This associates the variable with the node and adds the input slot
auto dataInputSlotId = setVariableNode->GetDataInSlotId();
EXPECT_TRUE(graph->Connect(fromNormalAndPointNode->GetEntityId(), fromNormalAndPointNode->GetSlotId("Result: Plane"), setVariableNode->GetEntityId(), dataInputSlotId));
auto dataOutputSlotId = setVariableNode->GetDataOutSlotId();
EXPECT_TRUE(graph->Connect(setVariableNode->GetEntityId(), dataOutputSlotId, planeResultNode->GetEntityId(), planeResultNode->GetSlotId("Set")));
// logic
EXPECT_TRUE(Connect(*graph, startNode->GetEntityId(), "Out", fromNormalAndPointNode->GetEntityId(), "In"));
EXPECT_TRUE(Connect(*graph, fromNormalAndPointNode->GetEntityId(), "Out", setVariableNode->GetEntityId(), "In"));
// execute
graphEntity->Activate();
EXPECT_FALSE(graph->IsInErrorState());
graphEntity->Deactivate();
AZ::Entity* connectionEntity{};
EXPECT_TRUE(graph->FindConnection(connectionEntity, { fromNormalAndPointNode->GetEntityId(), fromNormalAndPointNode->GetSlotId("Result: Plane") }, { setVariableNode->GetEntityId(), dataInputSlotId }));
setVariableNode->SetId({});
EXPECT_FALSE(graph->FindConnection(connectionEntity, { fromNormalAndPointNode->GetEntityId(), fromNormalAndPointNode->GetSlotId("Result: Plane") }, { setVariableNode->GetEntityId(), dataInputSlotId }));
EXPECT_FALSE(setVariableNode->GetId().IsValid());
EXPECT_FALSE(setVariableNode->GetDataInSlotId().IsValid());
GraphVariable* graphVariable = nullptr;
GraphVariableManagerRequestBus::EventResult(graphVariable, graphUniqueId, &GraphVariableManagerRequests::FindVariable, varName);
ASSERT_NE(nullptr, graphVariable);
// Get Variable Plane and verify that it is the same as the plane created from
auto variablePlane = graphVariable->GetDatum()->GetAs<Data::PlaneType>();
ASSERT_NE(nullptr, variablePlane);
EXPECT_EQ(testPlane, *variablePlane);
auto resultPlane = GetInput_UNIT_TEST<Data::PlaneType>(planeResultNode, "Set");
ASSERT_NE(nullptr, resultPlane);
auto expectedNormal = variablePlane->GetNormal();
EXPECT_EQ(expectedNormal, resultPlane->GetNormal());
}
TEST_F(ScriptCanvasTestFixture, Vector2AllNodes)
{
RunUnitTestGraph("LY_SC_UnitTest_Vector2_AllNodes");
RunUnitTestGraph("LY_SC_UnitTest_Vector2_AllNodes", ExecutionMode::Interpreted);
}
TEST_F(ScriptCanvasTestFixture, Vector3_GetNode)
{
RunUnitTestGraph("LY_SC_UnitTest_Vector3_Variable_GetNode");
RunUnitTestGraph("LY_SC_UnitTest_Vector3_Variable_GetNode", ExecutionMode::Interpreted);
}
TEST_F(ScriptCanvasTestFixture, Vector3_SetNode)
{
RunUnitTestGraph("LY_SC_UnitTest_Vector3_Variable_SetNode");
RunUnitTestGraph("LY_SC_UnitTest_Vector3_Variable_SetNode", ExecutionMode::Interpreted);
}
@@ -0,0 +1,19 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
${LY_ROOT_FOLDER}/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNode_Header.jinja
${LY_ROOT_FOLDER}/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNode_Source.jinja
${LY_ROOT_FOLDER}/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Header.jinja
${LY_ROOT_FOLDER}/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja
${LY_ROOT_FOLDER}/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvas_Macros.jinja
${LY_ROOT_FOLDER}/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvas_Nodeable_Macros.jinja
)
@@ -10,9 +10,19 @@
#
set(FILES
Source/ScriptCanvasTestBus.h
Source/ScriptCanvasTestBus.cpp
Source/ScriptCanvasTestingSystemComponent.cpp
Source/ScriptCanvasTestingSystemComponent.h
Source/Framework/ScriptCanvasTestVerify.cpp
Source/Framework/ScriptCanvasTestVerify.h
Source/Nodes/BehaviorContextObjectTestNode.h
Source/Nodes/Nodeables/NodeableTestingLibrary.h
Source/Nodes/Nodeables/NodeableTestingLibrary.cpp
Source/Nodes/Nodeables/SharedDataSlotExample.h
Source/Nodes/Nodeables/SharedDataSlotExample.cpp
Source/Nodes/Nodeables/SharedDataSlotExample.ScriptCanvasNodeable.xml
Source/Nodes/Nodeables/ValuePointerReferenceExample.h
Source/Nodes/Nodeables/ValuePointerReferenceExample.cpp
Source/Nodes/Nodeables/ValuePointerReferenceExample.ScriptCanvasNodeable.xml
)
@@ -10,5 +10,5 @@
#
set(FILES
Source/ScriptCanvasTestingEditorModule.cpp
Source/ScriptCanvasTestingEditorModule.cpp
)
@@ -21,14 +21,15 @@ set(FILES
Tests/ScriptCanvasTestingTest.cpp
Tests/ScriptCanvas_Async.cpp
Tests/ScriptCanvas_BehaviorContext.cpp
Tests/ScriptCanvas_Core.cpp
Tests/ScriptCanvas_ContainerSupport.cpp
Tests/ScriptCanvas_Slots.cpp
Tests/ScriptCanvas_Core.cpp
Tests/ScriptCanvas_EventHandlers.cpp
Tests/ScriptCanvas_Math.cpp
Tests/ScriptCanvas_MethodOverload.cpp
Tests/ScriptCanvas_NodeGenerics.cpp
Tests/ScriptCanvas_OutcomeAutoUnpacking.cpp
Tests/ScriptCanvas_Regressions.cpp
Tests/ScriptCanvas_RuntimeInterpreted.cpp
Tests/ScriptCanvas_Slots.cpp
Tests/ScriptCanvas_StringNodes.cpp
Tests/ScriptCanvas_UnitTesting.cpp
Tests/ScriptCanvas_Variables.cpp