[ios]Adjust golden test threshold for TwoPlatformViewsWithOtherBackDropFilterTests based on current macOS version (flutter/engine#45891)
TwoPlatformViewsWithOtherBackDropFilterTests is failing on macOS 13 with the same simulator version used in macOS 12. The image diff looks identical and slightly above the threshold. This PR adjusts the threshold for this test temporarily so our CI can run on both macOS 13 and 12. This change can be reverted when we move all our CI to macOS 13 Fixes https://github.com/flutter/flutter/issues/134740 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -25,7 +25,7 @@ FLUTTER_ASSERT_ARC
|
||||
XCTAssertTrue([addTextField waitForExistenceWithTimeout:30]);
|
||||
|
||||
GoldenTestManager* manager = [[GoldenTestManager alloc] initWithLaunchArg:@"--bogus-font-text"];
|
||||
[manager checkGoldenForTest:self];
|
||||
[manager checkGoldenForTest:self rmesThreshold:kDefaultRmseThreshold];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// Compare this GoldenImage to `image`.
|
||||
//
|
||||
// Return YES if the `image` of this GoldenImage have the same pixels of provided `image`.
|
||||
- (BOOL)compareGoldenToImage:(UIImage*)image;
|
||||
- (BOOL)compareGoldenToImage:(UIImage*)image rmesThreshold:(double)rmesThreshold;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#import <os/log.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
static const double kRmseThreshold = 0.5;
|
||||
|
||||
@interface GoldenImage ()
|
||||
|
||||
@end
|
||||
@@ -28,7 +26,7 @@ static const double kRmseThreshold = 0.5;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)compareGoldenToImage:(UIImage*)image {
|
||||
- (BOOL)compareGoldenToImage:(UIImage*)image rmesThreshold:(double)rmesThreshold {
|
||||
if (!self.image || !image) {
|
||||
os_log_error(OS_LOG_DEFAULT, "GOLDEN DIFF FAILED: image does not exists.");
|
||||
return NO;
|
||||
@@ -91,11 +89,11 @@ static const double kRmseThreshold = 0.5;
|
||||
}
|
||||
}
|
||||
double rmse = sqrt(sum / size);
|
||||
if (rmse > kRmseThreshold) {
|
||||
if (rmse > rmesThreshold) {
|
||||
os_log_error(
|
||||
OS_LOG_DEFAULT,
|
||||
"GOLDEN DIFF FAILED: image diff greater than threshold. Current diff: %@, threshold: %@",
|
||||
@(rmse), @(kRmseThreshold));
|
||||
@(rmse), @(rmesThreshold));
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
|
||||
@@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface GoldenPlatformViewTests : XCTestCase
|
||||
|
||||
@property(nonatomic, strong) XCUIApplication* application;
|
||||
@property(nonatomic, assign) double rmseThreadhold;
|
||||
|
||||
// Initialize with a `GoldenTestManager`.
|
||||
- (instancetype)initWithManager:(GoldenTestManager*)manager invocation:(NSInvocation*)invocation;
|
||||
|
||||
@@ -22,6 +22,7 @@ static const NSInteger kSecondsToWaitForPlatformView = 30;
|
||||
- (instancetype)initWithManager:(GoldenTestManager*)manager invocation:(NSInvocation*)invocation {
|
||||
self = [super initWithInvocation:invocation];
|
||||
_manager = manager;
|
||||
_rmseThreadhold = kDefaultRmseThreshold;
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -45,6 +46,6 @@ static const NSInteger kSecondsToWaitForPlatformView = 30;
|
||||
@(kSecondsToWaitForPlatformView));
|
||||
}
|
||||
|
||||
[self.manager checkGoldenForTest:self];
|
||||
[self.manager checkGoldenForTest:self rmesThreshold:self.rmseThreadhold];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern NSDictionary* launchArgsMap;
|
||||
const extern double kDefaultRmseThreshold;
|
||||
|
||||
// Manages a `GoldenPlatformViewTests`.
|
||||
//
|
||||
@@ -27,7 +28,7 @@ extern NSDictionary* launchArgsMap;
|
||||
|
||||
// Take a sceenshot of the test app and check it has the same pixels with
|
||||
// goldenImage inside the `GoldenTestManager`.
|
||||
- (void)checkGoldenForTest:(XCTestCase*)test;
|
||||
- (void)checkGoldenForTest:(XCTestCase*)test rmesThreshold:(double)rmesThreshold;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
@implementation GoldenTestManager
|
||||
|
||||
NSDictionary* launchArgsMap;
|
||||
const double kDefaultRmseThreshold = 0.5;
|
||||
|
||||
- (instancetype)initWithLaunchArg:(NSString*)launchArg {
|
||||
self = [super init];
|
||||
@@ -73,7 +74,7 @@ NSDictionary* launchArgsMap;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)checkGoldenForTest:(XCTestCase*)test {
|
||||
- (void)checkGoldenForTest:(XCTestCase*)test rmesThreshold:(double)rmesThreshold {
|
||||
XCUIScreenshot* screenshot = [[XCUIScreen mainScreen] screenshot];
|
||||
if (!_goldenImage.image) {
|
||||
XCTAttachment* attachment = [XCTAttachment attachmentWithScreenshot:screenshot];
|
||||
@@ -88,7 +89,7 @@ NSDictionary* launchArgsMap;
|
||||
_goldenImage.goldenName);
|
||||
}
|
||||
|
||||
if (![_goldenImage compareGoldenToImage:screenshot.image]) {
|
||||
if (![_goldenImage compareGoldenToImage:screenshot.image rmesThreshold:rmesThreshold]) {
|
||||
XCTAttachment* screenshotAttachment = [XCTAttachment attachmentWithImage:screenshot.image];
|
||||
screenshotAttachment.name = [_goldenImage.goldenName stringByAppendingString:@"_actual.png"];
|
||||
screenshotAttachment.lifetime = XCTAttachmentLifetimeKeepAlways;
|
||||
|
||||
@@ -375,6 +375,11 @@ static const NSInteger kSecondsToWaitForPlatformView = 30;
|
||||
}
|
||||
|
||||
- (void)testPlatformView {
|
||||
// (TODO)cyanglaz: remove the threshold adjustment after all the ci migrates to macOS13.
|
||||
// https://github.com/flutter/flutter/issues/133207
|
||||
if ([NSProcessInfo processInfo].operatingSystemVersion.majorVersion >= 13) {
|
||||
self.rmseThreadhold = 0.7;
|
||||
}
|
||||
[self checkPlatformViewGolden];
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
GoldenTestManager* manager =
|
||||
[[GoldenTestManager alloc] initWithLaunchArg:@"--spawn-engine-works"];
|
||||
[manager checkGoldenForTest:self];
|
||||
[manager checkGoldenForTest:self rmesThreshold:kDefaultRmseThreshold];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user