/* * 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 #include #include #include #include #include #define SCRIPT_CANVAS_UNIT_TEST_REPORTER_EXPECT_EQ(LHS, RHS)\ if(!(LHS == RHS)) { AddFailure(AZStd::string::format("Error | Expected (candidate) == (reference).\n%s", report.data())); } #define SCRIPT_CANVAS_UNIT_TEST_REPORTER_EXPECT_NE(LHS, RHS)\ if(!(LHS != RHS)) { AddFailure(AZStd::string::format("Error | Expected (candidate) != (reference).\n%s", report.data())); } #define SCRIPT_CANVAS_UNIT_TEST_REPORTER_EXPECT_GT(LHS, RHS)\ if(!(LHS > RHS)) { AddFailure(AZStd::string::format("Error | Expected (candidate) > (reference).\n%s", report.data())); } #define SCRIPT_CANVAS_UNIT_TEST_REPORTER_EXPECT_GE(LHS, RHS)\ if(!(LHS >= RHS)) { AddFailure(AZStd::string::format("Error | Expected (candidate) >= (reference).\n%s", report.data())); } #define SCRIPT_CANVAS_UNIT_TEST_REPORTER_EXPECT_LT(LHS, RHS)\ if(!(LHS < RHS)) { AddFailure(AZStd::string::format("Error | Expected (candidate) < (reference).\n%s", report.data())); } #define SCRIPT_CANVAS_UNIT_TEST_REPORTER_EXPECT_LE(LHS, RHS)\ if(!(LHS <= RHS)) { AddFailure(AZStd::string::format("Error | Expected (candidate) <= (reference).\n%s", report.data())); } namespace ScriptCanvasEditor { using namespace ScriptCanvas; using namespace ScriptCanvas::UnitTesting; class Reporter : public Bus::Handler , public AZ::EntityBus::Handler { public: Reporter(); Reporter(const ScriptCanvasId& graphID, const AZ::EntityId& entityID); ~Reporter(); void FinishReport(); void FinishReport(const bool inErrorState); const AZStd::vector& GetCheckpoints() const; const AZStd::vector& GetFailure() const; const ScriptCanvasId& GetScriptCanvasId() const; const AZStd::vector& GetSuccess() const; bool IsActivated() const; bool IsComplete() const; bool IsDeactivated() const; bool IsErrorFree() const; bool IsReportFinished() const; bool operator==(const Reporter& other) const; void Reset(); void SetGraph(const ScriptCanvasId& graphID, const AZ::EntityId& entityID); // Bus::Handler void AddFailure(const Report& report) override; void AddSuccess(const Report& report) override; void Checkpoint(const Report& report) override; void ExpectFalse(const bool value, const Report& report) override; void ExpectTrue(const bool value, const Report& report) override; void MarkComplete(const Report& report) override; SCRIPT_CANVAS_UNIT_TEST_EQUALITY_OVERLOAD_OVERRIDES(ExpectEqual); SCRIPT_CANVAS_UNIT_TEST_EQUALITY_OVERLOAD_OVERRIDES(ExpectNotEqual); SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_OVERRIDES(ExpectGreaterThan); SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_OVERRIDES(ExpectGreaterThanEqual); SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_OVERRIDES(ExpectLessThan); SCRIPT_CANVAS_UNIT_TEST_COMPARE_OVERLOAD_OVERRIDES(ExpectLessThanEqual); protected: void OnEntityActivated(const AZ::EntityId&) override; void OnEntityDeactivated(const AZ::EntityId&) override; private: bool m_graphIsActivated = false; bool m_graphIsDeactivated = false; bool m_graphIsComplete = false; bool m_graphIsErrorFree = false; bool m_isReportFinished = false; ScriptCanvasId m_scriptCanvasId; AZ::EntityId m_entityId; AZStd::vector m_checkpoints; AZStd::vector m_failures; AZStd::vector m_successes; }; // class Reporter } // namespace ScriptCanvasEditor #include "ScriptCanvasReporter.inl"