This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix UIWindowSceneGeometryPreferencesIOS leak #40957
Merged
jmagman
merged 1 commit into
flutter:main
from
jmagman:UIWindowSceneGeometryPreferencesIOS-leak
Apr 7, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1341,47 +1341,53 @@ - (void)orientationTestWithOrientationUpdate:(UIInterfaceOrientationMask)mask | |
id mockApplication = OCMClassMock([UIApplication class]); | ||
id mockWindowScene; | ||
id deviceMock; | ||
FlutterViewController* realVC = [[FlutterViewController alloc] initWithEngine:self.mockEngine | ||
nibName:nil | ||
bundle:nil]; | ||
if (@available(iOS 16.0, *)) { | ||
mockWindowScene = OCMClassMock([UIWindowScene class]); | ||
if (realVC.supportedInterfaceOrientations == mask) { | ||
OCMReject([mockWindowScene requestGeometryUpdateWithPreferences:[OCMArg any] | ||
errorHandler:[OCMArg any]]); | ||
__block __weak id weakPreferences; | ||
@autoreleasepool { | ||
FlutterViewController* realVC = [[FlutterViewController alloc] initWithEngine:self.mockEngine | ||
nibName:nil | ||
bundle:nil]; | ||
if (@available(iOS 16.0, *)) { | ||
mockWindowScene = OCMClassMock([UIWindowScene class]); | ||
if (realVC.supportedInterfaceOrientations == mask) { | ||
OCMReject([mockWindowScene requestGeometryUpdateWithPreferences:[OCMArg any] | ||
errorHandler:[OCMArg any]]); | ||
} else { | ||
// iOS 16 will decide whether to rotate based on the new preference, so always set it | ||
// when it changes. | ||
OCMExpect([mockWindowScene | ||
requestGeometryUpdateWithPreferences:[OCMArg checkWithBlock:^BOOL( | ||
UIWindowSceneGeometryPreferencesIOS* | ||
preferences) { | ||
weakPreferences = preferences; | ||
return preferences.interfaceOrientations == mask; | ||
}] | ||
errorHandler:[OCMArg any]]); | ||
} | ||
OCMStub([mockApplication sharedApplication]).andReturn(mockApplication); | ||
OCMStub([mockApplication connectedScenes]).andReturn([NSSet setWithObject:mockWindowScene]); | ||
} else { | ||
// iOS 16 will decide whether to rotate based on the new preference, so always set it | ||
// when it changes. | ||
OCMExpect([mockWindowScene | ||
requestGeometryUpdateWithPreferences:[OCMArg checkWithBlock:^BOOL( | ||
UIWindowSceneGeometryPreferencesIOS* | ||
preferences) { | ||
return preferences.interfaceOrientations == mask; | ||
}] | ||
errorHandler:[OCMArg any]]); | ||
deviceMock = OCMPartialMock([UIDevice currentDevice]); | ||
if (!didChange) { | ||
OCMReject([deviceMock setValue:[OCMArg any] forKey:@"orientation"]); | ||
} else { | ||
OCMExpect([deviceMock setValue:@(resultingOrientation) forKey:@"orientation"]); | ||
} | ||
|
||
OCMStub([mockApplication sharedApplication]).andReturn(mockApplication); | ||
OCMStub([mockApplication statusBarOrientation]).andReturn(currentOrientation); | ||
} | ||
OCMStub([mockApplication sharedApplication]).andReturn(mockApplication); | ||
OCMStub([mockApplication connectedScenes]).andReturn([NSSet setWithObject:mockWindowScene]); | ||
} else { | ||
deviceMock = OCMPartialMock([UIDevice currentDevice]); | ||
if (!didChange) { | ||
OCMReject([deviceMock setValue:[OCMArg any] forKey:@"orientation"]); | ||
|
||
[realVC performOrientationUpdate:mask]; | ||
if (@available(iOS 16.0, *)) { | ||
OCMVerifyAll(mockWindowScene); | ||
} else { | ||
OCMExpect([deviceMock setValue:@(resultingOrientation) forKey:@"orientation"]); | ||
OCMVerifyAll(deviceMock); | ||
} | ||
|
||
OCMStub([mockApplication sharedApplication]).andReturn(mockApplication); | ||
OCMStub([mockApplication statusBarOrientation]).andReturn(currentOrientation); | ||
} | ||
|
||
[realVC performOrientationUpdate:mask]; | ||
if (@available(iOS 16.0, *)) { | ||
OCMVerifyAll(mockWindowScene); | ||
} else { | ||
OCMVerifyAll(deviceMock); | ||
} | ||
[mockWindowScene stopMocking]; | ||
[deviceMock stopMocking]; | ||
[mockApplication stopMocking]; | ||
XCTAssertNil(weakPreferences); | ||
Comment on lines
+1387
to
+1390
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And these two line changes are new. |
||
} | ||
|
||
// Creates a mocked UITraitCollection with nil values for everything except accessibilityContrast, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this file change is whitespace, but this is new.