Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,127 @@
/*
* 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/Component/Entity.h>
#include <AzCore/Component/EntityBus.h>
#include <AzCore/Component/EntityId.h>
#include <ScriptCanvas/Data/Data.h>
#include <ScriptCanvas/Libraries/UnitTesting/UnitTestBus.h>
#include <ScriptCanvas/Execution/RuntimeComponent.h>
#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<Report>& GetCheckpoints() const;
const AZStd::vector<Report>& GetFailure() const;
const ScriptCanvasId& GetScriptCanvasId() const;
const AZStd::vector<Report>& 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<Report> m_checkpoints;
AZStd::vector<Report> m_failures;
AZStd::vector<Report> m_successes;
}; // class Reporter
} // namespace ScriptCanvasEditor
#include "ScriptCanvasReporter.inl"