Skip to content

Commit 5f3a165

Browse files
authored
Refactor FXIOS-14344 [Swift 6 migration] Fixing warnings in unit tests (#31078)
* Unit tests fun * Trying something * Revert for that tests case to get the other in for now. Will come back to this later
1 parent 5439adb commit 5f3a165

24 files changed

+90
-106
lines changed

firefox-ios/firefox-ios-tests/Tests/ClientTests/Application/AppLaunchUtilTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ import XCTest
1111
final class AppLaunchUtilTests: XCTestCase {
1212
var profile: MockProfile!
1313

14-
override func setUp() {
15-
super.setUp()
14+
override func setUp() async throws {
15+
try await super.setUp()
1616
DependencyHelperMock().bootstrapDependencies()
1717
TelemetryContextualIdentifier.clearUserDefaults()
1818
profile = MockProfile()
1919
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
2020
}
2121

22-
override func tearDown() {
22+
override func tearDown() async throws {
2323
DependencyHelperMock().reset()
2424
TelemetryContextualIdentifier.clearUserDefaults()
2525
profile = nil
26-
super.tearDown()
26+
try await super.tearDown()
2727
}
2828

2929
// MARK: Telemetry contextual identifier setup

firefox-ios/firefox-ios-tests/Tests/ClientTests/ClientTests.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Shared
99
import WebKit
1010

1111
class ClientTests: XCTestCase {
12+
@MainActor
1213
func testSyncUA() {
1314
let ua = UserAgent.syncUserAgent
1415
let device = DeviceInfo.deviceModel()
@@ -33,17 +34,4 @@ class ClientTests: XCTestCase {
3334
}
3435
XCTAssertTrue(compare(UserAgent.mobileUserAgent()), "User agent computes correctly.")
3536
}
36-
37-
// Disabling for now due to https://github.com/mozilla-mobile/firefox-ios/pull/6468
38-
// This hard-codes the desktop UA, not much to test as a result of that
39-
// func testDesktopUserAgent() {
40-
// let compare: (String) -> Bool = { ua in
41-
// let range = ua.range(
42-
// of: "^Mozilla/5\\.0 \\(Macintosh; Intel Mac OS X [0-9\\.]+\\)",
43-
// options: .regularExpression
44-
// )
45-
// return range != nil
46-
// }
47-
// XCTAssertTrue(compare(UserAgent.desktopUserAgent()), "Desktop user agent computes correctly.")
48-
// }
4937
}

firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/BaseCoordinatorTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ final class BaseCoordinatorTests: XCTestCase {
1010
var navigationController: NavigationController!
1111
var router: MockRouter!
1212

13-
override func setUp() {
14-
super.setUp()
13+
override func setUp() async throws {
14+
try await super.setUp()
1515
navigationController = MockNavigationController()
1616
router = MockRouter(navigationController: navigationController)
1717
}
1818

19-
override func tearDown() {
20-
super.tearDown()
19+
override func tearDown() async throws {
2120
navigationController = nil
2221
router = nil
22+
try await super.tearDown()
2323
}
2424

2525
func testAddChild() {

firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/EnhancedTrackingProtectionCoordinatorTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ final class EnhancedTrackingProtectionCoordinatorTests: XCTestCase {
2020
private var glean: MockGleanWrapper!
2121
private var delegate: MockEnhancedTrackingProtectionCoordinatorDelegate!
2222

23-
override func setUp() {
24-
super.setUp()
23+
override func setUp() async throws {
24+
try await super.setUp()
2525
self.profile = MockProfile()
2626
DependencyHelperMock().bootstrapDependencies()
2727
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
@@ -32,15 +32,15 @@ final class EnhancedTrackingProtectionCoordinatorTests: XCTestCase {
3232
self.delegate = MockEnhancedTrackingProtectionCoordinatorDelegate()
3333
}
3434

35-
override func tearDown() {
35+
override func tearDown() async throws {
3636
self.routeBuilder = nil
3737
self.mockRouter = nil
3838
self.profile = nil
3939
self.tabManager = nil
4040
self.glean = nil
4141
self.delegate = nil
4242
DependencyHelperMock().reset()
43-
super.tearDown()
43+
try await super.tearDown()
4444
}
4545

4646
func testParentCoordinatorDelegate_calledWithPage() {

firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Launch/LaunchCoordinatorTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ final class LaunchCoordinatorTests: XCTestCase {
1515
private var delegate: MockLaunchCoordinatorDelegate!
1616
let windowUUID: WindowUUID = .XCTestDefaultUUID
1717

18-
override func setUp() {
19-
super.setUp()
18+
override func setUp() async throws {
19+
try await super.setUp()
2020
DependencyHelperMock().bootstrapDependencies()
2121
profile = MockProfile()
2222
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
2323
mockRouter = MockRouter(navigationController: MockNavigationController())
2424
delegate = MockLaunchCoordinatorDelegate()
2525
}
2626

27-
override func tearDown() {
27+
override func tearDown() async throws {
2828
DependencyHelperMock().reset()
2929
profile = nil
3030
mockRouter = nil
3131
delegate = nil
32-
super.tearDown()
32+
try await super.tearDown()
3333
}
3434

3535
func testInitialState() {

firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/LaunchView/LaunchScreenViewControllerTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ final class LaunchScreenViewControllerTests: XCTestCase {
3232
try await super.tearDown()
3333
}
3434

35+
@MainActor
3536
func testNotLoaded_notCalled() {
3637
_ = createSubject()
3738
XCTAssertEqual(viewModel.startLoadingCalled, 0)
3839
}
3940

41+
@MainActor
4042
func testViewDidLoad_whenLaunchType_callsCoordinatorLaunch() {
4143
viewModel.mockLaunchType = .intro(manager: viewModel.introScreenManager)
4244
let subject = createSubject()
@@ -51,6 +53,7 @@ final class LaunchScreenViewControllerTests: XCTestCase {
5153
XCTAssertEqual(viewModel.startLoadingCalled, 1)
5254
}
5355

56+
@MainActor
5457
func testViewDidLoad_whenNilLaunchType_callsCoordinatorBrowser() {
5558
viewModel.mockLaunchType = nil
5659
let subject = createSubject()
@@ -61,6 +64,7 @@ final class LaunchScreenViewControllerTests: XCTestCase {
6164
XCTAssertEqual(viewModel.startLoadingCalled, 1)
6265
}
6366

67+
@MainActor
6468
func testAddLaunchView_whenViewWillAppear() {
6569
let subject = LaunchScreenViewController(windowUUID: windowUUID,
6670
coordinator: coordinatorDelegate,
@@ -71,6 +75,7 @@ final class LaunchScreenViewControllerTests: XCTestCase {
7175
}
7276

7377
// MARK: - Helpers
78+
@MainActor
7479
private func createSubject(file: StaticString = #filePath,
7580
line: UInt = #line) -> LaunchScreenViewController {
7681
let subject = LaunchScreenViewController(windowUUID: windowUUID,

firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/LaunchView/ModernLaunchScreenViewControllerTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ final class ModernLaunchScreenViewControllerTests: XCTestCase {
1515
private let windowUUID: WindowUUID = .XCTestDefaultUUID
1616

1717
// MARK: - Test Setup & Teardown
18-
override func setUp() {
19-
super.setUp()
18+
override func setUp() async throws {
19+
try await super.setUp()
2020
DependencyHelperMock().bootstrapDependencies()
2121
let profile = MockProfile()
2222
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
2323
viewModel = MockLaunchScreenViewModel(windowUUID: windowUUID, profile: profile)
2424
coordinatorDelegate = MockLaunchFinishedLoadingDelegate()
2525
}
2626

27-
override func tearDown() {
27+
override func tearDown() async throws {
2828
DependencyHelperMock().reset()
2929
viewModel = nil
3030
coordinatorDelegate = nil
31-
super.tearDown()
31+
try await super.tearDown()
3232
}
3333

3434
// MARK: - Initialization Tests

firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/BookmarksCoordinatorTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ final class BookmarksCoordinatorTests: XCTestCase {
1212
private var parentCoordinator: MockLibraryCoordinatorDelegate!
1313
private var navigationHandler: MockLibraryNavigationHandler!
1414

15-
override func setUp() {
16-
super.setUp()
15+
override func setUp() async throws {
16+
try await super.setUp()
1717
DependencyHelperMock().bootstrapDependencies()
1818
router = MockRouter(navigationController: UINavigationController())
1919
profile = MockProfile()
@@ -22,13 +22,13 @@ final class BookmarksCoordinatorTests: XCTestCase {
2222
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
2323
}
2424

25-
override func tearDown() {
26-
super.tearDown()
25+
override func tearDown() async throws {
2726
DependencyHelperMock().reset()
2827
router = nil
2928
profile = nil
3029
parentCoordinator = nil
3130
navigationHandler = nil
31+
try await super.tearDown()
3232
}
3333

3434
// MARK: Bookmarks

firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/DownloadsCoordinatorTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ final class DownloadsCoordinatorTests: XCTestCase {
1111
private var parentCoordinator: MockLibraryCoordinatorDelegate!
1212
private var profile: MockProfile!
1313

14-
override func setUp() {
15-
super.setUp()
14+
override func setUp() async throws {
15+
try await super.setUp()
1616
profile = MockProfile()
1717
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
1818
router = MockRouter(navigationController: UINavigationController())
1919
parentCoordinator = MockLibraryCoordinatorDelegate()
2020
DependencyHelperMock().bootstrapDependencies()
2121
}
2222

23-
override func tearDown() {
24-
super.tearDown()
23+
override func tearDown() async throws {
2524
router = nil
2625
parentCoordinator = nil
2726
profile = nil
2827
DependencyHelperMock().reset()
28+
try await super.tearDown()
2929
}
3030

3131
func testHandleFile_presentsShareController() {

firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/HistoryCoordinatorTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ final class HistoryCoordinatorTests: XCTestCase {
1313
private var notificationCenter: MockNotificationCenter!
1414
private var navigationHandler: MockLibraryNavigationHandler!
1515

16-
override func setUp() {
17-
super.setUp()
16+
override func setUp() async throws {
17+
try await super.setUp()
1818
DependencyHelperMock().bootstrapDependencies()
1919
router = MockRouter(navigationController: UINavigationController())
2020
profile = MockProfile()
@@ -23,14 +23,14 @@ final class HistoryCoordinatorTests: XCTestCase {
2323
navigationHandler = MockLibraryNavigationHandler()
2424
}
2525

26-
override func tearDown() {
27-
super.tearDown()
26+
override func tearDown() async throws {
2827
DependencyHelperMock().reset()
2928
router = nil
3029
profile = nil
3130
parentCoordinator = nil
3231
notificationCenter = nil
3332
navigationHandler = nil
33+
try await super.tearDown()
3434
}
3535

3636
func testShowRecentlyClosedTabs() {

0 commit comments

Comments
 (0)