From 172a3930f79f3e0a8c7ccc4987e18bc223643eaf Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 30 Oct 2020 13:05:34 -0700 Subject: [PATCH] Report image diff status for iOS scenario golden tests (#22230) --- .../ios/Scenarios/ScenariosUITests/GoldenImage.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m index 909cac11c..cc622d7df 100644 --- a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m +++ b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m @@ -5,6 +5,7 @@ #import "GoldenImage.h" #import +#import #include static const double kRmseThreshold = 0.5; @@ -29,6 +30,7 @@ static const double kRmseThreshold = 0.5; - (BOOL)compareGoldenToImage:(UIImage*)image { if (!self.image || !image) { + os_log_error(OS_LOG_DEFAULT, "GOLDEN DIFF FAILED: image does not exists."); return NO; } CGImageRef imageRefA = [self.image CGImage]; @@ -40,6 +42,7 @@ static const double kRmseThreshold = 0.5; NSUInteger heightB = CGImageGetHeight(imageRefB); if (widthA != widthB || heightA != heightB) { + os_log_error(OS_LOG_DEFAULT, "GOLDEN DIFF FAILED: images sizes do not match."); return NO; } NSUInteger bytesPerPixel = 4; @@ -48,6 +51,7 @@ static const double kRmseThreshold = 0.5; NSMutableData* rawB = [NSMutableData dataWithLength:size]; if (!rawA || !rawB) { + os_log_error(OS_LOG_DEFAULT, "GOLDEN DIFF FAILED: image data length do not match."); return NO; } @@ -87,7 +91,14 @@ static const double kRmseThreshold = 0.5; } } double rmse = sqrt(sum / size); - return rmse <= kRmseThreshold; + if (rmse > kRmseThreshold) { + os_log_error( + OS_LOG_DEFAULT, + "GOLDEN DIFF FAILED: image diff greater than threshold. Current diff: %@, threshold: %@", + @(rmse), @(kRmseThreshold)); + return NO; + } + return YES; } NS_INLINE NSString* _platformName() { -- GitLab