void OnLoadPlugin(bool bReloading) { EZ_TEST_BOOL_MSG(g_iPluginState == -1, "Plugin is in an invalid state."); g_iPluginState = 1; EZ_TEST_BOOL(ezPlugin::FindPluginByName("ezFoundationTest_Plugin1") != nullptr); // should find itself ezCVarInt* pCVar = (ezCVarInt*) ezCVar::FindCVarByName("TestPlugin1InitCount"); if (pCVar) *pCVar = *pCVar + 1; if (bReloading) { ezCVarInt* pCVarReload = (ezCVarInt*) ezCVar::FindCVarByName("TestPlugin1Reloaded"); if (pCVarReload) *pCVarReload = *pCVarReload + 1; } ezCVarBool* pCVarPlugin2Inited = (ezCVarBool*) ezCVar::FindCVarByName("test2_Inited"); if (pCVarPlugin2Inited) { EZ_TEST_BOOL(*pCVarPlugin2Inited == false); // Although Plugin2 is present, it should not yet have been initialized } }
void OnUnloadPlugin(bool bReloading) { EZ_TEST_BOOL_MSG(g_iPluginState == 1, "Plugin is in an invalid state."); g_iPluginState = 2; ezCVarInt* pCVar = (ezCVarInt*) ezCVar::FindCVarByName("TestPlugin1UninitCount"); if (pCVar) *pCVar = *pCVar + 1; if (bReloading) { ezCVarInt* pCVarReload = (ezCVarInt*) ezCVar::FindCVarByName("TestPlugin1Reloaded"); if (pCVarReload) *pCVarReload = *pCVarReload + 1; } }
virtual ezTestAppRun RunSubTest(ezInt32 iIdentifier, ezUInt32 uiInvocationCount) override { ezImageFormat::Enum format = static_cast<ezImageFormat::Enum>(iIdentifier); bool isDecodable = ezImageConversion::IsConvertible(format, defaultFormat); if (!isDecodable) { EZ_TEST_BOOL_MSG(false, "Format %s can be encoded from %s but not decoded - add a decoder for this format please", ezImageFormat::GetName(format), ezImageFormat::GetName(defaultFormat)); return ezTestAppRun::Quit; } { ezHybridArray<ezImageConversion::ConversionPathNode, 16> decodingPath; ezUInt32 decodingPathScratchBuffers; ezImageConversion::BuildPath(format, defaultFormat, false, decodingPath, decodingPathScratchBuffers); // the [test] tag tells the test framework to output the log message in the GUI ezLog::Info("[test]Default decoding Path:"); for (ezUInt32 i = 0; i < decodingPath.GetCount(); ++i) { ezLog::Info("[test] {} -> {}", ezImageFormat::GetName(decodingPath[i].m_sourceFormat), ezImageFormat::GetName(decodingPath[i].m_targetFormat)); } } { ezHybridArray<ezImageConversion::ConversionPathNode, 16> encodingPath; ezUInt32 encodingPathScratchBuffers; ezImageConversion::BuildPath(defaultFormat, format, false, encodingPath, encodingPathScratchBuffers); // the [test] tag tells the test framework to output the log message in the GUI ezLog::Info("[test]Default encoding Path:"); for (ezUInt32 i = 0; i < encodingPath.GetCount(); ++i) { ezLog::Info("[test] {} -> {}", ezImageFormat::GetName(encodingPath[i].m_sourceFormat), ezImageFormat::GetName(encodingPath[i].m_targetFormat)); } } // Test LDR: Load, encode to target format, then do image comparison (which internally decodes to BGR8_UNORM again). // This visualizes quantization for low bit formats, block compression artifacts, or whether formats have fewer than 3 channels. { EZ_TEST_BOOL(m_image.LoadFrom("ImageConversions/reference.png").Succeeded()); EZ_TEST_BOOL(m_image.Convert(format).Succeeded()); EZ_TEST_IMAGE(iIdentifier * 2, ezImageFormat::IsCompressed(format) ? 10 : 0); } // Test HDR: Load, decode to FLOAT32, stretch to [-range, range] and encode; // then decode to FLOAT32 again, bring back into LDR range and do image comparison. // If the format doesn't support negative values, the left half of the image will be black. // If the format doesn't support values with absolute value > 1, the image will appear clipped to fullbright. // Also, fill the first few rows in the top left with Infinity, -Infinity, and NaN, which should // show up as White, White, and Black, resp., in the comparison. { const float range = 8; EZ_TEST_BOOL(m_image.LoadFrom("ImageConversions/reference.png").Succeeded()); EZ_TEST_BOOL(m_image.Convert(ezImageFormat::R32G32B32A32_FLOAT).Succeeded()); float posInf = +ezMath::BasicType<float>::GetInfinity(); float negInf = -ezMath::BasicType<float>::GetInfinity(); float NaN = ezMath::BasicType<float>::GetNaN(); for (ezUInt32 y = 0; y < m_image.GetHeight(); ++y) { ezColor* pPixelPointer = m_image.GetPixelPointer<ezColor>(0, 0, 0, 0, y); for (ezUInt32 x = 0; x < m_image.GetWidth(); ++x) { // Fill with Inf or Nan resp. scale the image into positive and negative HDR range if (x < 30 && y < 10) { *pPixelPointer = ezColor(posInf, posInf, posInf, posInf); } else if (x < 30 && y < 20) { *pPixelPointer = ezColor(negInf, negInf, negInf, negInf); } else if (x < 30 && y < 30) { *pPixelPointer = ezColor(NaN, NaN, NaN, NaN); } else { float scale = (x / float(m_image.GetWidth()) - 0.5f) * 2.0f * range; if (ezMath::Abs(scale) > 0.5) { *pPixelPointer *= scale; } } pPixelPointer++; } } EZ_TEST_BOOL(m_image.Convert(format).Succeeded()); EZ_TEST_BOOL(m_image.Convert(ezImageFormat::R32G32B32A32_FLOAT).Succeeded()); for (ezUInt32 y = 0; y < m_image.GetHeight(); ++y) { ezColor* pPixelPointer = m_image.GetPixelPointer<ezColor>(0, 0, 0, 0, y); for (ezUInt32 x = 0; x < m_image.GetWidth(); ++x) { // Scale the image back into LDR range if possible if (x < 30 && y < 10) { // Leave pos inf as is - this should be clipped to 1 in the LDR conversion for img cmp } else if (x < 30 && y < 20) { // Flip neg inf to pos inf *pPixelPointer *= -1.0f; } else if (x < 30 && y < 30) { // Leave nan as is - this should be clipped to 0 in the LDR conversion for img cmp } else { float scale = (x / float(m_image.GetWidth()) - 0.5f) * 2.0f * range; if (ezMath::Abs(scale) > 0.5) { *pPixelPointer /= scale; } } pPixelPointer++; } } EZ_TEST_IMAGE(iIdentifier * 2 + 1, ezImageFormat::IsCompressed(format) ? 10 : 0); } return ezTestAppRun::Quit; }