Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit daa0f7a

Browse files
authored
Revert "Add a golden scenario test for fallback font rendering on iOS take 2 (#22033)" (#22095)
This reverts commit cde78c1.
1 parent 5677d3d commit daa0f7a

20 files changed

+119
-185
lines changed

testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj

Lines changed: 34 additions & 14 deletions
Large diffs are not rendered by default.

testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios.xcscheme

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES"
3030
systemAttachmentLifetime = "keepNever">
31+
<MacroExpansion>
32+
<BuildableReference
33+
BuildableIdentifier = "primary"
34+
BlueprintIdentifier = "248D76C622E388370012F0C1"
35+
BuildableName = "Scenarios.app"
36+
BlueprintName = "Scenarios"
37+
ReferencedContainer = "container:Scenarios.xcodeproj">
38+
</BuildableReference>
39+
</MacroExpansion>
3140
<Testables>
3241
<TestableReference
3342
skipped = "NO"
@@ -78,10 +87,6 @@
7887
argument = "--screen-before-flutter"
7988
isEnabled = "NO">
8089
</CommandLineArgument>
81-
<CommandLineArgument
82-
argument = "--bogus-font-text"
83-
isEnabled = "NO">
84-
</CommandLineArgument>
8590
<CommandLineArgument
8691
argument = "--text-semantics-focus"
8792
isEnabled = "NO">

testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ - (BOOL)application:(UIApplication*)application
2727
self.window.tintColor = UIColor.systemPinkColor;
2828
}
2929
NSDictionary<NSString*, NSString*>* launchArgsMap = @{
30-
// The golden test args should match `GoldenTestManager`.
30+
// The Platform view golden test args should match `PlatformViewGoldenTestManager`.
3131
@"--locale-initialization" : @"locale_initialization",
3232
@"--platform-view" : @"platform_view",
3333
@"--platform-view-no-overlay-intersection" : @"platform_view_no_overlay_intersection",
@@ -52,7 +52,6 @@ - (BOOL)application:(UIApplication*)application
5252
@"--tap-status-bar" : @"tap_status_bar",
5353
@"--text-semantics-focus" : @"text_semantics_focus",
5454
@"--animated-color-square" : @"animated_color_square",
55-
@"--bogus-font-text" : @"bogus_font_text"
5655
};
5756
__block NSString* flutterViewControllerTestName = nil;
5857
[launchArgsMap

testing/scenario_app/ios/Scenarios/ScenariosUITests/BogusFontTextTest.m

Lines changed: 0 additions & 28 deletions
This file was deleted.

testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
#import <XCTest/XCTest.h>
6-
#import "GoldenTestManager.h"
6+
#import "PlatformViewGoldenTestManager.h"
77

88
NS_ASSUME_NONNULL_BEGIN
99

@@ -12,19 +12,20 @@ NS_ASSUME_NONNULL_BEGIN
1212
// A new PlatformView golden tests can subclass this and override the `-initiWithInvocation:`
1313
// method, which then retun the `-initWithManager:invocation:`
1414
//
15-
// Then in any test method, call `checkPlatformViewGolden` to perform the golden test.
15+
// Then in any test method, call `checkGolden` to perform the golden test.
1616
//
1717
// This base class doesn't run any test case on its own.
1818
@interface GoldenPlatformViewTests : XCTestCase
1919

2020
@property(nonatomic, strong) XCUIApplication* application;
2121

22-
// Initialize with a `GoldenTestManager`.
23-
- (instancetype)initWithManager:(GoldenTestManager*)manager invocation:(NSInvocation*)invocation;
22+
// Initialize with a `PlatformViewGoldenTestManager`.
23+
- (instancetype)initWithManager:(PlatformViewGoldenTestManager*)manager
24+
invocation:(NSInvocation*)invocation;
2425

2526
// Take a sceenshot of the test app and check it has the same pixels with goldenImage inside the
26-
// `GoldenTestManager`.
27-
- (void)checkPlatformViewGolden;
27+
// `PlatformViewGoldenTestManager`.
28+
- (void)checkGolden;
2829

2930
@end
3031

testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenPlatformViewTests.m

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@
55
#import "GoldenPlatformViewTests.h"
66

77
#include <sys/sysctl.h>
8-
#import "GoldenTestManager.h"
8+
9+
#import "PlatformViewGoldenTestManager.h"
910

1011
static const NSInteger kSecondsToWaitForPlatformView = 30;
1112

1213
@interface GoldenPlatformViewTests ()
1314

1415
@property(nonatomic, copy) NSString* goldenName;
1516

16-
@property(nonatomic, strong) GoldenTestManager* manager;
17+
@property(nonatomic, strong) PlatformViewGoldenTestManager* manager;
1718

1819
@end
1920

2021
@implementation GoldenPlatformViewTests
2122

22-
- (instancetype)initWithManager:(GoldenTestManager*)manager invocation:(NSInvocation*)invocation {
23+
- (instancetype)initWithManager:(PlatformViewGoldenTestManager*)manager
24+
invocation:(NSInvocation*)invocation {
2325
self = [super initWithInvocation:invocation];
2426
_manager = manager;
2527
return self;
@@ -35,7 +37,7 @@ - (void)setUp {
3537
}
3638

3739
// Note: don't prefix with "test" or GoldenPlatformViewTests will run instead of the subclasses.
38-
- (void)checkPlatformViewGolden {
40+
- (void)checkGolden {
3941
XCUIElement* element = self.application.textViews.firstMatch;
4042
BOOL exists = [element waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
4143
if (!exists) {
@@ -45,6 +47,29 @@ - (void)checkPlatformViewGolden {
4547
@(kSecondsToWaitForPlatformView));
4648
}
4749

48-
[self.manager checkGoldenForTest:self];
50+
GoldenImage* golden = self.manager.goldenImage;
51+
52+
XCUIScreenshot* screenshot = [[XCUIScreen mainScreen] screenshot];
53+
if (!golden.image) {
54+
XCTAttachment* attachment = [XCTAttachment attachmentWithScreenshot:screenshot];
55+
attachment.name = @"new_golden";
56+
attachment.lifetime = XCTAttachmentLifetimeKeepAlways;
57+
[self addAttachment:attachment];
58+
XCTFail(@"This test will fail - no golden named %@ found. Follow the steps in the "
59+
@"README to add a new golden.",
60+
golden.goldenName);
61+
}
62+
63+
if (![golden compareGoldenToImage:screenshot.image]) {
64+
XCTAttachment* screenshotAttachment;
65+
screenshotAttachment = [XCTAttachment attachmentWithImage:screenshot.image];
66+
screenshotAttachment.name = golden.goldenName;
67+
screenshotAttachment.lifetime = XCTAttachmentLifetimeKeepAlways;
68+
[self addAttachment:screenshotAttachment];
69+
70+
XCTFail(@"Goldens to not match. Follow the steps in the "
71+
@"README to update golden named %@ if needed.",
72+
golden.goldenName);
73+
}
4974
}
5075
@end

testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenTestManager.h renamed to testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
#import <Foundation/Foundation.h>
6-
#import <XCTest/XCTest.h>
6+
77
#import "GoldenImage.h"
88

99
NS_ASSUME_NONNULL_BEGIN
@@ -14,7 +14,7 @@ extern NSDictionary* launchArgsMap;
1414
//
1515
// It creates the correct `identifer` based on the `launchArg`.
1616
// It also generates the correct GoldenImage based on the `identifier`.
17-
@interface GoldenTestManager : NSObject
17+
@interface PlatformViewGoldenTestManager : NSObject
1818

1919
@property(readonly, strong, nonatomic) GoldenImage* goldenImage;
2020
@property(readonly, copy, nonatomic) NSString* identifier;
@@ -25,10 +25,6 @@ extern NSDictionary* launchArgsMap;
2525
// Crahes if the launchArg is not mapped in `Appdelegate.launchArgsMap`.
2626
- (instancetype)initWithLaunchArg:(NSString*)launchArg;
2727

28-
// Take a sceenshot of the test app and check it has the same pixels with
29-
// goldenImage inside the `GoldenTestManager`.
30-
- (void)checkGoldenForTest:(XCTestCase*)test;
31-
3228
@end
3329

3430
NS_ASSUME_NONNULL_END

testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenTestManager.m renamed to testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.m

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#import "GoldenTestManager.h"
5+
#import "PlatformViewGoldenTestManager.h"
6+
67
#import <XCTest/XCTest.h>
78

8-
@interface GoldenTestManager ()
9+
@interface PlatformViewGoldenTestManager ()
910

1011
@property(readwrite, strong, nonatomic) GoldenImage* goldenImage;
1112

1213
@end
1314

14-
@implementation GoldenTestManager
15+
@implementation PlatformViewGoldenTestManager
1516

1617
NSDictionary* launchArgsMap;
1718

@@ -33,7 +34,6 @@ - (instancetype)initWithLaunchArg:(NSString*)launchArg {
3334
@"--platform-view-transform" : @"platform_view_transform",
3435
@"--platform-view-opacity" : @"platform_view_opacity",
3536
@"--platform-view-rotate" : @"platform_view_rotate",
36-
@"--bogus-font-text" : @"bogus_font_text",
3737
};
3838
});
3939
_identifier = launchArgsMap[launchArg];
@@ -44,32 +44,4 @@ - (instancetype)initWithLaunchArg:(NSString*)launchArg {
4444
return self;
4545
}
4646

47-
- (void)checkGoldenForTest:(XCTestCase*)test {
48-
XCUIScreenshot* screenshot = [[XCUIScreen mainScreen] screenshot];
49-
if (!_goldenImage.image) {
50-
XCTAttachment* attachment = [XCTAttachment attachmentWithScreenshot:screenshot];
51-
attachment.name = [_goldenImage.goldenName stringByAppendingString:@"_new"];
52-
attachment.lifetime = XCTAttachmentLifetimeKeepAlways;
53-
[test addAttachment:attachment];
54-
// Instead of XCTFail because that definition changed between Xcode 11 and 12 whereas this impl
55-
// is stable.
56-
_XCTPrimitiveFail(test,
57-
@"This test will fail - no golden named %@ found. "
58-
@"Follow the steps in the README to add a new golden.",
59-
_goldenImage.goldenName);
60-
}
61-
62-
if (![_goldenImage compareGoldenToImage:screenshot.image]) {
63-
XCTAttachment* screenshotAttachment = [XCTAttachment attachmentWithImage:screenshot.image];
64-
screenshotAttachment.name = [_goldenImage.goldenName stringByAppendingString:@"_actual"];
65-
screenshotAttachment.lifetime = XCTAttachmentLifetimeKeepAlways;
66-
[test addAttachment:screenshotAttachment];
67-
68-
_XCTPrimitiveFail(test,
69-
@"Goldens do not match. Follow the steps in the "
70-
@"README to update golden named %@ if needed.",
71-
_goldenImage.goldenName);
72-
}
73-
}
74-
7547
@end

0 commit comments

Comments
 (0)