Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaTardio committed May 15, 2024
1 parent 014eec4 commit a09f90e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions IntegrationTests/Tab/AddressBarTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,41 @@ class AddressBarTests: XCTestCase {
let shieldImage = mainViewController.navigationBarViewController.addressBarViewController!.addressBarButtonsViewController!.privacyEntryPointButton.image!
XCTAssertTrue(shieldImage.isEqualToImage(expectedImage))
}

@MainActor
func test_ZoomLevelNonDefault_ThenZoomButtonIsVisible() async throws {
// GIVEN
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .userEntered("")))
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
viewModel.selectedTabViewModel?.zoomWasSet(to: .percent150)
let tabLoadedPromise = tab.webViewDidFinishNavigationPublisher.timeout(5).first().promise()

// WHEN
window = WindowsManager.openNewWindow(with: viewModel)!
_=try await tabLoadedPromise.value

// THEN
let zoomButton = mainViewController.navigationBarViewController.addressBarViewController!.addressBarButtonsViewController!.zoomButton!
XCTAssertFalse(zoomButton.isHidden)
}

@MainActor
func test_ZoomLevelDefault_ThenZoomButtonIsNotVisible() async throws {
// GIVEN
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .userEntered("")))
tab.webView.zoomLevel = AccessibilityPreferences.shared.defaultPageZoom
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
viewModel.selectedTabViewModel?.zoomWasSet(to: .percent100)
let tabLoadedPromise = tab.webViewDidFinishNavigationPublisher.timeout(5).first().promise()

// WHEN
window = WindowsManager.openNewWindow(with: viewModel)!
_=try await tabLoadedPromise.value

// THEN
let zoomButton = mainViewController.navigationBarViewController.addressBarViewController!.addressBarButtonsViewController!.zoomButton!
XCTAssertTrue(zoomButton.isHidden)
}
}

protocol MainActorPerformer {
Expand Down

0 comments on commit a09f90e

Please sign in to comment.