Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1814,8 +1814,8 @@ - (void)performOrientationUpdate:(UIInterfaceOrientationMask)new_preferences {
}
UIWindowScene* windowScene = (UIWindowScene*)scene;
UIWindowSceneGeometryPreferencesIOS* preference =
[[UIWindowSceneGeometryPreferencesIOS alloc]
initWithInterfaceOrientations:_orientationPreferences];
[[[UIWindowSceneGeometryPreferencesIOS alloc]
initWithInterfaceOrientations:_orientationPreferences] autorelease];
[windowScene
requestGeometryUpdateWithPreferences:preference
errorHandler:^(NSError* error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Comment on lines +1344 to +1345
Copy link
Member Author

@jmagman jmagman Apr 5, 2023

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.

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
Copy link
Member Author

Choose a reason for hiding this comment

The 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,
Expand Down