ScriptCanvas_Core.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Source/Framework/ScriptCanvasTestFixture.h>
  9. #include <Source/Framework/ScriptCanvasTestUtilities.h>
  10. #include <Source/Framework/ScriptCanvasTestNodes.h>
  11. #include <AzCore/Serialization/IdUtils.h>
  12. #include <ScriptCanvas/Asset/RuntimeAsset.h>
  13. #include <ScriptCanvas/Asset/RuntimeAssetHandler.h>
  14. #include <ScriptCanvas/Execution/RuntimeComponent.h>
  15. #include <ScriptCanvas/Variable/GraphVariableManagerComponent.h>
  16. #include <ScriptCanvas/Libraries/Core/Start.h>
  17. #include <AzCore/Math/Vector3.h>
  18. #include <AzCore/Math/Color.h>
  19. using namespace ScriptCanvasTests;
  20. using namespace TestNodes;
  21. TEST_F(ScriptCanvasTestFixture, CoreNodeFunction_OwningGraphCheck)
  22. {
  23. using namespace ScriptCanvas;
  24. ScriptCanvas::Graph* graph = CreateGraph();
  25. ConfigurableUnitTestNode* groupedNode = CreateConfigurableNode();
  26. EXPECT_EQ(graph, groupedNode->GetGraph());
  27. }
  28. TEST_F(ScriptCanvasTestFixture, AddRemoveSlotNotifications)
  29. {
  30. RegisterComponentDescriptor<AddNodeWithRemoveSlot>();
  31. using namespace ScriptCanvas;
  32. AZStd::unique_ptr<AZ::Entity> numberAddEntity = AZStd::make_unique<AZ::Entity>("numberAddEntity");
  33. auto numberAddNode = numberAddEntity->CreateComponent<AddNodeWithRemoveSlot>();
  34. numberAddEntity->Init();
  35. ScriptUnitTestNodeNotificationHandler nodeNotifications(numberAddNode->GetEntityId());
  36. SlotId testSlotId = numberAddNode->AddSlot("test");
  37. EXPECT_EQ(1U, nodeNotifications.GetSlotsAdded());
  38. numberAddNode->RemoveSlot(testSlotId);
  39. EXPECT_EQ(1U, nodeNotifications.GetSlotsRemoved());
  40. testSlotId = numberAddNode->AddSlot("duplicate");
  41. EXPECT_EQ(2U, nodeNotifications.GetSlotsAdded());
  42. // This should not signal the NodeNotification::OnSlotAdded event as the slot already exist on the node
  43. SlotId duplicateSlotId = numberAddNode->AddSlot("duplicate");
  44. EXPECT_EQ(2U, nodeNotifications.GetSlotsAdded());
  45. EXPECT_EQ(testSlotId, duplicateSlotId);
  46. numberAddNode->RemoveSlot(testSlotId);
  47. EXPECT_EQ(2U, nodeNotifications.GetSlotsRemoved());
  48. // This should not signal the NodeNotification::OnSlotRemoved event as the slot no longer exist on the node
  49. numberAddNode->RemoveSlot(testSlotId, false);
  50. EXPECT_EQ(2U, nodeNotifications.GetSlotsRemoved());
  51. numberAddEntity.reset();
  52. }
  53. TEST_F(ScriptCanvasTestFixture, InsertSlot_Basic)
  54. {
  55. using namespace ScriptCanvas;
  56. ScriptCanvas::Graph* graph = CreateGraph();
  57. ConfigurableUnitTestNode* basicNode = CreateConfigurableNode();
  58. SlotId firstSlotAdded;
  59. SlotId secondSlotAdded;
  60. SlotId thirdSlotAdded;
  61. {
  62. DataSlotConfiguration slotConfiguration;
  63. slotConfiguration.m_name = "A";
  64. slotConfiguration.SetDefaultValue(0);
  65. slotConfiguration.SetConnectionType(ConnectionType::Input);
  66. Slot* slot = basicNode->AddTestingSlot(slotConfiguration);
  67. firstSlotAdded = slot->GetId();
  68. }
  69. {
  70. DataSlotConfiguration slotConfiguration;
  71. slotConfiguration.m_name = "C";
  72. slotConfiguration.SetDefaultValue(2);
  73. slotConfiguration.SetConnectionType(ConnectionType::Input);
  74. Slot* slot = basicNode->AddTestingSlot(slotConfiguration);
  75. secondSlotAdded = slot->GetId();
  76. }
  77. {
  78. DataSlotConfiguration slotConfiguration;
  79. slotConfiguration.m_name = "B";
  80. slotConfiguration.SetDefaultValue(1);
  81. slotConfiguration.SetConnectionType(ConnectionType::Input);
  82. auto index = basicNode->FindSlotIndex(secondSlotAdded);
  83. EXPECT_EQ(index, 1);
  84. Slot* slot = basicNode->InsertTestingSlot(index, slotConfiguration);
  85. thirdSlotAdded = slot->GetId();
  86. }
  87. {
  88. AZStd::vector< const Slot* > slotList = basicNode->GetAllSlots();
  89. EXPECT_EQ(slotList.size(), 3);
  90. {
  91. const Slot* firstSlot = slotList[0];
  92. EXPECT_EQ(firstSlot->GetId(), firstSlotAdded);
  93. EXPECT_EQ(firstSlot->GetName(), "A");
  94. EXPECT_FLOAT_EQ(static_cast<float>((*firstSlot->FindDatum()->GetAs<Data::NumberType>())), 0.0f);
  95. }
  96. {
  97. const Slot* secondSlot = slotList[1];
  98. EXPECT_EQ(secondSlot->GetId(), thirdSlotAdded);
  99. EXPECT_EQ(secondSlot->GetName(), "B");
  100. EXPECT_FLOAT_EQ(static_cast<float>((*secondSlot->FindDatum()->GetAs<Data::NumberType>())), 1.0f);
  101. }
  102. {
  103. const Slot* thirdSlot = slotList[2];
  104. EXPECT_EQ(thirdSlot->GetId(), secondSlotAdded);
  105. EXPECT_EQ(thirdSlot->GetName(), "C");
  106. EXPECT_FLOAT_EQ(static_cast<float>((*thirdSlot->FindDatum()->GetAs<Data::NumberType>())), 2.0f);
  107. }
  108. }
  109. graph->Activate();
  110. {
  111. AZStd::vector< const Slot* > slotList = basicNode->GetAllSlots();
  112. EXPECT_EQ(slotList.size(), 3);
  113. {
  114. const Slot* firstSlot = slotList[0];
  115. EXPECT_EQ(firstSlot->GetId(), firstSlotAdded);
  116. EXPECT_EQ(firstSlot->GetName(), "A");
  117. EXPECT_FLOAT_EQ(static_cast<float>((*firstSlot->FindDatum()->GetAs<Data::NumberType>())), 0.0f);
  118. }
  119. {
  120. const Slot* secondSlot = slotList[1];
  121. EXPECT_EQ(secondSlot->GetId(), thirdSlotAdded);
  122. EXPECT_EQ(secondSlot->GetName(), "B");
  123. EXPECT_FLOAT_EQ(static_cast<float>((*secondSlot->FindDatum()->GetAs<Data::NumberType>())), 1.0f);
  124. }
  125. {
  126. const Slot* thirdSlot = slotList[2];
  127. EXPECT_EQ(thirdSlot->GetId(), secondSlotAdded);
  128. EXPECT_EQ(thirdSlot->GetName(), "C");
  129. EXPECT_FLOAT_EQ(static_cast<float>((*thirdSlot->FindDatum()->GetAs<Data::NumberType>())), 2.0f);
  130. }
  131. }
  132. graph->Deactivate();
  133. {
  134. const AZStd::vector< const Slot* > slotList = basicNode->GetAllSlots();
  135. EXPECT_EQ(slotList.size(), 3);
  136. {
  137. const Slot* firstSlot = slotList[0];
  138. EXPECT_EQ(firstSlot->GetId(), firstSlotAdded);
  139. EXPECT_EQ(firstSlot->GetName(), "A");
  140. EXPECT_FLOAT_EQ(static_cast<float>((*firstSlot->FindDatum()->GetAs<Data::NumberType>())), 0.0f);
  141. }
  142. {
  143. const Slot* secondSlot = slotList[1];
  144. EXPECT_EQ(secondSlot->GetId(), thirdSlotAdded);
  145. EXPECT_EQ(secondSlot->GetName(), "B");
  146. EXPECT_FLOAT_EQ(static_cast<float>((*secondSlot->FindDatum()->GetAs<Data::NumberType>())), 1.0f);
  147. }
  148. {
  149. const Slot* thirdSlot = slotList[2];
  150. EXPECT_EQ(thirdSlot->GetId(), secondSlotAdded);
  151. EXPECT_EQ(thirdSlot->GetName(), "C");
  152. EXPECT_FLOAT_EQ(static_cast<float>((*thirdSlot->FindDatum()->GetAs<Data::NumberType>())), 2.0f);
  153. }
  154. }
  155. }
  156. TEST_F(ScriptCanvasTestFixture, InsertSlot_FrontPadded)
  157. {
  158. using namespace ScriptCanvas;
  159. ScriptCanvas::Graph* graph = CreateGraph();
  160. ConfigurableUnitTestNode* basicNode = CreateConfigurableNode();
  161. basicNode->AddTestingSlot(ExecutionSlotConfiguration("Input", ConnectionType::Input));
  162. basicNode->AddTestingSlot(ExecutionSlotConfiguration("Input-1", ConnectionType::Input));
  163. basicNode->AddTestingSlot(ExecutionSlotConfiguration("Input-2", ConnectionType::Input));
  164. basicNode->AddTestingSlot(ExecutionSlotConfiguration("Input-3", ConnectionType::Input));
  165. SlotId firstSlotAdded;
  166. SlotId secondSlotAdded;
  167. SlotId thirdSlotAdded;
  168. {
  169. DataSlotConfiguration slotConfiguration;
  170. slotConfiguration.m_name = "A";
  171. slotConfiguration.SetDefaultValue(0);
  172. slotConfiguration.SetConnectionType(ConnectionType::Input);
  173. Slot* slot = basicNode->AddTestingSlot(slotConfiguration);
  174. firstSlotAdded = slot->GetId();
  175. }
  176. {
  177. DataSlotConfiguration slotConfiguration;
  178. slotConfiguration.m_name = "C";
  179. slotConfiguration.SetDefaultValue(2);
  180. slotConfiguration.SetConnectionType(ConnectionType::Input);
  181. Slot* slot = basicNode->AddTestingSlot(slotConfiguration);
  182. secondSlotAdded = slot->GetId();
  183. }
  184. {
  185. DataSlotConfiguration slotConfiguration;
  186. slotConfiguration.m_name = "B";
  187. slotConfiguration.SetDefaultValue(1);
  188. slotConfiguration.SetConnectionType(ConnectionType::Input);
  189. auto index = basicNode->FindSlotIndex(secondSlotAdded);
  190. Slot* slot = basicNode->InsertTestingSlot(index, slotConfiguration);
  191. thirdSlotAdded = slot->GetId();
  192. }
  193. {
  194. AZStd::vector< const Slot* > slotList = basicNode->FindSlotsByDescriptor(SlotDescriptors::DataIn());
  195. EXPECT_EQ(slotList.size(), 3);
  196. {
  197. const Slot* firstSlot = slotList[0];
  198. EXPECT_EQ(firstSlot->GetId(), firstSlotAdded);
  199. EXPECT_EQ(firstSlot->GetName(), "A");
  200. EXPECT_FLOAT_EQ(static_cast<float>((*firstSlot->FindDatum()->GetAs<Data::NumberType>())), 0.0f);
  201. }
  202. {
  203. const Slot* secondSlot = slotList[1];
  204. EXPECT_EQ(secondSlot->GetId(), thirdSlotAdded);
  205. EXPECT_EQ(secondSlot->GetName(), "B");
  206. EXPECT_FLOAT_EQ(static_cast<float>((*secondSlot->FindDatum()->GetAs<Data::NumberType>())), 1.0f);
  207. }
  208. {
  209. const Slot* thirdSlot = slotList[2];
  210. EXPECT_EQ(thirdSlot->GetId(), secondSlotAdded);
  211. EXPECT_EQ(thirdSlot->GetName(), "C");
  212. EXPECT_FLOAT_EQ(static_cast<float>((*thirdSlot->FindDatum()->GetAs<Data::NumberType>())), 2.0f);
  213. }
  214. }
  215. graph->Activate();
  216. {
  217. AZStd::vector< const Slot* > slotList = basicNode->FindSlotsByDescriptor(SlotDescriptors::DataIn());
  218. EXPECT_EQ(slotList.size(), 3);
  219. {
  220. const Slot* firstSlot = slotList[0];
  221. EXPECT_EQ(firstSlot->GetId(), firstSlotAdded);
  222. EXPECT_EQ(firstSlot->GetName(), "A");
  223. EXPECT_FLOAT_EQ(static_cast<float>((*firstSlot->FindDatum()->GetAs<Data::NumberType>())), 0.0f);
  224. }
  225. {
  226. const Slot* secondSlot = slotList[1];
  227. EXPECT_EQ(secondSlot->GetId(), thirdSlotAdded);
  228. EXPECT_EQ(secondSlot->GetName(), "B");
  229. EXPECT_FLOAT_EQ(static_cast<float>((*secondSlot->FindDatum()->GetAs<Data::NumberType>())), 1.0f);
  230. }
  231. {
  232. const Slot* thirdSlot = slotList[2];
  233. EXPECT_EQ(thirdSlot->GetId(), secondSlotAdded);
  234. EXPECT_EQ(thirdSlot->GetName(), "C");
  235. EXPECT_FLOAT_EQ(static_cast<float>((*thirdSlot->FindDatum()->GetAs<Data::NumberType>())), 2.0f);
  236. }
  237. }
  238. graph->Deactivate();
  239. {
  240. AZStd::vector< const Slot* > slotList = basicNode->FindSlotsByDescriptor(SlotDescriptors::DataIn());
  241. EXPECT_EQ(slotList.size(), 3);
  242. {
  243. const Slot* firstSlot = slotList[0];
  244. EXPECT_EQ(firstSlot->GetId(), firstSlotAdded);
  245. EXPECT_EQ(firstSlot->GetName(), "A");
  246. EXPECT_FLOAT_EQ(static_cast<float>((*firstSlot->FindDatum()->GetAs<Data::NumberType>())), 0.0f);
  247. }
  248. {
  249. const Slot* secondSlot = slotList[1];
  250. EXPECT_EQ(secondSlot->GetId(), thirdSlotAdded);
  251. EXPECT_EQ(secondSlot->GetName(), "B");
  252. EXPECT_FLOAT_EQ(static_cast<float>((*secondSlot->FindDatum()->GetAs<Data::NumberType>())), 1.0f);
  253. }
  254. {
  255. const Slot* thirdSlot = slotList[2];
  256. EXPECT_EQ(thirdSlot->GetId(), secondSlotAdded);
  257. EXPECT_EQ(thirdSlot->GetName(), "C");
  258. EXPECT_FLOAT_EQ(static_cast<float>((*thirdSlot->FindDatum()->GetAs<Data::NumberType>())), 2.0f);
  259. }
  260. }
  261. }
  262. TEST_F(ScriptCanvasTestFixture, ValueTypes)
  263. {
  264. using namespace ScriptCanvas;
  265. Datum number0(Datum(0));
  266. int number0Value = *number0.GetAs<int>();
  267. Datum number1(Datum(1));
  268. int number1Value = *number1.GetAs<int>();
  269. Datum numberFloat(Datum(2.f));
  270. float numberFloatValue = *numberFloat.GetAs<float>();
  271. Datum numberDouble(Datum(3.0));
  272. double numberDoubleValue = *numberDouble.GetAs<double>();
  273. Datum numberHex(Datum(0xff));
  274. [[maybe_unused]] int numberHexValue = *numberHex.GetAs<int>();
  275. Datum numberPi(Datum(3.14f));
  276. float numberPiValue = *numberPi.GetAs<float>();
  277. Datum numberSigned(Datum(-100));
  278. [[maybe_unused]] int numberSignedValue = *numberSigned.GetAs<int>();
  279. Datum numberUnsigned(Datum(100u));
  280. [[maybe_unused]] unsigned int numberUnsignedValue = *numberUnsigned.GetAs<unsigned int>();
  281. Datum numberDoublePi(Datum(6.28));
  282. double numberDoublePiValue = *numberDoublePi.GetAs<double>();
  283. EXPECT_EQ(number0Value, 0);
  284. EXPECT_EQ(number1Value, 1);
  285. EXPECT_TRUE(AZ::IsClose(numberFloatValue, 2.f, std::numeric_limits<float>::epsilon()));
  286. EXPECT_TRUE(AZ::IsClose(numberDoubleValue, 3.0, std::numeric_limits<double>::epsilon()));
  287. EXPECT_NE(number0Value, number1Value);
  288. SC_EXPECT_FLOAT_EQ(numberPiValue, 3.14f);
  289. EXPECT_NE(number0Value, numberPiValue);
  290. EXPECT_NE(numberPiValue, numberDoublePiValue);
  291. Datum boolTrue(Datum(true));
  292. EXPECT_TRUE(*boolTrue.GetAs<bool>());
  293. Datum boolFalse(Datum(false));
  294. EXPECT_FALSE(*boolFalse.GetAs<bool>());
  295. boolFalse = boolTrue;
  296. EXPECT_TRUE(*boolFalse.GetAs<bool>());
  297. Datum boolFalse2(Datum(false));
  298. boolTrue = boolFalse2;
  299. EXPECT_FALSE(*boolTrue.GetAs<bool>());
  300. {
  301. const int k_count(10000);
  302. AZStd::vector<Datum> objects;
  303. for (int i = 0; i < k_count; ++i)
  304. {
  305. objects.push_back(Datum("Vector3", Datum::eOriginality::Original));
  306. }
  307. }
  308. GTEST_SUCCEED();
  309. }
  310. TEST_F(ScriptCanvasTestFixture, Contracts)
  311. {
  312. using namespace ScriptCanvas;
  313. RegisterComponentDescriptor<ContractNode>();
  314. //////////////////////////////////////////////////////////////////////////
  315. // Make the graph.
  316. ScriptCanvas::Graph* graph = nullptr;
  317. SystemRequestBus::BroadcastResult(graph, &SystemRequests::MakeGraph);
  318. EXPECT_TRUE(graph != nullptr);
  319. graph->GetEntity()->Init();
  320. const ScriptCanvasId& graphUniqueId = graph->GetScriptCanvasId();
  321. // Make the nodes.
  322. // Start
  323. AZ::Entity* startEntity{ aznew AZ::Entity("Start") };
  324. startEntity->Init();
  325. AZ::EntityId startNode{ startEntity->GetId() };
  326. SystemRequestBus::Broadcast(&SystemRequests::CreateNodeOnEntity, startNode, graphUniqueId, ScriptCanvas::Nodes::Core::Start::TYPEINFO_Uuid());
  327. // ContractNode 0
  328. AZ::Entity* contract0Entity{ aznew AZ::Entity("Contract 0") };
  329. contract0Entity->Init();
  330. AZ::EntityId contract0Node{ contract0Entity->GetId() };
  331. SystemRequestBus::Broadcast(&SystemRequests::CreateNodeOnEntity, contract0Node, graphUniqueId, ContractNode::TYPEINFO_Uuid());
  332. // ContractNode 1
  333. AZ::Entity* contract1Entity{ aznew AZ::Entity("Contract 1") };
  334. contract1Entity->Init();
  335. AZ::EntityId contract1Node{ contract1Entity->GetId() };
  336. SystemRequestBus::Broadcast(&SystemRequests::CreateNodeOnEntity, contract1Node, graphUniqueId, ContractNode::TYPEINFO_Uuid());
  337. // invalid
  338. {
  339. ScriptCanvasEditor::ScopedOutputSuppression suppressOutput;
  340. EXPECT_FALSE(graph->Connect(startNode, AZ::EntityUtils::FindFirstDerivedComponent<Node>(startEntity)->GetSlotId("Out"), contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Out")));
  341. EXPECT_FALSE(graph->Connect(startNode, AZ::EntityUtils::FindFirstDerivedComponent<Node>(startEntity)->GetSlotId("In"), contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("In")));
  342. EXPECT_FALSE(graph->Connect(startNode, AZ::EntityUtils::FindFirstDerivedComponent<Node>(startEntity)->GetSlotId("In"), contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Get String")));
  343. EXPECT_FALSE(graph->Connect(startNode, AZ::EntityUtils::FindFirstDerivedComponent<Node>(startEntity)->GetSlotId("Out"), contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Get String")));
  344. EXPECT_FALSE(graph->Connect(startNode, AZ::EntityUtils::FindFirstDerivedComponent<Node>(startEntity)->GetSlotId("In"), contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Set String")));
  345. EXPECT_FALSE(graph->Connect(startNode, AZ::EntityUtils::FindFirstDerivedComponent<Node>(startEntity)->GetSlotId("Out"), contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Set String")));
  346. EXPECT_FALSE(graph->Connect(contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Set String"), contract1Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract1Entity)->GetSlotId("Set String")));
  347. EXPECT_FALSE(graph->Connect(contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Set String"), contract1Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract1Entity)->GetSlotId("Set Number")));
  348. EXPECT_FALSE(graph->Connect(contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Get String"), contract1Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract1Entity)->GetSlotId("Set Number")));
  349. EXPECT_FALSE(graph->Connect(contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Set String"), contract1Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract1Entity)->GetSlotId("Set String")));
  350. EXPECT_FALSE(graph->Connect(contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Out"), contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("In")));
  351. }
  352. // valid
  353. EXPECT_TRUE(graph->Connect(startNode, AZ::EntityUtils::FindFirstDerivedComponent<Node>(startEntity)->GetSlotId("Out"), contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("In")));
  354. EXPECT_TRUE(graph->Connect(contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Set String"), contract1Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract1Entity)->GetSlotId("Get String")));
  355. EXPECT_TRUE(graph->Connect(contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("In"), contract1Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract1Entity)->GetSlotId("Out")));
  356. EXPECT_TRUE(graph->Connect(contract0Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract0Entity)->GetSlotId("Set Number"), contract1Node, AZ::EntityUtils::FindFirstDerivedComponent<Node>(contract1Entity)->GetSlotId("Get Number")));
  357. // Execute it
  358. graph->GetEntity()->Activate();
  359. ReportErrors(graph);
  360. graph->GetEntity()->Deactivate();
  361. delete graph->GetEntity();
  362. }
  363. TEST_F(ScriptCanvasTestFixture, While)
  364. {
  365. RunUnitTestGraph("LY_SC_UnitTest_While", ScriptCanvas::ExecutionMode::Interpreted);
  366. }
  367. TEST_F(ScriptCanvasTestFixture, WhileBreak)
  368. {
  369. RunUnitTestGraph("LY_SC_UnitTest_WhileBreak", ScriptCanvas::ExecutionMode::Interpreted);
  370. }