Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | Properties | List of all members
GoldenTestManager Class Reference

#include <GoldenTestManager.h>

Inheritance diagram for GoldenTestManager:

Instance Methods

(instancetype) - initWithLaunchArg:
 
(void) - checkGoldenForTest:rmesThreshold:
 

Properties

GoldenImagegoldenImage
 
NSString * identifier
 
NSString * launchArg
 

Detailed Description

Definition at line 21 of file GoldenTestManager.h.

Method Documentation

◆ checkGoldenForTest:rmesThreshold:

- (void) checkGoldenForTest: (XCTestCase*)  test
rmesThreshold: (double)  rmesThreshold 

Definition at line 17 of file GoldenTestManager.m.

79 :(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];
86 // Instead of XCTFail because that definition changed between Xcode 11 and 12 whereas this impl
87 // is stable.
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);
92 }
93
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];
99
100 _XCTPrimitiveFail(test,
101 @"Goldens do not match. Follow the steps in the "
102 @"README to update golden named %@ if needed.",
103 _goldenImage.goldenName);
104 }
105}
sk_sp< SkImage > image
Definition examples.cpp:29

◆ initWithLaunchArg:

- (instancetype) initWithLaunchArg: (NSString*)  launchArg

Definition at line 17 of file GoldenTestManager.m.

19 :(NSString*)launchArg {
20 self = [super init];
21 if (self) {
22 // The launchArgsMap should match the one in the `PlatformVieGoldenTestManager`.
23 static NSDictionary<NSString*, NSString*>* launchArgsMap;
24 static dispatch_once_t onceToken;
25 dispatch_once(&onceToken, ^{
26 launchArgsMap = @{
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",
58 };
59 });
60 _identifier = launchArgsMap[launchArg];
61
62 NSString* impeller = @"";
63 NSNumber* enableImpeller = [[NSBundle bundleWithIdentifier:@"dev.flutter.ScenariosUITests"]
64 objectForInfoDictionaryKey:@"FLTEnableImpeller"];
65 if (enableImpeller != nil) {
66 impeller = enableImpeller.boolValue ? @"impeller_" : @"";
67 } else {
68 NSLog(@"FLTEnableImpeller was nil");
69 }
70 NSLog(@"impeller = '%@'", impeller);
71
72 NSString* prefix = [NSString stringWithFormat:@"golden_%@_%@", _identifier, impeller];
73 _goldenImage = [[GoldenImage alloc] initWithGoldenNamePrefix:prefix];
74 _launchArg = launchArg;
75 }
76 return self;
77}
int64_t _identifier
NS_ASSUME_NONNULL_BEGIN NSDictionary * launchArgsMap

Property Documentation

◆ goldenImage

- (GoldenImage*) goldenImage
readnonatomicstrong

Definition at line 23 of file GoldenTestManager.h.

◆ identifier

- (NSString*) identifier
readnonatomiccopy

Definition at line 24 of file GoldenTestManager.h.

◆ launchArg

- (NSString*) launchArg
readnonatomiccopy

Definition at line 25 of file GoldenTestManager.h.


The documentation for this class was generated from the following files: