Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: Fix an issue with SDK image testing #1693

Merged
merged 7 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/public/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class F3D_EXPORT image
* Please note, due to possible arithmetic imprecision in the SSIM computation
* using a threshold of zero may return false with identical images.
* Depending on the VTK version, another comparison algorithm may be used.
* Threshold should be in range [0, 1[, this returns false otherwise.
* 1e-14: Pixel perfect comparison.
* 0.05: Visually indistinguishable.
* 0.1: Small visible difference.
Expand Down
7 changes: 7 additions & 0 deletions library/src/image.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ void* image::getContent() const
//----------------------------------------------------------------------------
bool image::compare(const image& reference, double threshold, double& error) const
{
// Sanity check for threshold
if (threshold < 0 || threshold >= 1)
{
error = 1;
return false;
}

ChannelType type = this->getChannelType();
if (type != reference.getChannelType())
{
Expand Down
2 changes: 1 addition & 1 deletion library/testing/TestSDKCompareWithFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int TestSDKCompareWithFile(int argc, char* argv[])
sce.add(std::string(argv[1]) + "/data/cow.vtp");

return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKCompareWithFile", 50)
std::string(argv[2]), "TestSDKCompareWithFile")
? EXIT_SUCCESS
: EXIT_FAILURE;
}
2 changes: 1 addition & 1 deletion library/testing/TestSDKDropZone.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int TestSDKDropZone(int argc, char* argv[])
win.render();

return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDropZone", 50)
std::string(argv[2]), "TestSDKDropZone")
? EXIT_SUCCESS
: EXIT_FAILURE;
}
2 changes: 1 addition & 1 deletion library/testing/TestSDKDynamicBackgroundColor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int TestSDKDynamicBackgroundColor(int argc, char* argv[])
opt.render.background.color = { 1.0, 1.0, 1.0 };

return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicBackgrounColor", 50)
std::string(argv[2]), "TestSDKDynamicBackgrounColor")
? EXIT_SUCCESS
: EXIT_FAILURE;
}
2 changes: 1 addition & 1 deletion library/testing/TestSDKDynamicFontFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int TestSDKDynamicFontFile(int argc, char* argv[])
opt.ui.font_file = std::string(argv[1]) + "data/Crosterian.ttf";

return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicFontFile", 50)
std::string(argv[2]), "TestSDKDynamicFontFile")
? EXIT_SUCCESS
: EXIT_FAILURE;
}
10 changes: 5 additions & 5 deletions library/testing/TestSDKDynamicHDRI.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int TestSDKDynamicHDRI(int argc, char* argv[])
opt.render.hdri.ambient = true;
opt.render.background.skybox = true;
ret = TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicHDRIDefault", 120);
std::string(argv[2]), "TestSDKDynamicHDRIDefault");
if (!ret)
{
std::cerr << "Render with Default HDRI failed" << std::endl;
Expand All @@ -52,7 +52,7 @@ int TestSDKDynamicHDRI(int argc, char* argv[])
// Change the hdri and make sure it is taken into account
opt.render.hdri.file = std::string(argv[1]) + "data/palermo_park_1k.hdr";
ret = TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicHDRI", 50);
std::string(argv[2]), "TestSDKDynamicHDRI");
if (!ret)
{
std::cerr << "Render with HDRI failed" << std::endl;
Expand All @@ -70,7 +70,7 @@ int TestSDKDynamicHDRI(int argc, char* argv[])
// Force a cache path change to force a LUT reconfiguration and test dynamic cache path
eng.setCachePath(std::string(argv[2]) + "/cache_" + std::to_string(dist(e1)));
ret = TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicHDRI", 50);
std::string(argv[2]), "TestSDKDynamicHDRI");
if (!ret)
{
std::cerr << "Render with HDRI with another cache path failed" << std::endl;
Expand All @@ -80,7 +80,7 @@ int TestSDKDynamicHDRI(int argc, char* argv[])
// Use an existing cache
eng.setCachePath(cachePath);
ret = TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicHDRI", 50);
std::string(argv[2]), "TestSDKDynamicHDRI");
if (!ret)
{
std::cerr << "Render with HDRI with existing cache path failed" << std::endl;
Expand All @@ -91,7 +91,7 @@ int TestSDKDynamicHDRI(int argc, char* argv[])
// Change the hdri and make sure it is taken into account
opt.render.hdri.file = std::string(argv[1]) + "/data/kloofendal_43d_clear_1k.exr";
ret = TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicHDRIExr", 50);
std::string(argv[2]), "TestSDKDynamicHDRIExr");

if (!ret)
{
Expand Down
6 changes: 3 additions & 3 deletions library/testing/TestSDKDynamicLightIntensity.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int TestSDKDynamicLightIntensity(int argc, char* argv[])

// Check render with default light intensity
if (!TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicLightIntensity-default", 50))
std::string(argv[2]), "TestSDKDynamicLightIntensity-default"))
{
std::cerr << "failed for default light intensity" << std::endl;
return EXIT_FAILURE;
Expand All @@ -28,7 +28,7 @@ int TestSDKDynamicLightIntensity(int argc, char* argv[])
// set light intensity to 5x brighter
opt.render.light.intensity = 5.;
if (!TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicLightIntensity-5x-brighter", 50))
std::string(argv[2]), "TestSDKDynamicLightIntensity-5x-brighter"))
{
std::cerr << "failed for light intensity = 5" << std::endl;
return EXIT_FAILURE;
Expand All @@ -37,7 +37,7 @@ int TestSDKDynamicLightIntensity(int argc, char* argv[])
// set light intensity to 5x darker
opt.render.light.intensity = .2;
if (!TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicLightIntensity-5x-darker", 50))
std::string(argv[2]), "TestSDKDynamicLightIntensity-5x-darker"))
{
std::cerr << "failed for light intensity = .2" << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion library/testing/TestSDKDynamicProperties.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int TestSDKDynamicProperties(int argc, char* argv[])
opt.model.color.opacity = 0.6;

return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/",
std::string(argv[2]), "TestSDKDynamicProperties", 50)
std::string(argv[2]), "TestSDKDynamicProperties")
? EXIT_SUCCESS
: EXIT_FAILURE;
}
2 changes: 1 addition & 1 deletion library/testing/TestSDKHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static bool RenderTest(const f3d::image& img, const std::string& baselinePath,
}

static bool RenderTest(f3d::window& win, const std::string& baselinePath,
const std::string& outputPath, const std::string& name, double threshold = 50,
const std::string& outputPath, const std::string& name, double threshold = 0.05,
bool noBackground = false)
{
return TestSDKHelpers::RenderTest(
Expand Down
Loading