Skip to content

Commit e2caa58

Browse files
authored
[image_picker_ios] Fix Swift warnings in ImagePickerPluginTests (flutter#13299)
Fix bug where `presentingViewControllerWithoutWindowSceneUsesFrame` was asserting always true, so was hiding that the test wasn't really presenting a window. This wasn't showing up in CI due to flutter#194517. Fixes flutter#194603 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent ddc298b commit e2caa58

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.swift‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ struct ImagePickerPluginTests {
533533
let picker = PHPickerViewController(configuration: PHPickerConfiguration())
534534
await confirmation("cancelled") { confirmed in
535535
plugin.callContext = FLTImagePickerMethodCallContext { result, error in
536-
#expect(result as? [String] == [])
536+
#expect(result == [])
537537
#expect(error == nil)
538538
confirmed()
539539
}
@@ -549,7 +549,7 @@ struct ImagePickerPluginTests {
549549
presentedViewController: presented, presenting: presenting)
550550
await confirmation("dismissed") { confirmed in
551551
plugin.callContext = FLTImagePickerMethodCallContext { result, error in
552-
#expect(result as? [String] == [])
552+
#expect(result == [])
553553
#expect(error == nil)
554554
confirmed()
555555
}
@@ -753,14 +753,18 @@ struct ImagePickerPluginTests {
753753
plugin.removeInteractionBlocker()
754754
}
755755

756-
@Test func presentingViewControllerWithoutWindowSceneUsesFrame() {
756+
@Test func presentingViewControllerWithoutWindowSceneUsesFrame() throws {
757757
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
758758
let rootViewController = UIViewController()
759759
window.rootViewController = rootViewController
760760
rootViewController.loadViewIfNeeded()
761+
window.addSubview(rootViewController.view)
761762
let plugin = FLTImagePickerPlugin(
762763
viewProvider: StubViewProvider(viewController: rootViewController))
763-
#expect(plugin.presentingViewControllerForImagePickerInNewWindow() != nil)
764+
let presenter = plugin.presentingViewControllerForImagePickerInNewWindow()
765+
let blockerWindow = try #require(plugin.interactionBlockerWindow)
766+
#expect(blockerWindow.rootViewController === presenter)
767+
#expect(blockerWindow.frame == window.bounds)
764768
plugin.removeInteractionBlocker()
765769
}
766770

0 commit comments

Comments
 (0)