From 0b59ffc8fd646844a45c4bc8be4d9ea77e36772f Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 30 Oct 2020 10:00:39 -0700 Subject: [PATCH 1/3] report diff --- .../ios/Scenarios/ScenariosUITests/GoldenImage.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m index 909cac11c7eac..8b23b895e6e28 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; @@ -28,7 +29,9 @@ - (instancetype)initWithGoldenNamePrefix:(NSString*)prefix { } - (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 +43,7 @@ - (BOOL)compareGoldenToImage:(UIImage*)image { 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 +52,7 @@ - (BOOL)compareGoldenToImage:(UIImage*)image { 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 +92,11 @@ - (BOOL)compareGoldenToImage:(UIImage*)image { } } 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() { From 6b3d61904bbcd55d6307583378188fc3d16a5f13 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 30 Oct 2020 10:03:51 -0700 Subject: [PATCH 2/3] cleanup --- .../scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m index 8b23b895e6e28..18708ff0e1bcc 100644 --- a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m +++ b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m @@ -29,7 +29,6 @@ - (instancetype)initWithGoldenNamePrefix:(NSString*)prefix { } - (BOOL)compareGoldenToImage:(UIImage*)image { - if (!self.image || !image) { os_log_error(OS_LOG_DEFAULT, "GOLDEN DIFF FAILED: image does not exists."); return NO; From 0d7304aaceac79beaf155cc647a382cfe5f4bf9a Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 30 Oct 2020 10:38:40 -0700 Subject: [PATCH 3/3] format --- .../ios/Scenarios/ScenariosUITests/GoldenImage.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m index 18708ff0e1bcc..cc622d7df1139 100644 --- a/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m +++ b/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m @@ -92,7 +92,10 @@ - (BOOL)compareGoldenToImage:(UIImage*)image { } double rmse = sqrt(sum / size); if (rmse > kRmseThreshold) { - os_log_error(OS_LOG_DEFAULT, "GOLDEN DIFF FAILED: image diff greater than threshold. Current diff: %@, threshold: %@", @(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;