BVB Source Codes

CRYENGINE Show FlowGraphDebuggerUnitTests.cpp Source code

Return Download CRYENGINE: download FlowGraphDebuggerUnitTests.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   FlowGraphDebuggerUnitTests.cpp
  5. //  Version:     v1.00
  6. //  Created:     02/11/2013 by Sascha Hoba.
  7. //  Description:
  8. // -------------------------------------------------------------------------
  9. //  History:
  10. //
  11. ////////////////////////////////////////////////////////////////////////////
  12.  
  13. #include "StdAfx.h"
  14.  
  15. #if defined(CRY_UNIT_TESTING)
  16.  
  17.         #include <CryFlowGraph/IFlowGraphDebugger.h>
  18.         #include <CryFlowGraph/IFlowSystem.h>
  19.  
  20. CRY_UNIT_TEST_SUITE(CryFlowgraphDebuggerUnitTest)
  21. {
  22.         namespace FGD_UT_HELPER
  23.         {
  24.         IFlowGraphDebuggerPtr GetFlowGraphDebugger()
  25.         {
  26.                 IFlowGraphDebuggerPtr pFlowgraphDebugger = GetIFlowGraphDebuggerPtr();
  27.                 CRY_UNIT_TEST_ASSERT(pFlowgraphDebugger.get() != NULL);
  28.                 return pFlowgraphDebugger;
  29.         }
  30.  
  31.         IFlowGraphPtr CreateFlowGraph()
  32.         {
  33.                 CRY_UNIT_TEST_ASSERT(gEnv->pFlowSystem != NULL);
  34.                 IFlowGraphPtr pFlowGraph = gEnv->pFlowSystem->CreateFlowGraph();
  35.                 CRY_UNIT_TEST_ASSERT(pFlowGraph.get() != NULL);
  36.                 return pFlowGraph;
  37.         }
  38.  
  39.         TFlowNodeId CreateTestNode(IFlowGraphPtr pFlowGraph, const TFlowNodeTypeId& typeID)
  40.         {
  41.                 const TFlowNodeId flowNodeID = pFlowGraph->CreateNode(typeID, "UnitTestNode");
  42.                 CRY_UNIT_TEST_ASSERT(flowNodeID != InvalidFlowNodeId);
  43.                 return flowNodeID;
  44.         }
  45.  
  46.         void AddBreakPoint(IFlowGraphDebuggerPtr pFlowGraphDebugger, IFlowGraphPtr pFlowGraph, const SFlowAddress& addrIn)
  47.         {
  48.                 DynArray<SBreakPoint> breakpointsDynArray;
  49.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->AddBreakpoint(pFlowGraph, addrIn));
  50.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->GetBreakpoints(breakpointsDynArray));
  51.                 CRY_UNIT_TEST_CHECK_EQUAL(breakpointsDynArray.size(), 1);
  52.  
  53.                 SBreakPoint breakpoint = breakpointsDynArray[0];
  54.                 CRY_UNIT_TEST_ASSERT(breakpoint.flowGraph == pFlowGraph);
  55.                 CRY_UNIT_TEST_ASSERT(breakpoint.addr == addrIn);
  56.                 breakpointsDynArray.clear();
  57.                 CRY_UNIT_TEST_ASSERT(breakpointsDynArray.empty());
  58.         }
  59.         }
  60.  
  61.         CRY_UNIT_TEST(CUT_INVALID_FLOWGRAPH_BREAKPOINT)
  62.         {
  63.                 IFlowGraphDebuggerPtr pFlowGraphDebugger = FGD_UT_HELPER::GetFlowGraphDebugger();
  64.                 const SBreakPoint& breakpoint = pFlowGraphDebugger->GetBreakpoint();
  65.  
  66.                 CRY_UNIT_TEST_CHECK_EQUAL(breakpoint.type, eBT_Invalid);
  67.                 CRY_UNIT_TEST_CHECK_EQUAL(breakpoint.edgeIndex, -1);
  68.                 CRY_UNIT_TEST_ASSERT(breakpoint.flowGraph.get() == NULL);
  69.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->BreakpointHit(), false);
  70.         }
  71.  
  72.         CRY_UNIT_TEST(CUT_ADD_REMOVE_FLOWGRAPH_BREAKPOINT)
  73.         {
  74.                 IFlowGraphPtr pFlowGraph = FGD_UT_HELPER::CreateFlowGraph();
  75.                 const TFlowNodeTypeId typeID = gEnv->pFlowSystem->GetTypeId("Logic:Any");
  76.                 CRY_UNIT_TEST_ASSERT(typeID != InvalidFlowNodeTypeId);
  77.                 const TFlowNodeId flowNodeID = FGD_UT_HELPER::CreateTestNode(pFlowGraph, typeID);
  78.  
  79.                 SFlowAddress addrIn;
  80.                 addrIn.isOutput = false;
  81.                 addrIn.node = flowNodeID;
  82.                 addrIn.port = 0;
  83.  
  84.                 IFlowGraphDebuggerPtr pFlowGraphDebugger = FGD_UT_HELPER::GetFlowGraphDebugger();
  85.  
  86.                 FGD_UT_HELPER::AddBreakPoint(pFlowGraphDebugger, pFlowGraph, addrIn);
  87.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, addrIn));
  88.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->RemoveBreakpoint(pFlowGraph, addrIn));
  89.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, addrIn), false);
  90.  
  91.                 FGD_UT_HELPER::AddBreakPoint(pFlowGraphDebugger, pFlowGraph, addrIn);
  92.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, flowNodeID));
  93.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->RemoveAllBreakpointsForNode(pFlowGraph, flowNodeID));
  94.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, flowNodeID), false);
  95.  
  96.                 FGD_UT_HELPER::AddBreakPoint(pFlowGraphDebugger, pFlowGraph, addrIn);
  97.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->HasBreakpoint(pFlowGraph));
  98.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->RemoveAllBreakpointsForGraph(pFlowGraph));
  99.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph), false);
  100.  
  101.                 FGD_UT_HELPER::AddBreakPoint(pFlowGraphDebugger, pFlowGraph, addrIn);
  102.                 pFlowGraphDebugger->ClearBreakpoints();
  103.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, addrIn), false);
  104.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, flowNodeID), false);
  105.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph), false);
  106.  
  107.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->BreakpointHit(), false);
  108.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->GetRootGraph(pFlowGraph) == pFlowGraph);
  109.         }
  110.  
  111.         CRY_UNIT_TEST(CUT_ENABLE_DISABLE_FLOWGRAPH_BREAKPOINT)
  112.         {
  113.                 IFlowGraphPtr pFlowGraph = FGD_UT_HELPER::CreateFlowGraph();
  114.                 const TFlowNodeTypeId typeID = gEnv->pFlowSystem->GetTypeId("Logic:Any");
  115.                 CRY_UNIT_TEST_ASSERT(typeID != InvalidFlowNodeTypeId);
  116.                 const TFlowNodeId flowNodeID = FGD_UT_HELPER::CreateTestNode(pFlowGraph, typeID);
  117.  
  118.                 SFlowAddress addrIn;
  119.                 addrIn.isOutput = false;
  120.                 addrIn.node = flowNodeID;
  121.                 addrIn.port = 0;
  122.  
  123.                 IFlowGraphDebuggerPtr pFlowGraphDebugger = FGD_UT_HELPER::GetFlowGraphDebugger();
  124.                 FGD_UT_HELPER::AddBreakPoint(pFlowGraphDebugger, pFlowGraph, addrIn);
  125.  
  126.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->IsBreakpointEnabled(pFlowGraph, addrIn));
  127.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->IsTracepoint(pFlowGraph, addrIn), false);
  128.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->EnableBreakpoint(pFlowGraph, addrIn, false));
  129.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->IsBreakpointEnabled(pFlowGraph, addrIn), false);
  130.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->EnableBreakpoint(pFlowGraph, addrIn, true));
  131.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->IsBreakpointEnabled(pFlowGraph, addrIn));
  132.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->IsTracepoint(pFlowGraph, addrIn), false);
  133.  
  134.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->EnableTracepoint(pFlowGraph, addrIn, true));
  135.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->IsTracepoint(pFlowGraph, addrIn));
  136.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->IsBreakpointEnabled(pFlowGraph, addrIn));
  137.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->EnableTracepoint(pFlowGraph, addrIn, false));
  138.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->IsTracepoint(pFlowGraph, addrIn), false);
  139.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->IsBreakpointEnabled(pFlowGraph, addrIn));
  140.  
  141.                 pFlowGraphDebugger->ClearBreakpoints();
  142.  
  143.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->IsBreakpointEnabled(pFlowGraph, addrIn), false);
  144.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->IsTracepoint(pFlowGraph, addrIn), false);
  145.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, addrIn), false);
  146.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, flowNodeID), false);
  147.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph), false);
  148.  
  149.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->BreakpointHit(), false);
  150.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->GetRootGraph(pFlowGraph) == pFlowGraph);
  151.         }
  152.  
  153.         CRY_UNIT_TEST(CUT_TRIGGER_FLOWGRAPH_BREAKPOINT)
  154.         {
  155.                 if (!gEnv->IsEditor())
  156.                         return;
  157.  
  158.                 ICVar* pNodeDebuggingCVar = gEnv->pConsole->GetCVar("fg_iEnableFlowgraphNodeDebugging");
  159.                 const int oldNodeDebuggingValue = pNodeDebuggingCVar->GetIVal();
  160.                 pNodeDebuggingCVar->Set(1);
  161.  
  162.                 IFlowGraphPtr pFlowGraph = FGD_UT_HELPER::CreateFlowGraph();
  163.                 const TFlowNodeTypeId typeID = gEnv->pFlowSystem->GetTypeId("Logic:Any");
  164.                 CRY_UNIT_TEST_ASSERT(typeID != InvalidFlowNodeTypeId);
  165.                 const TFlowNodeId flowNodeID = FGD_UT_HELPER::CreateTestNode(pFlowGraph, typeID);
  166.                 pFlowGraph->InitializeValues();
  167.  
  168.                 SFlowAddress addrIn;
  169.                 addrIn.isOutput = true;
  170.                 addrIn.node = flowNodeID;
  171.                 addrIn.port = 0;
  172.  
  173.                 IFlowGraphDebuggerPtr pFlowGraphDebugger = FGD_UT_HELPER::GetFlowGraphDebugger();
  174.                 FGD_UT_HELPER::AddBreakPoint(pFlowGraphDebugger, pFlowGraph, addrIn);
  175.  
  176.                 pFlowGraph->ActivatePortCString(addrIn, "UnitTestActivation");
  177.  
  178.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->BreakpointHit(), true);
  179.  
  180.                 const SBreakPoint& breakpoint = pFlowGraphDebugger->GetBreakpoint();
  181.  
  182.                 CRY_UNIT_TEST_CHECK_EQUAL(breakpoint.type, eBT_Output_Without_Edges);
  183.                 CRY_UNIT_TEST_CHECK_EQUAL(breakpoint.edgeIndex, -1);
  184.                 CRY_UNIT_TEST_ASSERT(breakpoint.flowGraph == pFlowGraph);
  185.  
  186.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, addrIn));
  187.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, flowNodeID));
  188.                 CRY_UNIT_TEST_ASSERT(pFlowGraphDebugger->HasBreakpoint(pFlowGraph));
  189.  
  190.                 pFlowGraphDebugger->InvalidateBreakpoint();
  191.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->BreakpointHit(), false);
  192.                 pFlowGraphDebugger->ClearBreakpoints();
  193.  
  194.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, addrIn), false);
  195.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph, flowNodeID), false);
  196.                 CRY_UNIT_TEST_CHECK_EQUAL(pFlowGraphDebugger->HasBreakpoint(pFlowGraph), false);
  197.  
  198.                 pNodeDebuggingCVar->Set(oldNodeDebuggingValue);
  199.         }
  200. }
  201.  
  202. #endif // UNITTESTING_ENABLED
  203.  
downloadFlowGraphDebuggerUnitTests.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top