6#import <XCTest/XCTest.h>
19- (instancetype)initWithLaunchArg:(NSString*)launchArg {
24 static dispatch_once_t onceToken;
25 dispatch_once(&onceToken, ^{
27 @"--platform-view" :
@"platform_view",
28 @"--platform-view-multiple" :
@"platform_view_multiple",
29 @"--platform-view-multiple-background-foreground" :
30 @"platform_view_multiple_background_foreground",
31 @"--platform-view-cliprect" :
@"platform_view_cliprect",
32 @"--platform-view-cliprrect" :
@"platform_view_cliprrect",
33 @"--platform-view-large-cliprrect" :
@"platform_view_large_cliprrect",
34 @"--platform-view-clippath" :
@"platform_view_clippath",
35 @"--platform-view-cliprrect-with-transform" :
@"platform_view_cliprrect_with_transform",
36 @"--platform-view-large-cliprrect-with-transform" :
37 @"platform_view_large_cliprrect_with_transform",
38 @"--platform-view-cliprect-with-transform" :
@"platform_view_cliprect_with_transform",
39 @"--platform-view-clippath-with-transform" :
@"platform_view_clippath_with_transform",
40 @"--platform-view-transform" :
@"platform_view_transform",
41 @"--platform-view-opacity" :
@"platform_view_opacity",
42 @"--platform-view-with-other-backdrop-filter" :
@"platform_view_with_other_backdrop_filter",
43 @"--two-platform-views-with-other-backdrop-filter" :
44 @"two_platform_views_with_other_backdrop_filter",
45 @"--platform-view-with-negative-backdrop-filter" :
46 @"platform_view_with_negative_backdrop_filter",
47 @"--platform-view-rotate" :
@"platform_view_rotate",
48 @"--non-full-screen-flutter-view-platform-view" :
49 @"non_full_screen_flutter_view_platform_view",
50 @"--bogus-font-text" :
@"bogus_font_text",
51 @"--spawn-engine-works" :
@"spawn_engine_works",
52 @"--platform-view-cliprect-after-moved" :
@"platform_view_cliprect_after_moved",
53 @"--two-platform-view-clip-rect" :
@"two_platform_view_clip_rect",
54 @"--two-platform-view-clip-rrect" :
@"two_platform_view_clip_rrect",
55 @"--two-platform-view-clip-path" :
@"two_platform_view_clip_path",
56 @"--app-extension" :
@"app_extension",
57 @"--darwin-system-font" :
@"darwin_system_font",
63 NSNumber* enableImpeller = [[NSBundle bundleWithIdentifier:@"dev.flutter.ScenariosUITests"]
64 objectForInfoDictionaryKey:@"FLTEnableImpeller"];
65 if (enableImpeller != nil) {
66 impeller = enableImpeller.boolValue ?
@"impeller_" :
@"";
68 NSLog(
@"FLTEnableImpeller was nil");
72 NSString*
prefix = [NSString stringWithFormat:@"golden_%@_%@", _identifier, impeller];
73 _goldenImage = [[
GoldenImage alloc] initWithGoldenNamePrefix:prefix];
79- (void)checkGoldenForTest:(XCTestCase*)test rmesThreshold:(
double)rmesThreshold {
80 XCUIScreenshot* screenshot = [[XCUIScreen mainScreen] screenshot];
81 if (!_goldenImage.image) {
82 XCTAttachment* attachment = [XCTAttachment attachmentWithScreenshot:screenshot];
83 attachment.name = [_goldenImage.goldenName stringByAppendingString:@"_new.png"];
84 attachment.lifetime = XCTAttachmentLifetimeKeepAlways;
85 [test addAttachment:attachment];
88 _XCTPrimitiveFail(
test,
89 @"This test will fail - no golden named %@ found. "
90 @"Follow the steps in the README to add a new golden.",
91 _goldenImage.goldenName);
94 if (![_goldenImage compareGoldenToImage:screenshot.image rmesThreshold:rmesThreshold]) {
95 XCTAttachment* screenshotAttachment = [XCTAttachment attachmentWithImage:screenshot.image];
96 screenshotAttachment.name = [_goldenImage.goldenName stringByAppendingString:@"_actual.png"];
97 screenshotAttachment.lifetime = XCTAttachmentLifetimeKeepAlways;
98 [test addAttachment:screenshotAttachment];
100 _XCTPrimitiveFail(
test,
101 @"Goldens do not match. Follow the steps in the "
102 @"README to update golden named %@ if needed.",
103 _goldenImage.goldenName);
const double kDefaultRmseThreshold
NSDictionary * launchArgsMap
GoldenImage * goldenImage