LkEngine 0.1.2
 
Loading...
Searching...
No Matches
TestManager.h
1#pragma once
2
6#include <LkEngine/Core/LObject/ObjectPtr.h>
7
8#include "LTesto/Core/AutomationTest.h"
9
10namespace LkEngine {
11
13 {
14 public:
15 LTestManager() = default;
16 ~LTestManager() = default;
17
18 static LTestManager& Get();
19
24 CORE_API bool RegisterAutomationTest(const std::string& TestName, Test::LAutomationTest* InTestInstance);
25
30 CORE_API bool UnregisterAutomationTest(const std::string& TestName, Test::LAutomationTest* InTestInstance);
31
32 CORE_API void RunTests(const Test::ETestSuite Suite = Test::ETestSuite::All) const;
33
37 CORE_API bool StartTest(const std::string& TestName);
38
42 CORE_API bool StopTest(const std::string& TestName);
43
48 {
49 return CurrentTest;
50 }
51
52 FORCEINLINE CORE_API void SetCaptureStack(const bool Enabled)
53 {
54 bCaptureStack = Enabled;
55 }
56
61 using FTestCreator = std::function<std::shared_ptr<Test::LAutomationTest>()>;
62
67 void AddToSuite(const Test::ETestSuite Suite, FTestCreator CreatorFunc)
68 {
69 /* TODO: Cannot use log macros here because the registration takes place before the logger is instantiated.
70 * Needs to be fixed. */
71 //LK_PRINTLN("[TestManager] Registering test {} to suite '{}'", TestCreatorMap[Suite].size() + 1, Enum::ToString(Suite));
72 TestCreatorMap[Suite].push_back(std::move(CreatorFunc));
73 }
74
75 const std::vector<FTestCreator>& GetTests(const Test::ETestSuite Suite) const
76 {
77 static const std::vector<FTestCreator> EmptySuite;
78 auto Iter = TestCreatorMap.find(Suite);
79 return (Iter != TestCreatorMap.end()) ? Iter->second : EmptySuite;
80 }
81
82 public:
86 std::unordered_map<std::string, Test::LAutomationTest*> TestInstanceMap{};
87
91 std::unordered_map<Test::ETestSuite, std::vector<FTestCreator>> TestCreatorMap;
92
93 private:
94 CORE_API static bool bCaptureStack;
95
96 Test::LAutomationTest* CurrentTest = nullptr;
97 };
98
99}
Core macros used by the entire engine.
Core types.
LObject implementation.
Definition TestManager.h:13
CORE_API bool StartTest(const std::string &TestName)
Definition TestManager.cpp:118
void AddToSuite(const Test::ETestSuite Suite, FTestCreator CreatorFunc)
Definition TestManager.h:67
CORE_API bool RegisterAutomationTest(const std::string &TestName, Test::LAutomationTest *InTestInstance)
Definition TestManager.cpp:22
CORE_API bool UnregisterAutomationTest(const std::string &TestName, Test::LAutomationTest *InTestInstance)
Definition TestManager.cpp:43
CORE_API bool StopTest(const std::string &TestName)
Definition TestManager.cpp:145
std::unordered_map< std::string, Test::LAutomationTest * > TestInstanceMap
Test instances.
Definition TestManager.h:86
std::function< std::shared_ptr< Test::LAutomationTest >()> FTestCreator
Definition TestManager.h:61
Test::LAutomationTest * GetCurrentTest() const
Definition TestManager.h:47
std::unordered_map< Test::ETestSuite, std::vector< FTestCreator > > TestCreatorMap
Definition TestManager.h:91
Definition AutomationTest.h:52
Definition Asset.h:11