From 2b2092a7812756e11b15e73c4d64de79bb764abf Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 19 Sep 2023 14:23:16 -0700 Subject: [PATCH] [ios] scenario test make parent view controller hide status bar (flutter/engine#46065) The parent view controller of FlutterViewController in `non_full_screen_flutter_view_platform_view` does not explicitly set the status bar hidden. iOS 17 will show the status bar causing the golden to be no deterministic. Part of https://github.com/flutter/flutter/issues/133207 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../ios/Scenarios/Scenarios/AppDelegate.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m index d938a89537..9aa3a00430 100644 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m +++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m @@ -9,6 +9,20 @@ #import "ScreenBeforeFlutter.h" #import "TextPlatformView.h" +// A UIViewController that sets YES for its preferedStatusBarHidden property. +// StatusBar includes current time, which is non-deterministic. This ViewController +// removes the StatusBar to make the screenshot deterministic. +@interface NoStatusBarViewController : UIViewController + +@end + +@implementation NoStatusBarViewController +- (BOOL)prefersStatusBarHidden { + return YES; +} +@end + +// The FlutterViewController version of NoStatusBarViewController @interface NoStatusBarFlutterViewController : FlutterViewController @end @@ -166,7 +180,7 @@ UIViewController* rootViewController = flutterViewController; // Make Flutter View's origin x/y not 0. if ([scenarioIdentifier isEqualToString:@"non_full_screen_flutter_view_platform_view"]) { - rootViewController = [UIViewController new]; + rootViewController = [[NoStatusBarViewController alloc] init]; [rootViewController.view addSubview:flutterViewController.view]; flutterViewController.view.frame = CGRectMake(150, 150, 500, 500); }