Skip to content
Open
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 @@ -11,19 +11,19 @@ import XCTest
final class AppLaunchUtilTests: XCTestCase {
var profile: MockProfile!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
TelemetryContextualIdentifier.clearUserDefaults()
profile = MockProfile()
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
}

override func tearDown() {
override func tearDown() async throws {
DependencyHelperMock().reset()
TelemetryContextualIdentifier.clearUserDefaults()
profile = nil
super.tearDown()
try await super.tearDown()
}

// MARK: Telemetry contextual identifier setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Shared
import WebKit

class ClientTests: XCTestCase {
@MainActor
func testSyncUA() {
let ua = UserAgent.syncUserAgent
let device = DeviceInfo.deviceModel()
Expand All @@ -33,17 +34,4 @@ class ClientTests: XCTestCase {
}
XCTAssertTrue(compare(UserAgent.mobileUserAgent()), "User agent computes correctly.")
}

// Disabling for now due to https://github.com/mozilla-mobile/firefox-ios/pull/6468
// This hard-codes the desktop UA, not much to test as a result of that
// func testDesktopUserAgent() {
// let compare: (String) -> Bool = { ua in
// let range = ua.range(
// of: "^Mozilla/5\\.0 \\(Macintosh; Intel Mac OS X [0-9\\.]+\\)",
// options: .regularExpression
// )
// return range != nil
// }
// XCTAssertTrue(compare(UserAgent.desktopUserAgent()), "Desktop user agent computes correctly.")
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ final class BaseCoordinatorTests: XCTestCase {
var navigationController: NavigationController!
var router: MockRouter!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
navigationController = MockNavigationController()
router = MockRouter(navigationController: navigationController)
}

override func tearDown() {
super.tearDown()
override func tearDown() async throws {
navigationController = nil
router = nil
try await super.tearDown()
}

func testAddChild() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ final class EnhancedTrackingProtectionCoordinatorTests: XCTestCase {
private var glean: MockGleanWrapper!
private var delegate: MockEnhancedTrackingProtectionCoordinatorDelegate!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
self.profile = MockProfile()
DependencyHelperMock().bootstrapDependencies()
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
Expand All @@ -32,15 +32,15 @@ final class EnhancedTrackingProtectionCoordinatorTests: XCTestCase {
self.delegate = MockEnhancedTrackingProtectionCoordinatorDelegate()
}

override func tearDown() {
override func tearDown() async throws {
self.routeBuilder = nil
self.mockRouter = nil
self.profile = nil
self.tabManager = nil
self.glean = nil
self.delegate = nil
DependencyHelperMock().reset()
super.tearDown()
try await super.tearDown()
}

func testParentCoordinatorDelegate_calledWithPage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ final class LaunchCoordinatorTests: XCTestCase {
private var delegate: MockLaunchCoordinatorDelegate!
let windowUUID: WindowUUID = .XCTestDefaultUUID

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
profile = MockProfile()
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
mockRouter = MockRouter(navigationController: MockNavigationController())
delegate = MockLaunchCoordinatorDelegate()
}

override func tearDown() {
override func tearDown() async throws {
DependencyHelperMock().reset()
profile = nil
mockRouter = nil
delegate = nil
super.tearDown()
try await super.tearDown()
}

func testInitialState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ final class LaunchScreenViewControllerTests: XCTestCase {
try await super.tearDown()
}

@MainActor
func testNotLoaded_notCalled() {
_ = createSubject()
XCTAssertEqual(viewModel.startLoadingCalled, 0)
}

@MainActor
func testViewDidLoad_whenLaunchType_callsCoordinatorLaunch() {
viewModel.mockLaunchType = .intro(manager: viewModel.introScreenManager)
let subject = createSubject()
Expand All @@ -51,6 +53,7 @@ final class LaunchScreenViewControllerTests: XCTestCase {
XCTAssertEqual(viewModel.startLoadingCalled, 1)
}

@MainActor
func testViewDidLoad_whenNilLaunchType_callsCoordinatorBrowser() {
viewModel.mockLaunchType = nil
let subject = createSubject()
Expand All @@ -61,6 +64,7 @@ final class LaunchScreenViewControllerTests: XCTestCase {
XCTAssertEqual(viewModel.startLoadingCalled, 1)
}

@MainActor
func testAddLaunchView_whenViewWillAppear() {
let subject = LaunchScreenViewController(windowUUID: windowUUID,
coordinator: coordinatorDelegate,
Expand All @@ -71,6 +75,7 @@ final class LaunchScreenViewControllerTests: XCTestCase {
}

// MARK: - Helpers
@MainActor
private func createSubject(file: StaticString = #filePath,
line: UInt = #line) -> LaunchScreenViewController {
let subject = LaunchScreenViewController(windowUUID: windowUUID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ final class ModernLaunchScreenViewControllerTests: XCTestCase {
private let windowUUID: WindowUUID = .XCTestDefaultUUID

// MARK: - Test Setup & Teardown
override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
let profile = MockProfile()
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
viewModel = MockLaunchScreenViewModel(windowUUID: windowUUID, profile: profile)
coordinatorDelegate = MockLaunchFinishedLoadingDelegate()
}

override func tearDown() {
override func tearDown() async throws {
DependencyHelperMock().reset()
viewModel = nil
coordinatorDelegate = nil
super.tearDown()
try await super.tearDown()
}

// MARK: - Initialization Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ final class BookmarksCoordinatorTests: XCTestCase {
private var parentCoordinator: MockLibraryCoordinatorDelegate!
private var navigationHandler: MockLibraryNavigationHandler!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
router = MockRouter(navigationController: UINavigationController())
profile = MockProfile()
Expand All @@ -22,13 +22,13 @@ final class BookmarksCoordinatorTests: XCTestCase {
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
}

override func tearDown() {
super.tearDown()
override func tearDown() async throws {
DependencyHelperMock().reset()
router = nil
profile = nil
parentCoordinator = nil
navigationHandler = nil
try await super.tearDown()
}

// MARK: Bookmarks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ final class DownloadsCoordinatorTests: XCTestCase {
private var parentCoordinator: MockLibraryCoordinatorDelegate!
private var profile: MockProfile!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
profile = MockProfile()
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
router = MockRouter(navigationController: UINavigationController())
parentCoordinator = MockLibraryCoordinatorDelegate()
DependencyHelperMock().bootstrapDependencies()
}

override func tearDown() {
super.tearDown()
override func tearDown() async throws {
router = nil
parentCoordinator = nil
profile = nil
DependencyHelperMock().reset()
try await super.tearDown()
}

func testHandleFile_presentsShareController() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ final class HistoryCoordinatorTests: XCTestCase {
private var notificationCenter: MockNotificationCenter!
private var navigationHandler: MockLibraryNavigationHandler!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
router = MockRouter(navigationController: UINavigationController())
profile = MockProfile()
Expand All @@ -23,14 +23,14 @@ final class HistoryCoordinatorTests: XCTestCase {
navigationHandler = MockLibraryNavigationHandler()
}

override func tearDown() {
super.tearDown()
override func tearDown() async throws {
DependencyHelperMock().reset()
router = nil
profile = nil
parentCoordinator = nil
notificationCenter = nil
navigationHandler = nil
try await super.tearDown()
}

func testShowRecentlyClosedTabs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ final class LibraryCoordinatorTests: XCTestCase {
private var mockRouter: MockRouter!
private var delegate: MockLibraryCoordinatorDelegate!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: MockProfile())
DependencyHelperMock().bootstrapDependencies()
self.mockRouter = MockRouter(navigationController: MockNavigationController())
self.delegate = MockLibraryCoordinatorDelegate()
}

override func tearDown() {
super.tearDown()
override func tearDown() async throws {
self.mockRouter = nil
self.delegate = nil
DependencyHelperMock().reset()
try await super.tearDown()
}

func testEmptyChildren_whenCreated() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ final class ReadingListCoordinatorTests: XCTestCase {
var parentCoordinator: MockLibraryCoordinatorDelegate!
private var navigationHandler: MockLibraryNavigationHandler!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
router = MockRouter(navigationController: UINavigationController())
parentCoordinator = MockLibraryCoordinatorDelegate()
navigationHandler = MockLibraryNavigationHandler()
}

override func tearDown() {
super.tearDown()
override func tearDown() async throws {
router = nil
parentCoordinator = nil
navigationHandler = nil
try await super.tearDown()
}

func testOpenUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ final class PasswordManagerCoordinatorTests: XCTestCase {
private var mockParentCoordinator: PasswordManagerCoordinatorDelegateMock!
let windowUUID: WindowUUID = .XCTestDefaultUUID

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
self.mockRouter = MockRouter(navigationController: MockNavigationController())
self.mockParentCoordinator = PasswordManagerCoordinatorDelegateMock()
}

override func tearDown() {
super.tearDown()
override func tearDown() async throws {
self.mockRouter = nil
self.mockParentCoordinator = nil
DependencyHelperMock().reset()
try await super.tearDown()
}

func testStart_withShowOnboarding() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ final class QRCodeCoordinatorTests: XCTestCase {
private var router: MockRouter!
private var parentCoordinator: MockParentCoordinator!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
router = MockRouter(navigationController: UINavigationController())
parentCoordinator = MockParentCoordinator()
}

override func tearDown() {
super.tearDown()
override func tearDown() async throws {
router = nil
parentCoordinator = nil
try await super.tearDown()
}

func testShowQRCode_presentsQRCodeNavigationController() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ final class SceneCoordinatorTests: XCTestCase {
private var mockRouter: MockRouter!
private var profile: MockProfile!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
profile = MockProfile()
DependencyHelperMock().bootstrapDependencies()
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
self.mockRouter = MockRouter(navigationController: MockNavigationController())
}

override func tearDown() {
override func tearDown() async throws {
mockRouter = nil
profile = nil
DependencyHelperMock().reset()
super.tearDown()
try await super.tearDown()
}

func testInitialState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ final class SearchEngineSelectionCoordinatorTests: XCTestCase {
private var mockRouter: MockRouter!
private var mockParentCoordinator: MockParentCoordinator!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
mockRouter = MockRouter(navigationController: MockNavigationController())
mockParentCoordinator = MockParentCoordinator()
Expand Down
Loading