diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index f05f7fd675cee..f94593913b190 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -681,11 +681,6 @@ - (void)updateViewportMetrics { [_engine.get() updateViewportMetrics:_viewportMetrics]; } -- (void)updateViewConstraints { - [super updateViewConstraints]; - [self onUserSettingsChanged:nil]; -} - - (CGFloat)statusBarPadding { UIScreen* screen = self.view.window.screen; CGRect statusFrame = [UIApplication sharedApplication].statusBarFrame; @@ -695,11 +690,6 @@ - (CGFloat)statusBarPadding { return CGRectIsNull(intersection) ? 0.0 : intersection.size.height; } -- (void)viewWillLayoutSubviews { - [super viewWillLayoutSubviews]; - [self onUserSettingsChanged:nil]; -} - - (void)viewDidLayoutSubviews { CGSize viewSize = self.view.bounds.size; CGFloat scale = [UIScreen mainScreen].scale; @@ -712,7 +702,6 @@ - (void)viewDidLayoutSubviews { [self updateViewportPadding]; [self updateViewportMetrics]; - [self onUserSettingsChanged:nil]; // This must run after updateViewportMetrics so that the surface creation tasks are queued after // the viewport metrics update tasks. @@ -874,16 +863,10 @@ - (void)onLocaleUpdated:(NSNotification*)notification { #pragma mark - Set user settings -- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection { - [super traitCollectionDidChange:previousTraitCollection]; - [self onUserSettingsChanged:nil]; -} - - (void)onUserSettingsChanged:(NSNotification*)notification { [[_engine.get() settingsChannel] sendMessage:@{ @"textScaleFactor" : @([self textScaleFactor]), @"alwaysUse24HourFormat" : @([self isAlwaysUse24HourFormat]), - @"platformBrightness" : [self brightnessMode] }]; } @@ -957,20 +940,6 @@ - (BOOL)isAlwaysUse24HourFormat { return [dateFormat rangeOfString:@"a"].location == NSNotFound; } -- (NSString*)brightnessMode { - if (@available(iOS 13, *)) { - UIUserInterfaceStyle style = UITraitCollection.currentTraitCollection.userInterfaceStyle; - - if (style == UIUserInterfaceStyleDark) { - return @"dark"; - } else { - return @"light"; - } - } else { - return @"light"; - } -} - #pragma mark - Status Bar touch event handling // Standard iOS status bar height in pixels. diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m index 26f99b9903f36..928a551059c74 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m @@ -6,8 +6,6 @@ #import #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h" -#include "FlutterBinaryMessenger.h" - @interface FlutterViewControllerTest : XCTestCase @end @@ -25,85 +23,4 @@ - (void)testBinaryMessenger { OCMVerify([engine binaryMessenger]); } -- (void)testItReportsLightPlatformBrightnessByDefault { - // Setup test. - id engine = OCMClassMock([FlutterEngine class]); - - id settingsChannel = OCMClassMock([FlutterBasicMessageChannel class]); - OCMStub([engine settingsChannel]).andReturn(settingsChannel); - - FlutterViewController* vc = [[FlutterViewController alloc] initWithEngine:engine - nibName:nil - bundle:nil]; - - // Exercise behavior under test. - [vc traitCollectionDidChange:nil]; - - // Verify behavior. - OCMVerify([settingsChannel sendMessage:[OCMArg checkWithBlock:^BOOL(id message) { - return [message[@"platformBrightness"] isEqualToString:@"light"]; - }]]); -} - -- (void)testItReportsDarkPlatformBrightnessWhenTraitCollectionRequestsIt { - // Setup test. - id engine = OCMClassMock([FlutterEngine class]); - - id settingsChannel = OCMClassMock([FlutterBasicMessageChannel class]); - OCMStub([engine settingsChannel]).andReturn(settingsChannel); - - FlutterViewController* vc = [[FlutterViewController alloc] initWithEngine:engine - nibName:nil - bundle:nil]; - id mockTraitCollection = [self setupFakeUserInterfaceStyle:UIUserInterfaceStyleDark]; - - // Exercise behavior under test. - [vc traitCollectionDidChange:nil]; - - // Verify behavior. - OCMVerify([settingsChannel sendMessage:[OCMArg checkWithBlock:^BOOL(id message) { - return [message[@"platformBrightness"] isEqualToString:@"light"]; - }]]); - - // Restore UIUserInterfaceStyle - [mockTraitCollection stopMocking]; -} - -- (void)testItReportsPlatformBrightnessWhenExpected { - // Setup test. - id engine = OCMClassMock([FlutterEngine class]); - - id settingsChannel = OCMClassMock([FlutterBasicMessageChannel class]); - OCMStub([engine settingsChannel]).andReturn(settingsChannel); - - FlutterViewController* vc = [[FlutterViewController alloc] initWithEngine:engine - nibName:nil - bundle:nil]; - id mockTraitCollection = [self setupFakeUserInterfaceStyle:UIUserInterfaceStyleDark]; - - __block int messageCount = 0; - OCMStub([settingsChannel sendMessage:[OCMArg any]]).andDo(^(NSInvocation* invocation) { - messageCount = messageCount + 1; - }); - - // Exercise behavior under test. - [vc updateViewConstraints]; - [vc viewWillLayoutSubviews]; - [vc traitCollectionDidChange:nil]; - [vc onUserSettingsChanged:nil]; - - // Verify behavior. - XCTAssertEqual(messageCount, 4); - - // Restore UIUserInterfaceStyle - [mockTraitCollection stopMocking]; -} - -- (UITraitCollection*)setupFakeUserInterfaceStyle:(UIUserInterfaceStyle)style { - id mockTraitCollection = OCMClassMock([UITraitCollection class]); - OCMStub([mockTraitCollection userInterfaceStyle]).andReturn(UIUserInterfaceStyleDark); - OCMStub([mockTraitCollection currentTraitCollection]).andReturn(mockTraitCollection); - return mockTraitCollection; -} - @end diff --git a/testing/ios/IosUnitTests/run_tests.sh b/testing/ios/IosUnitTests/run_tests.sh index a9eac157e1496..b4efa3d237795 100755 --- a/testing/ios/IosUnitTests/run_tests.sh +++ b/testing/ios/IosUnitTests/run_tests.sh @@ -12,6 +12,6 @@ fi set -o pipefail && xcodebuild -sdk iphonesimulator \ -scheme IosUnitTests \ - -destination 'platform=iOS Simulator,name=iPhone 8,OS=13.0' \ + -destination 'platform=iOS Simulator,name=iPhone SE,OS=12.2' \ test \ FLUTTER_ENGINE=$FLUTTER_ENGINE | $PRETTY