ezEngine  Milestone 9
ezTestFramework Class Reference

Public Types

typedef void(* OutputHandler) (ezTestOutput::Enum Type, const char *szMsg)
 
typedef std::function< ezDynamicArray< std::pair< ezString, ezString > >)> ImageDiffExtraInfoCallback
 A function to be called to add extra info to image diff output, that is not available from here. E.g. device specific info like driver version.
 
typedef std::function< void(bool)> ImageComparisonCallback
 

Public Member Functions

 ezTestFramework (const char *szTestName, const char *szAbsTestOutputDir, const char *szRelTestDataDir, int argc, const char **argv)
 
void CreateOutputFolder ()
 
const char * GetTestName () const
 
const char * GetAbsOutputPath () const
 
const char * GetRelTestDataPath () const
 
const char * GetAbsTestSettingsFilePath () const
 
void RegisterOutputHandler (OutputHandler Handler)
 
void GatherAllTests ()
 
void LoadTestOrder ()
 
void AutoSaveTestOrder ()
 
void SaveTestOrder (const char *const filePath)
 
void SetAllTestsEnabledStatus (bool bEnable)
 
void SetAllFailedTestsEnabledStatus ()
 
void GetTestSettingsFromCommandLine (int argc, const char **argv)
 
void ResetTests ()
 
ezTestAppRun RunTestExecutionLoop ()
 
void StartTests ()
 
void ExecuteNextTest ()
 
void EndTests ()
 
void AbortTests ()
 
ezUInt32 GetTestCount () const
 
ezUInt32 GetTestEnabledCount () const
 
ezUInt32 GetSubTestEnabledCount (ezUInt32 uiTestIndex) const
 
bool IsTestEnabled (ezUInt32 uiTestIndex) const
 
bool IsSubTestEnabled (ezUInt32 uiTestIndex, ezUInt32 uiSubTestIndex) const
 
void SetTestEnabled (ezUInt32 uiTestIndex, bool bEnabled)
 
void SetSubTestEnabled (ezUInt32 uiTestIndex, ezUInt32 uiSubTestIndex, bool bEnabled)
 
ezInt32 GetCurrentTestIndex ()
 
ezInt32 GetCurrentSubTestIndex ()
 
ezTestEntryGetTest (ezUInt32 uiTestIndex)
 
bool GetTestsRunning () const
 
TestSettings GetSettings () const
 
void SetSettings (const TestSettings &settings)
 
ezTestFrameworkResultGetTestResult ()
 
ezInt32 GetTotalErrorCount () const
 
ezInt32 GetTestsPassedCount () const
 
ezInt32 GetTestsFailedCount () const
 
double GetTotalTestDuration () const
 
void ScheduleImageComparison (ezUInt32 uiImageNumber, ezUInt32 uiMaxError)
 
bool IsImageComparisonScheduled () const
 
void GenerateComparisonImageName (ezUInt32 uiImageNumber, ezStringBuilder &sImgName)
 
void GetCurrentComparisonImageName (ezStringBuilder &sImgName)
 
void WriteImageDiffHtml (const char *fileName, ezImage &referenceImgRgb, ezImage &referenceImgAlpha, ezImage &capturedImgRgb, ezImage &capturedImgAlpha, ezImage &diffImgRgb, ezImage &diffImgAlpha, ezUInt32 uiError, ezUInt32 uiThreshold, ezUInt8 uiMinDiffRgb, ezUInt8 uiMaxDiffRgb, ezUInt8 uiMinDiffAlpha, ezUInt8 uiMaxDiffAlpha)
 Writes an Html file that contains test information and an image diff view for failed image comparisons.
 
bool PerformImageComparison (ezStringBuilder sImgName, const ezImage &img, ezUInt32 uiMaxError, char *szErrorMsg)
 
bool CompareImages (ezUInt32 uiImageNumber, ezUInt32 uiMaxError, char *szErrorMsg)
 
void SetImageDiffExtraInfoCallback (ImageDiffExtraInfoCallback provider)
 
void SetImageComparisonCallback (const ImageComparisonCallback &callback)
 A function to be called after every image comparison with a bool indicating if the images matched or not.
 

Static Public Member Functions

static EZ_ALWAYS_INLINE ezTestFrameworkGetInstance ()
 
static bool GetAssertOnTestFail ()
 Returns whether to asset on test fail, will return false if no debugger is attached to prevent crashing.
 
static void Output (ezTestOutput::Enum Type, const char *szMsg,...)
 
static void OutputArgs (ezTestOutput::Enum Type, const char *szMsg, va_list args)
 
static void Error (const char *szError, const char *szFile, ezInt32 iLine, const char *szFunction, const char *szMsg,...)
 
static void Error (const char *szError, const char *szFile, ezInt32 iLine, const char *szFunction, const char *szMsg, va_list args)
 
static void TestResult (ezInt32 iSubTestIndex, bool bSuccess, double fDuration)
 

Static Public Attributes

static const char * s_szTestBlockName = ""
 
static int s_iAssertCounter = 0
 
static bool s_bCallstackOnAssert = false
 

Protected Member Functions

void Initialize ()
 
void DeInitialize ()
 
virtual void ErrorImpl (const char *szError, const char *szFile, ezInt32 iLine, const char *szFunction, const char *szMsg)
 Will be called for test failures to record the location of the failure and forward the error to OutputImpl.
 
virtual void OutputImpl (ezTestOutput::Enum Type, const char *szMsg)
 Receives ezLog messages (via LogWriter) as well as test-framework internal logging. Any ezTestOutput::Error will cause the test to fail.
 
virtual void TestResultImpl (ezInt32 iSubTestIndex, bool bSuccess, double fDuration)
 
void FlushAsserts ()
 

Protected Attributes

ezInt32 m_iCurrentTestIndex = -1
 
ezInt32 m_iCurrentSubTestIndex = -1
 
bool m_bTestsRunning = false
 

The documentation for this class was generated from the following files: