diff --git a/Client/Coordinators/Browser/BrowserCoordinator.swift b/Client/Coordinators/Browser/BrowserCoordinator.swift index f0bd468c776c..1f0c8897bca9 100644 --- a/Client/Coordinators/Browser/BrowserCoordinator.swift +++ b/Client/Coordinators/Browser/BrowserCoordinator.swift @@ -432,15 +432,15 @@ class BrowserCoordinator: BaseCoordinator, guard let fakespotCoordinator = childCoordinators.first(where: { $0 is FakespotCoordinator }) as? FakespotCoordinator else { return // there is no modal to close } - fakespotCoordinator.fakespotControllerDidDismiss(animated: animated) + fakespotCoordinator.dismissModal(animated: animated) } func dismissFakespotSidebar(sidebarContainer: SidebarEnabledViewProtocol, parentViewController: UIViewController) { guard let fakespotCoordinator = childCoordinators.first(where: { $0 is FakespotCoordinator }) as? FakespotCoordinator else { return // there is no sidebar to close } - fakespotCoordinator.fakespotControllerCloseSidebar(sidebarContainer: sidebarContainer, - parentViewController: parentViewController) + fakespotCoordinator.closeSidebar(sidebarContainer: sidebarContainer, + parentViewController: parentViewController) } func updateFakespotSidebar(productURL: URL, diff --git a/Client/Frontend/Browser/BrowserViewController.swift b/Client/Frontend/Browser/BrowserViewController.swift index 513e9180a4ae..0e2ad6ed81d2 100644 --- a/Client/Frontend/Browser/BrowserViewController.swift +++ b/Client/Frontend/Browser/BrowserViewController.swift @@ -169,8 +169,6 @@ class BrowserViewController: UIViewController, return NewTabAccessors.getNewTabPage(profile.prefs) } - lazy var isReduxIntegrationEnabled: Bool = ReduxFlagManager.isReduxEnabled - @available(iOS 13.4, *) func keyboardPressesHandler() -> KeyboardPressesHandler { guard let keyboardPressesHandlerValue = keyboardPressesHandlerValue as? KeyboardPressesHandler else { @@ -453,7 +451,8 @@ class BrowserViewController: UIViewController, private func dismissModalsIfStartAtHome() { if tabManager.startAtHomeCheck() { - guard !dismissFakespotIfNeeded(), presentedViewController != nil else { return } + store.dispatch(FakespotAction.setAppearanceTo(false)) + guard presentedViewController != nil else { return } dismissVC() } } @@ -461,7 +460,6 @@ class BrowserViewController: UIViewController, // MARK: - Redux func subscribeToRedux() { - guard isReduxIntegrationEnabled else { return } store.dispatch(ActiveScreensStateAction.showScreen(.browserViewController)) store.subscribe(self, transform: { @@ -470,9 +468,7 @@ class BrowserViewController: UIViewController, } func unsubscribeFromRedux() { - if isReduxIntegrationEnabled { - store.unsubscribe(self) - } + store.unsubscribe(self) } func newState(state: BrowserViewControllerState) { @@ -482,11 +478,11 @@ class BrowserViewController: UIViewController, browserViewControllerState = state // opens or close sidebar/bottom sheet to match the saved state - if state.fakespotState.isOpenOnProductPage { + if state.fakespotState.isOpen { guard let productURL = urlBar.currentURL else { return } handleFakespotFlow(productURL: productURL) - } else if !state.fakespotState.isOpenOnProductPage { - _ = dismissFakespotIfNeeded() + } else if !state.fakespotState.isOpen { + dismissFakespotIfNeeded() } } } @@ -766,12 +762,12 @@ class BrowserViewController: UIViewController, var fakespotNeedsUpdate = false if urlBar.currentURL != nil { fakespotNeedsUpdate = contentStackView.isSidebarVisible != FakespotUtils().shouldDisplayInSidebar(viewSize: size) - if isReduxIntegrationEnabled, let fakespotState = browserViewControllerState?.fakespotState { - fakespotNeedsUpdate = fakespotNeedsUpdate && fakespotState.isOpenOnProductPage + if let fakespotState = browserViewControllerState?.fakespotState { + fakespotNeedsUpdate = fakespotNeedsUpdate && fakespotState.isOpen } if fakespotNeedsUpdate { - _ = dismissFakespotIfNeeded(animated: false) + dismissFakespotIfNeeded(animated: false) } } @@ -1663,26 +1659,39 @@ class BrowserViewController: UIViewController, } } - private func updateFakespot(tab: Tab) { + internal func updateFakespot(tab: Tab) { guard let webView = tab.webView, let url = webView.url else { + // We're on homepage or a blank tab + store.dispatch(FakespotAction.setAppearanceTo(false)) return } let environment = featureFlags.isCoreFeatureEnabled(.useStagingFakespotAPI) ? FakespotEnvironment.staging : .prod let product = ShoppingProduct(url: url, client: FakespotClient(environment: environment)) - if product.product != nil, !tab.isPrivate, contentStackView.isSidebarVisible { + + guard product.product != nil, !tab.isPrivate else { + store.dispatch(FakespotAction.setAppearanceTo(false)) + + // Quick fix: make sure to sidebar is hidden when opened from deep-link + // Relates to FXIOS-7844 + contentStackView.hideSidebar(self) + return + } + + if contentStackView.isSidebarVisible { + // Sidebar is visible, update content navigationHandler?.updateFakespotSidebar(productURL: url, sidebarContainer: contentStackView, parentViewController: self) - } else if product.product != nil, - !tab.isPrivate, - FakespotUtils().shouldDisplayInSidebar(), - isReduxIntegrationEnabled, + } else if FakespotUtils().shouldDisplayInSidebar(), let fakespotState = browserViewControllerState?.fakespotState, - fakespotState.isOpenOnProductPage { + fakespotState.isOpen { + // Sidebar should be displayed and Fakespot is open, display Fakespot handleFakespotFlow(productURL: url) - } else if contentStackView.isSidebarVisible { - _ = dismissFakespotIfNeeded(animated: true) + } else if let fakespotState = browserViewControllerState?.fakespotState, + fakespotState.sidebarOpenForiPadLandscape { + // Sidebar should be displayed, display Fakespot + store.dispatch(FakespotAction.setAppearanceTo(true)) } } diff --git a/Client/Frontend/Browser/BrowserViewController/BrowserViewController+URLBarDelegate.swift b/Client/Frontend/Browser/BrowserViewController/BrowserViewController+URLBarDelegate.swift index 2b8fb8b76c6c..6fd235acd1a6 100644 --- a/Client/Frontend/Browser/BrowserViewController/BrowserViewController+URLBarDelegate.swift +++ b/Client/Frontend/Browser/BrowserViewController/BrowserViewController+URLBarDelegate.swift @@ -113,38 +113,26 @@ extension BrowserViewController: URLBarDelegate { } } - func urlBarDidPressShopping(_ urlBar: URLBarView, shoppingButton: UIButton) { - guard let productURL = urlBar.currentURL else { return } - TelemetryWrapper.recordEvent(category: .action, method: .tap, object: .shoppingButton) - - let dismissedFakespot = dismissFakespotIfNeeded() - if !dismissedFakespot { - // open flow - handleFakespotFlow(productURL: productURL) - if isReduxIntegrationEnabled { - store.dispatch(FakespotAction.toggleAppearance(true)) - } - } else if isReduxIntegrationEnabled { - // Fakespot was closed/dismissed - store.dispatch(FakespotAction.toggleAppearance(false)) - } - } - - internal func dismissFakespotIfNeeded(animated: Bool = true) -> Bool { - if contentStackView.isSidebarVisible { + internal func dismissFakespotIfNeeded(animated: Bool = true) { + guard !contentStackView.isSidebarVisible else { // hide sidebar as user tapped on shopping icon for a second time navigationHandler?.dismissFakespotSidebar(sidebarContainer: contentStackView, parentViewController: self) - return true - } else if presentedViewController as? FakespotViewController != nil { - // dismiss modal as user tapped on shopping icon for a second time - navigationHandler?.dismissFakespotModal(animated: animated) - return true + return } - return false + + // dismiss modal as user tapped on shopping icon for a second time + navigationHandler?.dismissFakespotModal(animated: animated) } internal func handleFakespotFlow(productURL: URL, viewSize: CGSize? = nil) { - if FakespotUtils().shouldDisplayInSidebar(viewSize: viewSize) { + let shouldDisplayInSidebar = FakespotUtils().shouldDisplayInSidebar(viewSize: viewSize) + if !shouldDisplayInSidebar, contentStackView.isSidebarVisible { + // Quick fix: make sure to sidebar is hidden + // Relates to FXIOS-7844 + contentStackView.hideSidebar(self) + } + + if shouldDisplayInSidebar { navigationHandler?.showFakespotFlowAsSidebar(productURL: productURL, sidebarContainer: contentStackView, parentViewController: self) @@ -171,10 +159,8 @@ extension BrowserViewController: URLBarDelegate { value: .shoppingCFRsDisplayed ) }, - andActionForButton: { [weak self] in - guard let self else { return } - guard let productURL = self.urlBar.currentURL else { return } - self.handleFakespotFlow(productURL: productURL) + andActionForButton: { + store.dispatch(FakespotAction.show) }, overlayState: overlayManager) } diff --git a/Client/Frontend/Browser/BrowserViewController/BrowserViewController+WebViewDelegates.swift b/Client/Frontend/Browser/BrowserViewController/BrowserViewController+WebViewDelegates.swift index ac3075fe35f1..4bbe025c2e59 100644 --- a/Client/Frontend/Browser/BrowserViewController/BrowserViewController+WebViewDelegates.swift +++ b/Client/Frontend/Browser/BrowserViewController/BrowserViewController+WebViewDelegates.swift @@ -764,6 +764,7 @@ extension BrowserViewController: WKNavigationDelegate { if tabManager.selectedTab === tab { self.scrollController.showToolbars(animated: false) updateUIForReaderHomeStateForTab(tab, focusUrlBar: true) + updateFakespot(tab: tab) } } diff --git a/Client/Frontend/Fakespot/FakespotAction.swift b/Client/Frontend/Fakespot/FakespotAction.swift index 494034351589..3791f5266297 100644 --- a/Client/Frontend/Fakespot/FakespotAction.swift +++ b/Client/Frontend/Fakespot/FakespotAction.swift @@ -7,5 +7,8 @@ import Redux enum FakespotAction: Action { // UI trigger actions - case toggleAppearance(Bool) + case pressedShoppingButton + case show + case dismiss + case setAppearanceTo(Bool) } diff --git a/Client/Frontend/Fakespot/FakespotCoordinator.swift b/Client/Frontend/Fakespot/FakespotCoordinator.swift index a16e6f548aad..5ab1daee5b25 100644 --- a/Client/Frontend/Fakespot/FakespotCoordinator.swift +++ b/Client/Frontend/Fakespot/FakespotCoordinator.swift @@ -10,11 +10,7 @@ protocol FakespotCoordinatorDelegate: AnyObject { // Define any coordinator delegate methods } -protocol FakespotViewControllerDelegate: AnyObject { - func fakespotControllerDidDismiss(animated: Bool) -} - -class FakespotCoordinator: BaseCoordinator, FakespotViewControllerDelegate, FeatureFlaggable { +class FakespotCoordinator: BaseCoordinator, FeatureFlaggable { weak var parentCoordinator: ParentCoordinatorDelegate? private var profile: Profile @@ -48,13 +44,13 @@ class FakespotCoordinator: BaseCoordinator, FakespotViewControllerDelegate, Feat sidebarContainer.showSidebar(viewController, parentViewController: parentViewController) } - func fakespotControllerCloseSidebar(sidebarContainer: SidebarEnabledViewProtocol, - parentViewController: UIViewController) { + func closeSidebar(sidebarContainer: SidebarEnabledViewProtocol, + parentViewController: UIViewController) { sidebarContainer.hideSidebar(parentViewController) - fakespotControllerDidDismiss(animated: true) + dismissModal(animated: true) } - func fakespotControllerDidDismiss(animated: Bool) { + func dismissModal(animated: Bool) { router.dismiss(animated: animated, completion: nil) parentCoordinator?.didFinish(from: self) } @@ -69,7 +65,6 @@ class FakespotCoordinator: BaseCoordinator, FakespotViewControllerDelegate, Feat private func createFakespotViewController(productURL: URL) -> FakespotViewController { let viewModel = createFakespotViewModel(productURL: productURL) let fakespotViewController = FakespotViewController(viewModel: viewModel) - fakespotViewController.delegate = self return fakespotViewController } diff --git a/Client/Frontend/Fakespot/FakespotState.swift b/Client/Frontend/Fakespot/FakespotState.swift index 365aeabb2ef7..91a440319c38 100644 --- a/Client/Frontend/Fakespot/FakespotState.swift +++ b/Client/Frontend/Fakespot/FakespotState.swift @@ -6,30 +6,39 @@ import Common import Redux struct FakespotState: ScreenState, Equatable { - var isOpenOnProductPage: Bool + var isOpen: Bool + var sidebarOpenForiPadLandscape: Bool init(_ appState: BrowserViewControllerState) { - self.init(isOpenOnProductPage: appState.fakespotState.isOpenOnProductPage) + self.init(isOpen: appState.fakespotState.isOpen, + sidebarOpenForiPadLandscape: appState.fakespotState.sidebarOpenForiPadLandscape) } init() { - self.init(isOpenOnProductPage: false) + self.init(isOpen: false, sidebarOpenForiPadLandscape: false) } - init(isOpenOnProductPage: Bool) { - self.isOpenOnProductPage = isOpenOnProductPage + init(isOpen: Bool, sidebarOpenForiPadLandscape: Bool) { + self.isOpen = isOpen + self.sidebarOpenForiPadLandscape = sidebarOpenForiPadLandscape } static let reducer: Reducer = { state, action in switch action { - case FakespotAction.toggleAppearance(let isEnabled): - return FakespotState(isOpenOnProductPage: isEnabled) + case FakespotAction.pressedShoppingButton: + return FakespotState(isOpen: !state.isOpen, + sidebarOpenForiPadLandscape: !state.isOpen) + case FakespotAction.show: + return FakespotState(isOpen: true, + sidebarOpenForiPadLandscape: true) + case FakespotAction.dismiss: + return FakespotState(isOpen: false, + sidebarOpenForiPadLandscape: false) + case FakespotAction.setAppearanceTo(let isEnabled): + return FakespotState(isOpen: isEnabled, + sidebarOpenForiPadLandscape: state.sidebarOpenForiPadLandscape) default: return state } } - - static func == (lhs: FakespotState, rhs: FakespotState) -> Bool { - return lhs.isOpenOnProductPage == rhs.isOpenOnProductPage - } } diff --git a/Client/Frontend/Fakespot/FakespotUtils.swift b/Client/Frontend/Fakespot/FakespotUtils.swift index 9342cc0c8abe..338a31e4f7b7 100644 --- a/Client/Frontend/Fakespot/FakespotUtils.swift +++ b/Client/Frontend/Fakespot/FakespotUtils.swift @@ -88,8 +88,12 @@ public struct FakespotUtils: FeatureFlaggable { func shouldDisplayInSidebar(device: UIUserInterfaceIdiom = UIDevice.current.userInterfaceIdiom, window: UIWindow? = UIWindow.attachedKeyWindow, viewSize: CGSize? = nil, + isPortrait: Bool = UIWindow.isPortrait, orientation: UIDeviceOrientation = UIDevice.current.orientation) -> Bool { let isPadInMultitasking = isPadInMultitasking(device: device, window: window, viewSize: viewSize) - return device == .pad && !isPadInMultitasking && !orientation.isPortrait + + // UIDevice is not always returning the correct orientation so we check against the window orientation as well + let isPortrait = orientation.isPortrait || isPortrait + return device == .pad && !isPadInMultitasking && !isPortrait } } diff --git a/Client/Frontend/Fakespot/FakespotViewController.swift b/Client/Frontend/Fakespot/FakespotViewController.swift index 7a9495ed9c14..5c4a3e168144 100644 --- a/Client/Frontend/Fakespot/FakespotViewController.swift +++ b/Client/Frontend/Fakespot/FakespotViewController.swift @@ -41,7 +41,6 @@ class FakespotViewController: var themeManager: ThemeManager var themeObserver: NSObjectProtocol? private var viewModel: FakespotViewModel - weak var delegate: FakespotViewControllerDelegate? lazy var isReduxIntegrationEnabled: Bool = ReduxFlagManager.isReduxEnabled @@ -365,9 +364,9 @@ class FakespotViewController: case .onboarding: let view: FakespotOptInCardView = .build() viewModel.optInCardViewModel.dismissViewController = { [weak self] action in - guard let self = self else { return } - self.delegate?.fakespotControllerDidDismiss(animated: true) - guard let action else { return } + store.dispatch(FakespotAction.setAppearanceTo(false)) + + guard let self = self, let action else { return } viewModel.recordDismissTelemetry(by: action) } viewModel.optInCardViewModel.onOptIn = { [weak self] in @@ -397,9 +396,8 @@ class FakespotViewController: case .qualityDeterminationCard: let reviewQualityCardView: FakespotReviewQualityCardView = .build() - viewModel.reviewQualityCardViewModel.dismissViewController = { [weak self] in - guard let self = self else { return } - self.delegate?.fakespotControllerDidDismiss(animated: true) + viewModel.reviewQualityCardViewModel.dismissViewController = { + store.dispatch(FakespotAction.setAppearanceTo(false)) } reviewQualityCardView.configure(viewModel.reviewQualityCardViewModel) return reviewQualityCardView @@ -408,9 +406,9 @@ class FakespotViewController: let view: FakespotSettingsCardView = .build() view.configure(viewModel.settingsCardViewModel) viewModel.settingsCardViewModel.dismissViewController = { [weak self] action in - guard let self = self else { return } - self.delegate?.fakespotControllerDidDismiss(animated: true) - guard let action else { return } + guard let self = self, let action else { return } + + store.dispatch(FakespotAction.setAppearanceTo(false)) viewModel.recordDismissTelemetry(by: action) } viewModel.settingsCardViewModel.toggleAdsEnabled = { [weak self] in @@ -430,9 +428,8 @@ class FakespotViewController: guard viewModel.areAdsEnabled else { return nil } let view: FakespotAdView = .build() var viewModel = FakespotAdViewModel(productAdsData: adData) - viewModel.dismissViewController = { [weak self] in - guard let self = self else { return } - self.delegate?.fakespotControllerDidDismiss(animated: true) + viewModel.dismissViewController = { + store.dispatch(FakespotAction.setAppearanceTo(false)) } view.configure(viewModel) adView = view @@ -506,11 +503,7 @@ class FakespotViewController: } private func triggerDismiss() { - delegate?.fakespotControllerDidDismiss(animated: true) - - if isReduxIntegrationEnabled { - store.dispatch(FakespotAction.toggleAppearance(false)) - } + store.dispatch(FakespotAction.dismiss) } deinit { diff --git a/Client/Frontend/FeltPrivacy/BrowserViewControllerState.swift b/Client/Frontend/FeltPrivacy/BrowserViewControllerState.swift index f9e3a5ed2c18..b86ad186d1c8 100644 --- a/Client/Frontend/FeltPrivacy/BrowserViewControllerState.swift +++ b/Client/Frontend/FeltPrivacy/BrowserViewControllerState.swift @@ -42,7 +42,13 @@ struct BrowserViewControllerState: ScreenState, Equatable { return BrowserViewControllerState( feltPrivacyState: FeltPrivacyState.reducer(state.feltPrivacyState, action), fakespotState: state.fakespotState) - case FakespotAction.toggleAppearance(let isEnabled): + case FakespotAction.pressedShoppingButton, + FakespotAction.show, + FakespotAction.dismiss: + return BrowserViewControllerState( + feltPrivacyState: state.feltPrivacyState, + fakespotState: FakespotState.reducer(state.fakespotState, action)) + case FakespotAction.setAppearanceTo(let isEnabled): return BrowserViewControllerState( feltPrivacyState: state.feltPrivacyState, fakespotState: FakespotState.reducer(state.fakespotState, action)) diff --git a/Client/Frontend/Toolbar+URLBar/TabLocationView.swift b/Client/Frontend/Toolbar+URLBar/TabLocationView.swift index b3c2b6d83c18..093aaf078b75 100644 --- a/Client/Frontend/Toolbar+URLBar/TabLocationView.swift +++ b/Client/Frontend/Toolbar+URLBar/TabLocationView.swift @@ -14,7 +14,6 @@ protocol TabLocationViewDelegate: AnyObject { func tabLocationViewDidTapShield(_ tabLocationView: TabLocationView) func tabLocationViewDidBeginDragInteraction(_ tabLocationView: TabLocationView) func tabLocationViewDidTapShare(_ tabLocationView: TabLocationView, button: UIButton) - func tabLocationViewDidTapShopping(_ tabLocationView: TabLocationView, button: UIButton) func tabLocationViewPresentCFR(at sourceView: UIView) /// - returns: whether the long-press was handled by the delegate; i.e. return `false` when the conditions for even starting handling long-press were not satisfied @@ -290,7 +289,8 @@ class TabLocationView: UIView, FeatureFlaggable { @objc func didPressShoppingButton(_ button: UIButton) { button.isSelected = true - delegate?.tabLocationViewDidTapShopping(self, button: button) + TelemetryWrapper.recordEvent(category: .action, method: .tap, object: .shoppingButton) + store.dispatch(FakespotAction.pressedShoppingButton) } @objc diff --git a/Client/Frontend/Toolbar+URLBar/URLBarView.swift b/Client/Frontend/Toolbar+URLBar/URLBarView.swift index 208b6c9176ca..48b84b163ccc 100644 --- a/Client/Frontend/Toolbar+URLBar/URLBarView.swift +++ b/Client/Frontend/Toolbar+URLBar/URLBarView.swift @@ -46,7 +46,6 @@ protocol URLBarDelegate: AnyObject { func urlBarDisplayTextForURL(_ url: URL?) -> (String?, Bool) func urlBarDidBeginDragInteraction(_ urlBar: URLBarView) func urlBarDidPressShare(_ urlBar: URLBarView, shareView: UIView) - func urlBarDidPressShopping(_ urlBar: URLBarView, shoppingButton: UIButton) func urlBarPresentCFR(at sourceView: UIView) } @@ -778,10 +777,6 @@ extension URLBarView: TabLocationViewDelegate { delegate?.urlBarDidPressShare(self, shareView: button) } - func tabLocationViewDidTapShopping(_ tabLocationView: TabLocationView, button: UIButton) { - delegate?.urlBarDidPressShopping(self, shoppingButton: button) - } - func tabLocationViewPresentCFR(at sourceView: UIView) { delegate?.urlBarPresentCFR(at: sourceView) } diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/BrowserCoordinatorTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/BrowserCoordinatorTests.swift index d9ea986b17f4..17ca4393b409 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/BrowserCoordinatorTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/BrowserCoordinatorTests.swift @@ -833,7 +833,7 @@ final class BrowserCoordinatorTests: XCTestCase { subject.showFakespotFlowAsModal(productURL: URL(string: "www.example.com")!) let fakespotCoordinator = subject.childCoordinators[0] as! FakespotCoordinator - fakespotCoordinator.fakespotControllerDidDismiss(animated: false) + fakespotCoordinator.dismissModal(animated: false) XCTAssertEqual(mockRouter.dismissCalled, 1) XCTAssertTrue(subject.childCoordinators.isEmpty) diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/FakespotCoordinatorTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/FakespotCoordinatorTests.swift index 45a1482a6157..22c99cee2225 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/FakespotCoordinatorTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/FakespotCoordinatorTests.swift @@ -64,8 +64,8 @@ final class FakespotCoordinatorTests: XCTestCase { subject.startSidebar(productURL: exampleProduct, sidebarContainer: sidebarContainer, parentViewController: viewController) - subject.fakespotControllerCloseSidebar(sidebarContainer: sidebarContainer, - parentViewController: viewController) + subject.closeSidebar(sidebarContainer: sidebarContainer, + parentViewController: viewController) XCTAssertEqual(sidebarContainer.hideSidebarCalled, 1) XCTAssertEqual(mockRouter.dismissCalled, 1) @@ -76,7 +76,7 @@ final class FakespotCoordinatorTests: XCTestCase { let subject = createSubject() subject.startModal(productURL: exampleProduct) - subject.fakespotControllerDidDismiss(animated: false) + subject.dismissModal(animated: false) XCTAssertEqual(mockRouter.dismissCalled, 1) XCTAssertTrue(subject.childCoordinators.isEmpty) diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Fakespot/FakespotUtilsTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Fakespot/FakespotUtilsTests.swift index 111f1a3fad4e..ee5db8d72dfc 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Fakespot/FakespotUtilsTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Fakespot/FakespotUtilsTests.swift @@ -34,11 +34,13 @@ final class FakespotUtilsTests: XCTestCase { func testShouldDisplayInSidebar_withIphone() { let device = UIUserInterfaceIdiom.phone let keyWindow = UIWindow.attachedKeyWindow! + let isPortrait = true let orientation = UIDeviceOrientation.portrait let subject = FakespotUtils() XCTAssertFalse(subject.shouldDisplayInSidebar(device: device, window: keyWindow, viewSize: keyWindow.frame.size, + isPortrait: isPortrait, orientation: orientation), "Should return false for an iPhone") } @@ -46,11 +48,13 @@ final class FakespotUtilsTests: XCTestCase { func testShouldDisplayInSidebar_withIpad_landscape_fullScreen() { let device = UIUserInterfaceIdiom.pad let keyWindow = UIWindow.attachedKeyWindow! + let isPortrait = false let orientation = UIDeviceOrientation.landscapeLeft let subject = FakespotUtils() XCTAssertTrue(subject.shouldDisplayInSidebar(device: device, window: keyWindow, viewSize: keyWindow.frame.size, + isPortrait: isPortrait, orientation: orientation), "Should return true on iPad in landscape in full screen") } @@ -58,11 +62,13 @@ final class FakespotUtilsTests: XCTestCase { func testShouldDisplayInSidebar_withIpad_landscape_splitScreen() { let device = UIUserInterfaceIdiom.pad let keyWindow = UIWindow.attachedKeyWindow! + let isPortrait = false let orientation = UIDeviceOrientation.landscapeRight let subject = FakespotUtils() XCTAssertFalse(subject.shouldDisplayInSidebar(device: device, window: keyWindow, viewSize: CGSize.zero, + isPortrait: isPortrait, orientation: orientation), "Should return false on iPad in landscape in split screen") } @@ -70,11 +76,13 @@ final class FakespotUtilsTests: XCTestCase { func testShouldDisplayInSidebar_withIpad_portrait_fullScreen() { let device = UIUserInterfaceIdiom.pad let keyWindow = UIWindow.attachedKeyWindow! + let isPortrait = true let orientation = UIDeviceOrientation.portrait let subject = FakespotUtils() XCTAssertFalse(subject.shouldDisplayInSidebar(device: device, window: keyWindow, viewSize: keyWindow.frame.size, + isPortrait: isPortrait, orientation: orientation), "Should return false on iPad in portrait in full screen") } @@ -82,11 +90,13 @@ final class FakespotUtilsTests: XCTestCase { func testShouldDisplayInSidebar_withIpad_portrait_splitScreen() { let device = UIUserInterfaceIdiom.pad let keyWindow = UIWindow.attachedKeyWindow! + let isPortrait = true let orientation = UIDeviceOrientation.portrait let subject = FakespotUtils() XCTAssertFalse(subject.shouldDisplayInSidebar(device: device, window: keyWindow, viewSize: CGSize.zero, + isPortrait: isPortrait, orientation: orientation), "Should return false on iPad in portrait in split screen") } diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/TabTray/Legacy/TabLocationViewTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/TabTray/Legacy/TabLocationViewTests.swift index 2dcc16e08426..5e6490a6702f 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/TabTray/Legacy/TabLocationViewTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/TabTray/Legacy/TabLocationViewTests.swift @@ -35,7 +35,6 @@ class MockTabLocationViewDelegate: TabLocationViewDelegate { func tabLocationViewDidTapShield(_ tabLocationView: TabLocationView) {} func tabLocationViewDidBeginDragInteraction(_ tabLocationView: TabLocationView) {} func tabLocationViewDidTapShare(_ tabLocationView: TabLocationView, button: UIButton) {} - func tabLocationViewDidTapShopping(_ tabLocationView: TabLocationView, button: UIButton) {} func tabLocationViewDidLongPressReaderMode(_ tabLocationView: TabLocationView) -> Bool { return false }