ScriptCanvas_UnitTesting.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/Serialization/IdUtils.h>
  9. #include <ScriptCanvas/Asset/RuntimeAsset.h>
  10. #include <ScriptCanvas/Asset/RuntimeAssetHandler.h>
  11. #include <ScriptCanvas/Execution/RuntimeComponent.h>
  12. #include <ScriptCanvas/Variable/GraphVariableManagerComponent.h>
  13. #include <Source/Framework/ScriptCanvasTestFixture.h>
  14. #include <Source/Framework/ScriptCanvasTestNodes.h>
  15. #include <Source/Framework/ScriptCanvasTestUtilities.h>
  16. #include <Editor/Framework/ScriptCanvasReporter.h>
  17. #if 0
  18. using namespace ScriptCanvasEditor;
  19. #define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_EQ(LHS, RHS)\
  20. if (LHS == RHS)\
  21. ++m_countEQSucceeded;\
  22. else\
  23. ++m_countEQFailed;
  24. #define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_NE(LHS, RHS)\
  25. if (LHS != RHS)\
  26. ++m_countNESucceeded;\
  27. else\
  28. ++m_countNEFailed;
  29. #define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_GT(LHS, RHS)\
  30. if (LHS > RHS)\
  31. ++m_countGTSucceeded;\
  32. else\
  33. ++m_countGTFailed;
  34. #define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_GE(LHS, RHS)\
  35. if (LHS >= RHS)\
  36. ++m_countGESucceeded;\
  37. else\
  38. ++m_countGEFailed;
  39. #define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_LT(LHS, RHS)\
  40. if (LHS < RHS)\
  41. ++m_countLTSucceeded;\
  42. else\
  43. ++m_countLTFailed;
  44. #define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_LE(LHS, RHS)\
  45. if (LHS <= RHS)\
  46. ++m_countLESucceeded;\
  47. else\
  48. ++m_countLEFailed;
  49. #define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_GT(LHS, RHS)\
  50. if((LHS.IsGreaterThan(RHS))) ++m_countGTSucceeded; else ++m_countGTFailed;
  51. #define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_GE(LHS, RHS)\
  52. if((LHS.IsGreaterEqualThan(RHS))) ++m_countGESucceeded; else ++m_countGEFailed;
  53. #define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_LT(LHS, RHS)\
  54. if((LHS.IsLessThan(RHS))) ++m_countLTSucceeded; else ++m_countLTFailed;
  55. #define SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_LE(LHS, RHS)\
  56. if((LHS.IsLessEqualThan(RHS))) ++m_countLTSucceeded; else ++m_countLTFailed;
  57. namespace ScriptCanvas_UnitTestingCPP
  58. {
  59. const double k_tolerance = 0.01;
  60. const char* k_defaultExtension = "scriptcanvas";
  61. const char* k_unitTestDirPathRelative = "@gemroot:ScriptCanvasTesting@/Assets/ScriptCanvas/UnitTests";
  62. }
  63. using namespace ScriptCanvasTests;
  64. using namespace ScriptCanvas;
  65. using namespace ScriptCanvas::UnitTesting;
  66. using namespace ScriptCanvasEditor;
  67. class MetaReporter
  68. : public Reporter
  69. {
  70. public:
  71. AZ_INLINE AZ::u32 GetCountEQFailed() const { return m_countEQFailed; }
  72. AZ_INLINE AZ::u32 GetCountEQSucceeded() const { return m_countEQSucceeded; }
  73. AZ_INLINE AZ::u32 GetCountFalseFailed() const { return m_countFalseFailed; }
  74. AZ_INLINE AZ::u32 GetCountFalseSucceeded() const { return m_countFalseSucceeded; }
  75. AZ_INLINE AZ::u32 GetCountGEFailed() const { return m_countGEFailed; }
  76. AZ_INLINE AZ::u32 GetCountGESucceeded() const { return m_countGESucceeded; }
  77. AZ_INLINE AZ::u32 GetCountGTFailed() const { return m_countGTFailed; }
  78. AZ_INLINE AZ::u32 GetCountGTSucceeded() const { return m_countGTSucceeded; }
  79. AZ_INLINE AZ::u32 GetCountLEFailed() const { return m_countLEFailed; }
  80. AZ_INLINE AZ::u32 GetCountLESucceeded() const { return m_countLESucceeded; }
  81. AZ_INLINE AZ::u32 GetCountLTFailed() const { return m_countLTFailed; }
  82. AZ_INLINE AZ::u32 GetCountLTSucceeded() const { return m_countLTSucceeded; }
  83. AZ_INLINE AZ::u32 GetCountNEFailed() const { return m_countNEFailed; }
  84. AZ_INLINE AZ::u32 GetCountNESucceeded() const { return m_countNESucceeded; }
  85. AZ_INLINE AZ::u32 GetCountTrueFailed() const { return m_countTrueFailed; }
  86. AZ_INLINE AZ::u32 GetCountTrueSucceeded() const { return m_countTrueSucceeded; }
  87. bool operator==(const MetaReporter& reporter) const;
  88. void ExpectFalse(const bool value, const Report& report) override;
  89. void ExpectTrue(const bool value, const Report& report) override;
  90. SCRIPT_CANVAS_UNIT_TEST_EQUALITY_OVERLOAD_OVERRIDES(ExpectEqual);
  91. SCRIPT_CANVAS_UNIT_TEST_EQUALITY_OVERLOAD_OVERRIDES(ExpectNotEqual);
  92. SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_OVERRIDES(ExpectGreaterThan);
  93. SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_OVERRIDES(ExpectGreaterThanEqual);
  94. SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_OVERRIDES(ExpectLessThan);
  95. SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_OVERRIDES(ExpectLessThanEqual);
  96. private:
  97. AZ::u32 m_countEQFailed = 0;
  98. AZ::u32 m_countEQSucceeded = 0;
  99. AZ::u32 m_countFalseFailed = 0;
  100. AZ::u32 m_countFalseSucceeded = 0;
  101. AZ::u32 m_countGEFailed = 0;
  102. AZ::u32 m_countGESucceeded = 0;
  103. AZ::u32 m_countGTFailed = 0;
  104. AZ::u32 m_countGTSucceeded = 0;
  105. AZ::u32 m_countLEFailed = 0;
  106. AZ::u32 m_countLESucceeded = 0;
  107. AZ::u32 m_countLTFailed = 0;
  108. AZ::u32 m_countLTSucceeded = 0;
  109. AZ::u32 m_countNEFailed = 0;
  110. AZ::u32 m_countNESucceeded = 0;
  111. AZ::u32 m_countTrueFailed = 0;
  112. AZ::u32 m_countTrueSucceeded = 0;
  113. }; // class MetaReporter
  114. bool MetaReporter::operator==(const MetaReporter& other) const
  115. {
  116. return m_countEQFailed == other.m_countEQFailed
  117. && m_countEQSucceeded == other.m_countEQSucceeded
  118. && m_countFalseFailed == other.m_countFalseFailed
  119. && m_countFalseSucceeded == other.m_countFalseSucceeded
  120. && m_countGEFailed == other.m_countGEFailed
  121. && m_countGESucceeded == other.m_countGESucceeded
  122. && m_countGTFailed == other.m_countGTFailed
  123. && m_countGTSucceeded == other.m_countGTSucceeded
  124. && m_countLEFailed == other.m_countLEFailed
  125. && m_countLESucceeded == other.m_countLESucceeded
  126. && m_countLTFailed == other.m_countLTFailed
  127. && m_countLTSucceeded == other.m_countLTSucceeded
  128. && m_countNEFailed == other.m_countNEFailed
  129. && m_countNESucceeded == other.m_countNESucceeded
  130. && m_countTrueSucceeded == other.m_countTrueSucceeded
  131. && m_countTrueFailed == other.m_countTrueFailed
  132. && *static_cast<const Reporter*>(this) == *static_cast<const Reporter*>(&other);
  133. }
  134. // Handler
  135. void MetaReporter::ExpectFalse(const bool value, const Report&)
  136. {
  137. if (!value)
  138. ++m_countFalseSucceeded;
  139. else
  140. ++m_countFalseFailed;
  141. }
  142. void MetaReporter::ExpectTrue(const bool value, const Report&)
  143. {
  144. if (value)
  145. ++m_countTrueSucceeded;
  146. else
  147. ++m_countTrueFailed;
  148. }
  149. void MetaReporter::ExpectEqual(const Data::NumberType lhs, const Data::NumberType rhs, const Report&)
  150. {
  151. if (AZ::IsClose(lhs, rhs, ScriptCanvas_UnitTestingCPP::k_tolerance))
  152. ++m_countEQSucceeded;
  153. else
  154. ++m_countEQFailed;
  155. }
  156. void MetaReporter::ExpectNotEqual(const Data::NumberType lhs, const Data::NumberType rhs, const Report&)
  157. {
  158. if (!AZ::IsClose(lhs, rhs, ScriptCanvas_UnitTestingCPP::k_tolerance))
  159. ++m_countNESucceeded;
  160. else
  161. ++m_countNEFailed;
  162. }
  163. SCRIPT_CANVAS_UNIT_TEST_EQUALITY_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectEqual, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_EQ)
  164. SCRIPT_CANVAS_UNIT_TEST_EQUALITY_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectNotEqual, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_NE)
  165. SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectGreaterThan, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_GT)
  166. SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectGreaterThanEqual, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_GE)
  167. SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectLessThan, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_LT)
  168. SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectLessThanEqual, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_EXPECT_LE)
  169. // Vector Implementations
  170. SCRIPT_CANVAS_UNIT_TEST_VECTOR_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectGreaterThan, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_GT)
  171. SCRIPT_CANVAS_UNIT_TEST_VECTOR_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectGreaterThanEqual, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_GE)
  172. SCRIPT_CANVAS_UNIT_TEST_VECTOR_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectLessThan, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_LT)
  173. SCRIPT_CANVAS_UNIT_TEST_VECTOR_COMPARE_OVERLOAD_IMPLEMENTATIONS(MetaReporter, ExpectLessThanEqual, SCRIPT_CANVAS_UNIT_TEST_META_REPORTER_VECTOR_EXPECT_LE)
  174. MetaReporter MetaRunUnitTestGraph(AZStd::string_view path)
  175. {
  176. MetaReporter interpretedReporter;
  177. const AZStd::string filePath = AZStd::string::format("%s/%s.%s", ScriptCanvas_UnitTestingCPP::k_unitTestDirPathRelative, path.data(), ScriptCanvas_UnitTestingCPP::k_defaultExtension);
  178. RunGraphSpec runGraphSpec;
  179. runGraphSpec.graphPath = filePath;
  180. runGraphSpec.dirPath = ScriptCanvas_UnitTestingCPP::k_unitTestDirPathRelative;
  181. runGraphSpec.runSpec.execution = ExecutionMode::Interpreted;
  182. ScriptCanvasEditor::RunGraphImplementation(runGraphSpec, interpretedReporter);
  183. EXPECT_TRUE(interpretedReporter.IsReportFinished());
  184. return interpretedReporter;
  185. }
  186. //////////////////////////////////////////////////////////////////////////
  187. // if this test doesn't pass, our fixture is broken, and our unit tests are meaningless
  188. //////////////////////////////////////////////////////////////////////////
  189. TEST_F(ScriptCanvasTestFixture, FixtureSanity)
  190. {
  191. SUCCEED();
  192. }
  193. //////////////////////////////////////////////////////////////////////////
  194. // if these tests do not pass, our SC unit test framework is broken, and such tests are meaningless
  195. //////////////////////////////////////////////////////////////////////////
  196. TEST_F(ScriptCanvasTestFixture, AddFailure)
  197. {
  198. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_AddFailure");
  199. if (!reporter.GetScriptCanvasId().IsValid())
  200. {
  201. ADD_FAILURE() << "Graph is not valid";
  202. return;
  203. }
  204. EXPECT_EQ(reporter.GetFailure().size(), 3);
  205. if (reporter.GetFailure().size() == 3)
  206. {
  207. EXPECT_EQ(reporter.GetFailure()[0], "zero");
  208. EXPECT_EQ(reporter.GetFailure()[1], "one");
  209. EXPECT_EQ(reporter.GetFailure()[2], "two");
  210. }
  211. EXPECT_TRUE(reporter.IsComplete());
  212. EXPECT_TRUE(reporter.IsDeactivated());
  213. EXPECT_FALSE(reporter.IsErrorFree());
  214. }
  215. TEST_F(ScriptCanvasTestFixture, AddSuccess)
  216. {
  217. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_AddSuccess");
  218. if (!reporter.GetScriptCanvasId().IsValid())
  219. {
  220. ADD_FAILURE() << "Graph is not valid";
  221. return;
  222. }
  223. EXPECT_EQ(reporter.GetSuccess().size(), 3);
  224. if (reporter.GetFailure().size() == 3)
  225. {
  226. EXPECT_EQ(reporter.GetSuccess()[0], "zero");
  227. EXPECT_EQ(reporter.GetSuccess()[1], "one");
  228. EXPECT_EQ(reporter.GetSuccess()[2], "two");
  229. }
  230. EXPECT_TRUE(reporter.IsComplete());
  231. EXPECT_TRUE(reporter.IsDeactivated());
  232. EXPECT_TRUE(reporter.IsErrorFree());
  233. }
  234. TEST_F(ScriptCanvasTestFixture, ExpectTrueFail)
  235. {
  236. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectTrueFail");
  237. if (!reporter.GetScriptCanvasId().IsValid())
  238. {
  239. ADD_FAILURE() << "Graph is not valid";
  240. return;
  241. }
  242. EXPECT_EQ(reporter.GetCountTrueSucceeded(), 0);
  243. EXPECT_EQ(reporter.GetCountTrueFailed(), 1);
  244. EXPECT_TRUE(reporter.IsErrorFree());
  245. }
  246. TEST_F(ScriptCanvasTestFixture, ExpectTrueSucceed)
  247. {
  248. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectTrueSucceed");
  249. if (!reporter.GetScriptCanvasId().IsValid())
  250. {
  251. ADD_FAILURE() << "Graph is not valid";
  252. return;
  253. }
  254. EXPECT_EQ(reporter.GetCountTrueSucceeded(), 1);
  255. EXPECT_EQ(reporter.GetCountTrueFailed(), 0);
  256. EXPECT_TRUE(reporter.IsErrorFree());
  257. }
  258. TEST_F(ScriptCanvasTestFixture, ExpectEqualFail)
  259. {
  260. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectEqualFail");
  261. if (!reporter.GetScriptCanvasId().IsValid())
  262. {
  263. ADD_FAILURE() << "Graph is not valid";
  264. return;
  265. }
  266. EXPECT_EQ(reporter.GetCountEQFailed(), 1);
  267. EXPECT_EQ(reporter.GetCountEQSucceeded(), 0);
  268. EXPECT_TRUE(reporter.IsComplete());
  269. EXPECT_TRUE(reporter.IsDeactivated());
  270. EXPECT_TRUE(reporter.IsErrorFree());
  271. }
  272. TEST_F(ScriptCanvasTestFixture, ExpectEqualSucceed)
  273. {
  274. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectEqualSucceed");
  275. if (!reporter.GetScriptCanvasId().IsValid())
  276. {
  277. ADD_FAILURE() << "Graph is not valid";
  278. return;
  279. }
  280. EXPECT_EQ(reporter.GetCountEQFailed(), 0);
  281. EXPECT_EQ(reporter.GetCountEQSucceeded(), 1);
  282. EXPECT_TRUE(reporter.IsComplete());
  283. EXPECT_TRUE(reporter.IsDeactivated());
  284. EXPECT_TRUE(reporter.IsErrorFree());
  285. }
  286. TEST_F(ScriptCanvasTestFixture, ExpectNotEqualFail)
  287. {
  288. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectNotEqualFail");
  289. if (!reporter.GetScriptCanvasId().IsValid())
  290. {
  291. ADD_FAILURE() << "Graph is not valid";
  292. return;
  293. }
  294. EXPECT_EQ(reporter.GetCountNEFailed(), 1);
  295. EXPECT_EQ(reporter.GetCountNESucceeded(), 0);
  296. EXPECT_TRUE(reporter.IsComplete());
  297. EXPECT_TRUE(reporter.IsDeactivated());
  298. EXPECT_TRUE(reporter.IsErrorFree());
  299. }
  300. TEST_F(ScriptCanvasTestFixture, ExpectNotEqualSucceed)
  301. {
  302. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectNotEqualSucceed");
  303. if (!reporter.GetScriptCanvasId().IsValid())
  304. {
  305. ADD_FAILURE() << "Graph is not valid";
  306. return;
  307. }
  308. EXPECT_EQ(reporter.GetCountNEFailed(), 0);
  309. EXPECT_EQ(reporter.GetCountNESucceeded(), 1);
  310. EXPECT_TRUE(reporter.IsComplete());
  311. EXPECT_TRUE(reporter.IsDeactivated());
  312. EXPECT_TRUE(reporter.IsErrorFree());
  313. }
  314. TEST_F(ScriptCanvasTestFixture, MarkCompleteFail)
  315. {
  316. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_MarkCompleteFail");
  317. if (!reporter.GetScriptCanvasId().IsValid())
  318. {
  319. ADD_FAILURE() << "Graph is not valid";
  320. return;
  321. }
  322. EXPECT_EQ(reporter.GetCountTrueSucceeded(), 1);
  323. EXPECT_FALSE(reporter.IsComplete());
  324. EXPECT_TRUE(reporter.IsDeactivated());
  325. EXPECT_TRUE(reporter.IsErrorFree());
  326. }
  327. TEST_F(ScriptCanvasTestFixture, MarkCompleteSucceed)
  328. {
  329. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_MarkCompleteSucceed");
  330. if (!reporter.GetScriptCanvasId().IsValid())
  331. {
  332. ADD_FAILURE() << "Graph is not valid";
  333. return;
  334. }
  335. EXPECT_EQ(reporter.GetCountTrueSucceeded(), 1);
  336. EXPECT_TRUE(reporter.IsComplete());
  337. EXPECT_TRUE(reporter.IsDeactivated());
  338. EXPECT_TRUE(reporter.IsErrorFree());
  339. }
  340. TEST_F(ScriptCanvasTestFixture, ExpectGreaterThanFail)
  341. {
  342. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectGreaterThanFail");
  343. if (!reporter.GetScriptCanvasId().IsValid())
  344. {
  345. ADD_FAILURE() << "Graph is not valid";
  346. return;
  347. }
  348. EXPECT_EQ(reporter.GetCountGTFailed(), 1);
  349. EXPECT_EQ(reporter.GetCountGTSucceeded(), 0);
  350. EXPECT_TRUE(reporter.IsComplete());
  351. EXPECT_TRUE(reporter.IsDeactivated());
  352. EXPECT_TRUE(reporter.IsErrorFree());
  353. }
  354. TEST_F(ScriptCanvasTestFixture, ExpectGreaterThanSucceed)
  355. {
  356. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectGreaterThanSucceed");
  357. if (!reporter.GetScriptCanvasId().IsValid())
  358. {
  359. ADD_FAILURE() << "Graph is not valid";
  360. return;
  361. }
  362. EXPECT_EQ(reporter.GetCountGTFailed(), 0);
  363. EXPECT_EQ(reporter.GetCountGTSucceeded(), 1);
  364. EXPECT_TRUE(reporter.IsComplete());
  365. EXPECT_TRUE(reporter.IsDeactivated());
  366. EXPECT_TRUE(reporter.IsErrorFree());
  367. }
  368. TEST_F(ScriptCanvasTestFixture, ExpectGreaterThanEqualFail)
  369. {
  370. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectGreaterThanEqualFail");
  371. if (!reporter.GetScriptCanvasId().IsValid())
  372. {
  373. ADD_FAILURE() << "Graph is not valid";
  374. return;
  375. }
  376. EXPECT_EQ(reporter.GetCountGEFailed(), 1);
  377. EXPECT_EQ(reporter.GetCountGESucceeded(), 0);
  378. EXPECT_TRUE(reporter.IsComplete());
  379. EXPECT_TRUE(reporter.IsDeactivated());
  380. EXPECT_TRUE(reporter.IsErrorFree());
  381. }
  382. TEST_F(ScriptCanvasTestFixture, ExpectGreaterThanEqualSucceed)
  383. {
  384. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectGreaterThanEqualSucceed");
  385. if (!reporter.GetScriptCanvasId().IsValid())
  386. {
  387. ADD_FAILURE() << "Graph is not valid";
  388. return;
  389. }
  390. EXPECT_EQ(reporter.GetCountGEFailed(), 0);
  391. EXPECT_EQ(reporter.GetCountGESucceeded(), 2);
  392. EXPECT_TRUE(reporter.IsComplete());
  393. EXPECT_TRUE(reporter.IsDeactivated());
  394. EXPECT_TRUE(reporter.IsErrorFree());
  395. }
  396. TEST_F(ScriptCanvasTestFixture, ExpectLessThanFail)
  397. {
  398. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectLessThanFail");
  399. if (!reporter.GetScriptCanvasId().IsValid())
  400. {
  401. ADD_FAILURE() << "Graph is not valid";
  402. return;
  403. }
  404. EXPECT_EQ(reporter.GetCountLTFailed(), 1);
  405. EXPECT_EQ(reporter.GetCountLTSucceeded(), 0);
  406. EXPECT_TRUE(reporter.IsComplete());
  407. EXPECT_TRUE(reporter.IsDeactivated());
  408. EXPECT_TRUE(reporter.IsErrorFree());
  409. }
  410. TEST_F(ScriptCanvasTestFixture, ExpectLessThanSucceed)
  411. {
  412. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectLessThanSucceed");
  413. if (!reporter.GetScriptCanvasId().IsValid())
  414. {
  415. ADD_FAILURE() << "Graph is not valid";
  416. return;
  417. }
  418. EXPECT_EQ(reporter.GetCountLTFailed(), 0);
  419. EXPECT_EQ(reporter.GetCountLTSucceeded(), 1);
  420. EXPECT_TRUE(reporter.IsComplete());
  421. EXPECT_TRUE(reporter.IsDeactivated());
  422. EXPECT_TRUE(reporter.IsErrorFree());
  423. }
  424. TEST_F(ScriptCanvasTestFixture, ExpectLessThanEqualFail)
  425. {
  426. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectLessThanEqualFail");
  427. if (!reporter.GetScriptCanvasId().IsValid())
  428. {
  429. ADD_FAILURE() << "Graph is not valid";
  430. return;
  431. }
  432. EXPECT_EQ(reporter.GetCountLEFailed(), 1);
  433. EXPECT_EQ(reporter.GetCountLESucceeded(), 0);
  434. EXPECT_TRUE(reporter.IsComplete());
  435. EXPECT_TRUE(reporter.IsDeactivated());
  436. EXPECT_TRUE(reporter.IsErrorFree());
  437. }
  438. TEST_F(ScriptCanvasTestFixture, ExpectLessThanEqualSucceed)
  439. {
  440. MetaReporter reporter = MetaRunUnitTestGraph("LY_SC_UnitTest_Meta_ExpectLessThanEqualSucceed");
  441. if (!reporter.GetScriptCanvasId().IsValid())
  442. {
  443. ADD_FAILURE() << "Graph is not valid";
  444. return;
  445. }
  446. EXPECT_EQ(reporter.GetCountLEFailed(), 0);
  447. EXPECT_EQ(reporter.GetCountLESucceeded(), 2);
  448. EXPECT_TRUE(reporter.IsComplete());
  449. EXPECT_TRUE(reporter.IsDeactivated());
  450. EXPECT_TRUE(reporter.IsErrorFree());
  451. }
  452. #endif