Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor FXIOS-10467 - Remove force_cast violations from BrowserKit and firefox-ios #23412

Conversation

bmihai23
Copy link
Contributor

@bmihai23 bmihai23 commented Nov 26, 2024

📜 Tickets

Jira ticket
Github issue

💡 Description

  • This PR remove force_cast violations from:
    • NotificationService
    • AppContainer
    • TestBrowserDB
    • JumpBackInTests
    • WKUserScriptManagerTests
    • SearchEngineTableView
  • This PR is part of a series aimed at adding a new SwiftLint rule in the project, as described in Swiftlint: force_cast #22916

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

@bmihai23 bmihai23 requested review from a team as code owners November 26, 2024 18:53
@bmihai23 bmihai23 requested a review from jjSDET November 26, 2024 18:53
Copy link
Collaborator

@FilippoZazzeroni FilippoZazzeroni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contributions 🎉 just some nit comments 💬. Great work again 😃

@@ -14,6 +14,15 @@ import class MozillaAppServices.Viaduct
class NotificationService: UNNotificationServiceExtension {
var display: SyncDataDisplay?
var profile: BrowserProfile?
private let logger: Logger

init(display: SyncDataDisplay? = nil,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that unfortunately we can't have a custom init in the NotificationService since the system will call init() when he needs an object from this class. We should restore this to previous implementation, i tried testing on simulator but i'm having some difficulties to fire the notification service extension, but i remember from previous work that trying to have custom init results in getting the notification service not working.

@@ -30,7 +39,12 @@ class NotificationService: UNNotificationServiceExtension {

let userInfo = request.content.userInfo

let content = request.content.mutableCopy() as! UNMutableNotificationContent
guard let content = request.content.mutableCopy() as? UNMutableNotificationContent else {
logger.log("Unable to create a mutable copy of UNNotificationContent from the notification request",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should call contentHandler(request.content) here instead of the log so the notification doesn't get deferred to the process termination.

@FilippoZazzeroni FilippoZazzeroni self-requested a review November 27, 2024 11:04
@mobiletest-ci-bot
Copy link

mobiletest-ci-bot commented Nov 27, 2024

Messages
📖 Project coverage: 33.83%
📖 Edited 6 files
📖 Created 0 files

NotificationService.appex: Coverage: 25.92

File Coverage
NotificationService.swift 0.0% ⚠️

Generated by 🚫 Danger Swift against ac4ef09

@FilippoZazzeroni FilippoZazzeroni requested review from clarmso and removed request for jjSDET November 28, 2024 10:38
@FilippoZazzeroni
Copy link
Collaborator

Hi @clarmso could you please have a look to this PR, looks good to me on my side. Thanks very much 🎉

} else {
XCTFail("Failed to retrieve the URL string from the address toolbar")
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XCTAssertEqual allows a message argument: https://developer.apple.com/documentation/xctest/2142776-xctassertequal

XCTAssertEqual(url, "wikipedia.org", "Failed to retrieve the URL string from the address toolbar")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @clarmso, I wasn't aware of the message argument in XCTAssertEqual, I've updated the code to include it. Please let me know if there's anything else to adjust

@FilippoZazzeroni FilippoZazzeroni merged commit d39a471 into mozilla-mobile:main Dec 9, 2024
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants