|
|
|
|
@ -76,6 +76,7 @@ struct CompareImageTest: TestSuite::Tester {
|
|
|
|
|
void compareAboveThresholds(); |
|
|
|
|
void compareAboveMaxThreshold(); |
|
|
|
|
void compareAboveMeanThreshold(); |
|
|
|
|
void compareNonZeroThreshold(); |
|
|
|
|
void compareSpecials(); |
|
|
|
|
void compareSpecialsMeanOnly(); |
|
|
|
|
void compareSpecialsDisallowedThreshold(); |
|
|
|
|
@ -83,29 +84,36 @@ struct CompareImageTest: TestSuite::Tester {
|
|
|
|
|
void setupExternalPluginManager(); |
|
|
|
|
void teardownExternalPluginManager(); |
|
|
|
|
|
|
|
|
|
void image(); |
|
|
|
|
void imageZeroDelta(); |
|
|
|
|
void imageNonZeroDelta(); |
|
|
|
|
void imageError(); |
|
|
|
|
void imageFile(); |
|
|
|
|
void imageFileZeroDelta(); |
|
|
|
|
void imageFileNonZeroDelta(); |
|
|
|
|
void imageFileError(); |
|
|
|
|
void imageFilePluginLoadFailed(); |
|
|
|
|
void imageFileActualLoadFailed(); |
|
|
|
|
void imageFileExpectedLoadFailed(); |
|
|
|
|
void imageFileActualIsCompressed(); |
|
|
|
|
void imageFileExpectedIsCompressed(); |
|
|
|
|
void imageToFile(); |
|
|
|
|
void imageToFileZeroDelta(); |
|
|
|
|
void imageToFileNonZeroDelta(); |
|
|
|
|
void imageToFileError(); |
|
|
|
|
void imageToFilePluginLoadFailed(); |
|
|
|
|
void imageToFileExpectedLoadFailed(); |
|
|
|
|
void imageToFileExpectedIsCompressed(); |
|
|
|
|
void fileToImage(); |
|
|
|
|
void fileToImageZeroDelta(); |
|
|
|
|
void fileToImageNonZeroDelta(); |
|
|
|
|
void fileToImageError(); |
|
|
|
|
void fileToImagePluginLoadFailed(); |
|
|
|
|
void fileToImageActualLoadFailed(); |
|
|
|
|
void fileToImageActualIsCompressed(); |
|
|
|
|
|
|
|
|
|
void pixelsToImage(); |
|
|
|
|
void pixelsToImageZeroDelta(); |
|
|
|
|
void pixelsToImageNonZeroDelta(); |
|
|
|
|
void pixelsToImageError(); |
|
|
|
|
void pixelsToFile(); |
|
|
|
|
void pixelsToFileZeroDelta(); |
|
|
|
|
void pixelsToFileNonZeroDelta(); |
|
|
|
|
void pixelsToFileError(); |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
@ -138,14 +146,17 @@ CompareImageTest::CompareImageTest() {
|
|
|
|
|
&CompareImageTest::compareAboveThresholds, |
|
|
|
|
&CompareImageTest::compareAboveMaxThreshold, |
|
|
|
|
&CompareImageTest::compareAboveMeanThreshold, |
|
|
|
|
&CompareImageTest::compareNonZeroThreshold, |
|
|
|
|
&CompareImageTest::compareSpecials, |
|
|
|
|
&CompareImageTest::compareSpecialsMeanOnly, |
|
|
|
|
&CompareImageTest::compareSpecialsDisallowedThreshold, |
|
|
|
|
|
|
|
|
|
&CompareImageTest::image, |
|
|
|
|
&CompareImageTest::imageZeroDelta, |
|
|
|
|
&CompareImageTest::imageNonZeroDelta, |
|
|
|
|
&CompareImageTest::imageError}); |
|
|
|
|
|
|
|
|
|
addTests({&CompareImageTest::imageFile, |
|
|
|
|
addTests({&CompareImageTest::imageFileZeroDelta, |
|
|
|
|
&CompareImageTest::imageFileNonZeroDelta, |
|
|
|
|
&CompareImageTest::imageFileError}, |
|
|
|
|
&CompareImageTest::setupExternalPluginManager, |
|
|
|
|
&CompareImageTest::teardownExternalPluginManager); |
|
|
|
|
@ -160,7 +171,8 @@ CompareImageTest::CompareImageTest() {
|
|
|
|
|
addTests({&CompareImageTest::imageFileActualIsCompressed, |
|
|
|
|
&CompareImageTest::imageFileExpectedIsCompressed}); |
|
|
|
|
|
|
|
|
|
addTests({&CompareImageTest::imageToFile, |
|
|
|
|
addTests({&CompareImageTest::imageToFileZeroDelta, |
|
|
|
|
&CompareImageTest::imageToFileNonZeroDelta, |
|
|
|
|
&CompareImageTest::imageToFileError}, |
|
|
|
|
&CompareImageTest::setupExternalPluginManager, |
|
|
|
|
&CompareImageTest::teardownExternalPluginManager); |
|
|
|
|
@ -173,7 +185,8 @@ CompareImageTest::CompareImageTest() {
|
|
|
|
|
|
|
|
|
|
addTests({&CompareImageTest::imageToFileExpectedIsCompressed}); |
|
|
|
|
|
|
|
|
|
addTests({&CompareImageTest::fileToImage, |
|
|
|
|
addTests({&CompareImageTest::fileToImageZeroDelta, |
|
|
|
|
&CompareImageTest::fileToImageNonZeroDelta, |
|
|
|
|
&CompareImageTest::fileToImageError}, |
|
|
|
|
&CompareImageTest::setupExternalPluginManager, |
|
|
|
|
&CompareImageTest::teardownExternalPluginManager); |
|
|
|
|
@ -186,10 +199,12 @@ CompareImageTest::CompareImageTest() {
|
|
|
|
|
|
|
|
|
|
addTests({&CompareImageTest::fileToImageActualIsCompressed}); |
|
|
|
|
|
|
|
|
|
addTests({&CompareImageTest::pixelsToImage, |
|
|
|
|
addTests({&CompareImageTest::pixelsToImageZeroDelta, |
|
|
|
|
&CompareImageTest::pixelsToImageNonZeroDelta, |
|
|
|
|
&CompareImageTest::pixelsToImageError}); |
|
|
|
|
|
|
|
|
|
addTests({&CompareImageTest::pixelsToFile, |
|
|
|
|
addTests({&CompareImageTest::pixelsToFileZeroDelta, |
|
|
|
|
&CompareImageTest::pixelsToFileNonZeroDelta, |
|
|
|
|
&CompareImageTest::pixelsToFileError}, |
|
|
|
|
&CompareImageTest::setupExternalPluginManager, |
|
|
|
|
&CompareImageTest::teardownExternalPluginManager); |
|
|
|
|
@ -615,6 +630,25 @@ void CompareImageTest::compareAboveMeanThreshold() {
|
|
|
|
|
" [1,0] #5647ec, expected #5610ed (Δ = 18.6667)\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::compareNonZeroThreshold() { |
|
|
|
|
std::stringstream out; |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f}; |
|
|
|
|
TestSuite::ComparisonStatusFlags flags = compare(ActualRgb, ExpectedRgb); |
|
|
|
|
/* No diagnostic as we don't have any expected filename */ |
|
|
|
|
CORRADE_COMPARE(flags, TestSuite::ComparisonStatusFlag::Verbose); |
|
|
|
|
Debug d{&out, Debug::Flag::DisableColors}; |
|
|
|
|
compare.printMessage(flags, d, "a", "b"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(out.str(), |
|
|
|
|
"Images a and b have deltas 39/18.5 below threshold 40/20. Delta image:\n" |
|
|
|
|
" |?M|\n" |
|
|
|
|
" Pixels above max/mean threshold:\n" |
|
|
|
|
" [1,1] #abcd85, expected #abcdfa (Δ = 39)\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::compareSpecials() { |
|
|
|
|
std::stringstream out; |
|
|
|
|
|
|
|
|
|
@ -761,6 +795,12 @@ void CompareImageTest::teardownExternalPluginManager() {
|
|
|
|
|
_converterManager = Containers::NullOpt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constexpr const char* ImageCompareVerbose = |
|
|
|
|
"Images a and b have deltas 39/18.5 below threshold 40/20. Delta image:\n" |
|
|
|
|
" |?M|\n" |
|
|
|
|
" Pixels above max/mean threshold:\n" |
|
|
|
|
" [1,1] #abcd85, expected #abcdfa (Δ = 39)\n"; |
|
|
|
|
|
|
|
|
|
constexpr const char* ImageCompareError = |
|
|
|
|
"Images a and b have both max and mean delta above threshold, actual 39/18.5 but at most 20/10 expected. Delta image:\n" |
|
|
|
|
" |?M|\n" |
|
|
|
|
@ -769,12 +809,30 @@ constexpr const char* ImageCompareError =
|
|
|
|
|
" [1,0] #5647ec, expected #5610ed (Δ = 18.6667)\n" |
|
|
|
|
" [0,1] #235710, expected #232710 (Δ = 16)\n"; |
|
|
|
|
|
|
|
|
|
void CompareImageTest::image() { |
|
|
|
|
CORRADE_COMPARE_WITH(ActualRgb, ExpectedRgb, (CompareImage{40.0f, 20.0f})); |
|
|
|
|
void CompareImageTest::imageZeroDelta() { |
|
|
|
|
CORRADE_COMPARE_WITH(ExpectedRgb, ExpectedRgb, (CompareImage{40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f}; |
|
|
|
|
CORRADE_COMPARE(compare(ActualRgb, ExpectedRgb), TestSuite::ComparisonStatusFlags{}); |
|
|
|
|
CORRADE_COMPARE(compare(ExpectedRgb, ExpectedRgb), TestSuite::ComparisonStatusFlags{}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::imageNonZeroDelta() { |
|
|
|
|
/* This will produce output if --verbose is specified */ |
|
|
|
|
CORRADE_COMPARE_WITH(ActualRgb, ExpectedRgb, (CompareImage{40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f}; |
|
|
|
|
TestSuite::ComparisonStatusFlags flags = compare(ActualRgb, ExpectedRgb); |
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
CORRADE_COMPARE(flags, TestSuite::ComparisonStatusFlag::Verbose); |
|
|
|
|
Debug d{&out, Debug::Flag::DisableColors}; |
|
|
|
|
compare.printMessage(flags, d, "a", "b"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(out.str(), ImageCompareVerbose); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::imageError() { |
|
|
|
|
@ -792,22 +850,49 @@ void CompareImageTest::imageError() {
|
|
|
|
|
CORRADE_COMPARE(out.str(), ImageCompareError); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::imageFile() { |
|
|
|
|
void CompareImageTest::imageFileZeroDelta() { |
|
|
|
|
if(_importerManager->loadState("AnyImageImporter") == PluginManager::LoadState::NotFound || |
|
|
|
|
_importerManager->loadState("TgaImporter") == PluginManager::LoadState::NotFound) |
|
|
|
|
CORRADE_SKIP("AnyImageImporter or TgaImporter plugins not found."); |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE_WITH( |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"), |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"), |
|
|
|
|
(CompareImageFile{*_importerManager, 40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f}; |
|
|
|
|
CORRADE_COMPARE(compare( |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"), |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga")), |
|
|
|
|
TestSuite::ComparisonStatusFlags{}); |
|
|
|
|
TestSuite::ComparisonStatusFlag{}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::imageFileNonZeroDelta() { |
|
|
|
|
if(_importerManager->loadState("AnyImageImporter") == PluginManager::LoadState::NotFound || |
|
|
|
|
_importerManager->loadState("TgaImporter") == PluginManager::LoadState::NotFound) |
|
|
|
|
CORRADE_SKIP("AnyImageImporter or TgaImporter plugins not found."); |
|
|
|
|
|
|
|
|
|
/* This will produce output if --verbose is specified */ |
|
|
|
|
CORRADE_COMPARE_WITH( |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"), |
|
|
|
|
(CompareImageFile{*_importerManager, 40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f}; |
|
|
|
|
TestSuite::ComparisonStatusFlags flags = compare( |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga")); |
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
CORRADE_COMPARE(flags, TestSuite::ComparisonStatusFlag::Verbose); |
|
|
|
|
Debug d{&out, Debug::Flag::DisableColors}; |
|
|
|
|
compare.printMessage(flags, d, "a", "b"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(out.str(), ImageCompareVerbose); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::imageFileError() { |
|
|
|
|
@ -995,21 +1080,45 @@ void CompareImageTest::imageFileExpectedIsCompressed() {
|
|
|
|
|
CORRADE_VERIFY(!Utility::Directory::exists(filename)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::imageToFile() { |
|
|
|
|
void CompareImageTest::imageToFileZeroDelta() { |
|
|
|
|
if(_importerManager->loadState("AnyImageImporter") == PluginManager::LoadState::NotFound || |
|
|
|
|
_importerManager->loadState("TgaImporter") == PluginManager::LoadState::NotFound) |
|
|
|
|
CORRADE_SKIP("AnyImageImporter or TgaImporter plugins not found."); |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE_WITH(ActualRgb, |
|
|
|
|
CORRADE_COMPARE_WITH(ExpectedRgb, |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"), |
|
|
|
|
(CompareImageToFile{*_importerManager, 40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f}; |
|
|
|
|
CORRADE_COMPARE(compare(ActualRgb, Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga")), |
|
|
|
|
CORRADE_COMPARE(compare(ExpectedRgb, Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga")), |
|
|
|
|
TestSuite::ComparisonStatusFlags{}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::imageToFileNonZeroDelta() { |
|
|
|
|
if(_importerManager->loadState("AnyImageImporter") == PluginManager::LoadState::NotFound || |
|
|
|
|
_importerManager->loadState("TgaImporter") == PluginManager::LoadState::NotFound) |
|
|
|
|
CORRADE_SKIP("AnyImageImporter or TgaImporter plugins not found."); |
|
|
|
|
|
|
|
|
|
/* This will produce output if --verbose is specified */ |
|
|
|
|
CORRADE_COMPARE_WITH(ActualRgb, |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"), |
|
|
|
|
(CompareImageToFile{*_importerManager, 40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f}; |
|
|
|
|
TestSuite::ComparisonStatusFlags flags = compare(ActualRgb, Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga")); |
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
CORRADE_COMPARE(flags, TestSuite::ComparisonStatusFlag::Verbose); |
|
|
|
|
Debug d{&out, Debug::Flag::DisableColors}; |
|
|
|
|
compare.printMessage(flags, d, "a", "b"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(out.str(), ImageCompareVerbose); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::imageToFileError() { |
|
|
|
|
if(_importerManager->loadState("AnyImageImporter") == PluginManager::LoadState::NotFound || |
|
|
|
|
_importerManager->loadState("TgaImporter") == PluginManager::LoadState::NotFound) |
|
|
|
|
@ -1149,22 +1258,48 @@ void CompareImageTest::imageToFileExpectedIsCompressed() {
|
|
|
|
|
CORRADE_VERIFY(!Utility::Directory::exists(filename)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::fileToImage() { |
|
|
|
|
void CompareImageTest::fileToImageZeroDelta() { |
|
|
|
|
if(_importerManager->loadState("AnyImageImporter") == PluginManager::LoadState::NotFound || |
|
|
|
|
_importerManager->loadState("TgaImporter") == PluginManager::LoadState::NotFound) |
|
|
|
|
CORRADE_SKIP("AnyImageImporter or TgaImporter plugins not found."); |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE_WITH( |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"), |
|
|
|
|
ExpectedRgb, |
|
|
|
|
(CompareFileToImage{*_importerManager, 40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 40.0f, 20.0f}; |
|
|
|
|
CORRADE_COMPARE(compare(Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), |
|
|
|
|
CORRADE_COMPARE(compare(Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"), |
|
|
|
|
ExpectedRgb), TestSuite::ComparisonStatusFlags{}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::fileToImageNonZeroDelta() { |
|
|
|
|
if(_importerManager->loadState("AnyImageImporter") == PluginManager::LoadState::NotFound || |
|
|
|
|
_importerManager->loadState("TgaImporter") == PluginManager::LoadState::NotFound) |
|
|
|
|
CORRADE_SKIP("AnyImageImporter or TgaImporter plugins not found."); |
|
|
|
|
|
|
|
|
|
/* This will produce output if --verbose is specified */ |
|
|
|
|
CORRADE_COMPARE_WITH( |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), |
|
|
|
|
ExpectedRgb, |
|
|
|
|
(CompareFileToImage{*_importerManager, 40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 40.0f, 20.0f}; |
|
|
|
|
TestSuite::ComparisonStatusFlags flags = compare(Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), |
|
|
|
|
ExpectedRgb); |
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
CORRADE_COMPARE(flags, TestSuite::ComparisonStatusFlag::Verbose); |
|
|
|
|
Debug d{&out, Debug::Flag::DisableColors}; |
|
|
|
|
compare.printMessage(flags, d, "a", "b"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(out.str(), ImageCompareVerbose); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::fileToImageError() { |
|
|
|
|
if(_importerManager->loadState("AnyImageImporter") == PluginManager::LoadState::NotFound || |
|
|
|
|
_importerManager->loadState("TgaImporter") == PluginManager::LoadState::NotFound) |
|
|
|
|
@ -1247,15 +1382,35 @@ void CompareImageTest::fileToImageActualIsCompressed() {
|
|
|
|
|
"Actual image a (.../CompareImageCompressed.dds) is compressed, comparison not possible.\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::pixelsToImage() { |
|
|
|
|
void CompareImageTest::pixelsToImageZeroDelta() { |
|
|
|
|
/* Same as image(), but taking pixels instead */ |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE_WITH(ActualRgb.pixels<Color3ub>(), |
|
|
|
|
CORRADE_COMPARE_WITH(ExpectedRgb.pixels<Color3ub>(), |
|
|
|
|
ExpectedRgb, (CompareImage{40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f}; |
|
|
|
|
CORRADE_COMPARE(compare(ActualRgb.pixels<Color3ub>(), ExpectedRgb), TestSuite::ComparisonStatusFlags{}); |
|
|
|
|
CORRADE_COMPARE(compare(ExpectedRgb.pixels<Color3ub>(), ExpectedRgb), TestSuite::ComparisonStatusFlags{}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::pixelsToImageNonZeroDelta() { |
|
|
|
|
/* Same as image(), but taking pixels instead */ |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE_WITH(ActualRgb.pixels<Color3ub>(), |
|
|
|
|
ExpectedRgb, (CompareImage{40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f}; |
|
|
|
|
TestSuite::ComparisonStatusFlags flags = compare(ActualRgb.pixels<Color3ub>(), ExpectedRgb); |
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
CORRADE_COMPARE(flags, TestSuite::ComparisonStatusFlag::Verbose); |
|
|
|
|
Debug d{&out, Debug::Flag::DisableColors}; |
|
|
|
|
compare.printMessage(flags, d, "a", "b"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(out.str(), ImageCompareVerbose); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::pixelsToImageError() { |
|
|
|
|
@ -1276,23 +1431,48 @@ void CompareImageTest::pixelsToImageError() {
|
|
|
|
|
CORRADE_COMPARE(out.str(), ImageCompareError); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::pixelsToFile() { |
|
|
|
|
void CompareImageTest::pixelsToFileZeroDelta() { |
|
|
|
|
/* Same as imageToFile(), but taking pixels instead */ |
|
|
|
|
|
|
|
|
|
if(_importerManager->loadState("AnyImageImporter") == PluginManager::LoadState::NotFound || |
|
|
|
|
_importerManager->loadState("TgaImporter") == PluginManager::LoadState::NotFound) |
|
|
|
|
CORRADE_SKIP("AnyImageImporter or TgaImporter plugins not found."); |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE_WITH(ActualRgb.pixels<Color3ub>(), |
|
|
|
|
CORRADE_COMPARE_WITH(ExpectedRgb.pixels<Color3ub>(), |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"), |
|
|
|
|
(CompareImageToFile{*_importerManager, 40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f}; |
|
|
|
|
CORRADE_COMPARE(compare(ActualRgb.pixels<Color3ub>(), Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga")), |
|
|
|
|
CORRADE_COMPARE(compare(ExpectedRgb.pixels<Color3ub>(), Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga")), |
|
|
|
|
TestSuite::ComparisonStatusFlags{}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::pixelsToFileNonZeroDelta() { |
|
|
|
|
/* Same as imageToFile(), but taking pixels instead */ |
|
|
|
|
|
|
|
|
|
if(_importerManager->loadState("AnyImageImporter") == PluginManager::LoadState::NotFound || |
|
|
|
|
_importerManager->loadState("TgaImporter") == PluginManager::LoadState::NotFound) |
|
|
|
|
CORRADE_SKIP("AnyImageImporter or TgaImporter plugins not found."); |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE_WITH(ActualRgb.pixels<Color3ub>(), |
|
|
|
|
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"), |
|
|
|
|
(CompareImageToFile{*_importerManager, 40.0f, 20.0f})); |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f}; |
|
|
|
|
TestSuite::ComparisonStatusFlags flags = compare(ActualRgb.pixels<Color3ub>(), Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga")); |
|
|
|
|
/* No diagnostic as there's no error */ |
|
|
|
|
CORRADE_COMPARE(flags, TestSuite::ComparisonStatusFlag::Verbose); |
|
|
|
|
Debug d{&out, Debug::Flag::DisableColors}; |
|
|
|
|
compare.printMessage(flags, d, "a", "b"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(out.str(), ImageCompareVerbose); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CompareImageTest::pixelsToFileError() { |
|
|
|
|
/* Same as imageToFileError(), but taking pixels instead */ |
|
|
|
|
|
|
|
|
|
|