Skip to content

Commit bc96baf

Browse files
authored
Refactor FXIOS-12796 [Swift 6 Migration] Fix main actor isolation warnings that are Swift 6 errors in the XCUITests suite - Batch 3 (#31029)
* Fix main actor isolation warnings that are Swift 6 errors in the XCUITests suite. * Fix setup/teardown warnings in the XCUITests suite. * Add additional main actor isolation.
1 parent f031061 commit bc96baf

File tree

9 files changed

+32
-18
lines changed

9 files changed

+32
-18
lines changed

firefox-ios/firefox-ios-tests/Tests/XCUITests/DownloadsTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ let testBLOBFileSize = "35 bytes"
1515
class DownloadsTests: BaseTestCase {
1616
var downloadsScreen: DownloadsScreen!
1717
var browserScreen: BrowserScreen!
18-
override func tearDown() {
19-
defer { super.tearDown() }
2018

21-
guard let navigator = navigator else {
22-
print("⚠️ Navigator is nil in tearDown — skipping cleanup.")
23-
return
24-
}
19+
override func tearDown() async throws {
20+
guard let navigator = navigator else {
21+
print("⚠️ Navigator is nil in tearDown — skipping cleanup.")
22+
return
23+
}
24+
2525
// The downloaded file has to be removed between tests
2626
app.terminate()
2727
app.launch()
@@ -37,7 +37,7 @@ class DownloadsTests: BaseTestCase {
3737
app.tables["DownloadsTable"].buttons["Delete"].waitAndTap()
3838
}
3939
}
40-
super.tearDown()
40+
try await super.tearDown()
4141
}
4242

4343
private func deleteItem(itemName: String) {

firefox-ios/firefox-ios-tests/Tests/XCUITests/DragAndDropTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ let websiteWithSearchField = "https://developer.mozilla.org/en-US/"
2424
let tabTrayCollectionView = AccessibilityIdentifiers.TabTray.collectionView
2525

2626
class DragAndDropTests: BaseTestCase {
27-
// Disable test suite since in theory it does not make sense with Chron tabs implementation
28-
override func tearDown() {
27+
// Disable test suite since in theory it does not make sense with Chron tabs implementation
28+
override func tearDown() async throws {
2929
XCUIDevice.shared.orientation = UIDeviceOrientation.portrait
30-
super.tearDown()
30+
try await super.tearDown()
3131
}
3232

3333
// https://mozilla.testrail.io/index.php?/cases/view/2362645

firefox-ios/firefox-ios-tests/Tests/XCUITests/FxScreenGraph.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ extension MMNavigator where T == FxUserState {
292292
performAction(Action.LoadURLByTyping)
293293
}
294294

295+
@MainActor
295296
func mozWaitForElementToExist(_ element: XCUIElement, timeout: TimeInterval? = TIMEOUT) {
296297
let startTime = Date()
297298

@@ -305,6 +306,7 @@ extension MMNavigator where T == FxUserState {
305306
}
306307

307308
// Opens a URL in a new tab.
309+
@MainActor
308310
func openNewURL(urlString: String) {
309311
let app = XCUIApplication()
310312
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton], timeout: 10)
@@ -314,6 +316,7 @@ extension MMNavigator where T == FxUserState {
314316
}
315317

316318
// Add a new Tab from the New Tab option in Browser Tab Menu
319+
@MainActor
317320
func createNewTab() {
318321
let app = XCUIApplication()
319322
self.goto(TabTray)
@@ -322,6 +325,7 @@ extension MMNavigator where T == FxUserState {
322325
}
323326

324327
// Add Tab(s) from the Tab Tray
328+
@MainActor
325329
func createSeveralTabsFromTabTray(numberTabs: Int) {
326330
let app = XCUIApplication()
327331
for _ in 1...numberTabs {

firefox-ios/firefox-ios-tests/Tests/XCUITests/HomeButtonTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import XCTest
66

77
class HomeButtonTests: BaseTestCase {
8-
override func tearDown() {
8+
override func tearDown() async throws {
99
XCUIDevice.shared.orientation = .portrait
10-
super.tearDown()
10+
try await super.tearDown()
1111
}
1212

1313
// https://mozilla.testrail.io/index.php?/cases/view/2306925

firefox-ios/firefox-ios-tests/Tests/XCUITests/ScreenGraphTest.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ private class TestActions {
119119
static let LoadURLByPasting = "LoadURLByPasting"
120120
}
121121

122+
@MainActor
122123
public var isTablet: Bool {
123124
// There is more value in a variable having the same name,
124125
// so it can be used in both predicates and in code
125126
// than avoiding the duplication of one line of code.
126127
return UIDevice.current.userInterfaceIdiom == .pad
127128
}
128129

130+
@MainActor
129131
private func createTestGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScreenGraph<TestUserState> {
130132
let map = MMScreenGraph(for: test, with: TestUserState.self)
131133

firefox-ios/firefox-ios-tests/Tests/XCUITests/Selectors/WebsiteDataSelectorSet.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ protocol WebsiteDataSelectorsSet {
1616
var EXAMPLE_CONTAINS: Selector { get }
1717
var CIRCLE_IMAGE_ANYWHERE: Selector { get }
1818
var STATIC_TEXT_EXAMPLE_IN_CELL: Selector { get }
19+
20+
@MainActor
1921
func clearAllLabel(in app: XCUIApplication) -> XCUIElement
22+
@MainActor
2023
func circleImageInsideCells(_ app: XCUIApplication) -> XCUIElement
24+
@MainActor
2125
func anyTableButton(_ app: XCUIApplication) -> XCUIElement
26+
2227
var all: [Selector] { get }
2328
}
2429

@@ -102,14 +107,17 @@ struct WebsiteDataSelectors: WebsiteDataSelectorsSet {
102107
groups: ["settings", "websitedata"]
103108
)
104109

110+
@MainActor
105111
func clearAllLabel(in app: XCUIApplication) -> XCUIElement {
106112
app.tables.cells[IDs.clearAllCell].staticTexts[IDs.clearAllLabel]
107113
}
108114

115+
@MainActor
109116
func circleImageInsideCells(_ app: XCUIApplication) -> XCUIElement {
110117
return app.cells.images.matching(identifier: IDs.circleImageId).firstMatch
111118
}
112119

120+
@MainActor
113121
func anyTableButton(_ app: XCUIApplication) -> XCUIElement {
114122
return app.tables.buttons.firstMatch
115123
}

firefox-ios/firefox-ios-tests/Tests/XCUITests/SettingsTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import XCTest
77
class SettingsTests: FeatureFlaggedTestBase {
88
var settingsScreen: SettingScreen!
99

10-
override func tearDown() {
10+
override func tearDown() async throws {
1111
if name.contains("testAutofillPasswordSettingsOptionSubtitles") ||
1212
name.contains("testBrowsingSettingsOptionSubtitles") ||
1313
name.contains("testSettingsOptionSubtitlesDarkMode") ||
1414
name.contains("testSettingsOptionSubtitlesDarkModeLandscape") {
1515
switchThemeToDarkOrLight(theme: "Light")
1616
}
1717
XCUIDevice.shared.orientation = .portrait
18-
super.tearDown()
18+
try await super.tearDown()
1919
}
2020

2121
private func checkShowImages(showImages: Bool = true) {

firefox-ios/firefox-ios-tests/Tests/XCUITests/SwipingTabsTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import Foundation
66
import XCTest
77

88
class SwipingTabsTests: BaseTestCase {
9-
override func tearDown() {
9+
override func tearDown() async throws {
1010
XCUIDevice.shared.orientation = .portrait
11-
super.tearDown()
11+
try await super.tearDown()
1212
}
1313

1414
let addressBar = XCUIApplication().textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField]

firefox-ios/firefox-ios-tests/Tests/XCUITests/ToolbarMenuTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import Foundation
66
import XCTest
77

88
class ToolbarMenuTests: BaseTestCase {
9-
override func tearDown() {
9+
override func tearDown() async throws {
1010
XCUIDevice.shared.orientation = .portrait
11-
super.tearDown()
11+
try await super.tearDown()
1212
}
1313

1414
// https://mozilla.testrail.io/index.php?/cases/view/2306840

0 commit comments

Comments
 (0)